Update frontend to allow categories
This commit is contained in:
@@ -14,6 +14,7 @@ export async function fetchServer<T = unknown>(
|
||||
if (!authToken) redirect('/login');
|
||||
|
||||
try {
|
||||
console.log(`${endpoint}`)
|
||||
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}${endpoint}`, {
|
||||
...options,
|
||||
headers: {
|
||||
@@ -29,7 +30,7 @@ export async function fetchServer<T = unknown>(
|
||||
|
||||
return res.json();
|
||||
} catch (error) {
|
||||
console.error(`Server request to ${endpoint} failed:`, error);
|
||||
//console.error(`Server request to ${endpoint} failed:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ export const apiRequest = async <T = any>(endpoint: string, method: string = "GE
|
||||
throw new Error("No authentication token found");
|
||||
}
|
||||
|
||||
// ✅ API Request Options
|
||||
const options: RequestInit = {
|
||||
method,
|
||||
headers: {
|
||||
@@ -41,7 +40,6 @@ export const apiRequest = async <T = any>(endpoint: string, method: string = "GE
|
||||
throw new Error(`Failed to ${method} ${endpoint}: ${errorMessage}`);
|
||||
}
|
||||
|
||||
// ✅ Return JSON response
|
||||
return res;
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { clsx, type ClassValue } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
|
||||
/**
|
||||
* Utility function for merging Tailwind CSS class names with conditional logic.
|
||||
* @param inputs - Class values to merge.
|
||||
|
||||
@@ -3,11 +3,11 @@ import type React from "react"
|
||||
|
||||
export interface ProductModalProps {
|
||||
open: boolean
|
||||
onClose: () => void
|
||||
onSave: (productData: ProductData, imageFile?: File | null) => void;
|
||||
productData: ProductData
|
||||
categories: Category[]
|
||||
editing: boolean
|
||||
onClose: () => void
|
||||
onSave: (productData: ProductData, imageFile?: File | null) => void;
|
||||
handleChange: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void
|
||||
handleTieredPricingChange: (e: React.ChangeEvent<HTMLInputElement>, index: number) => void
|
||||
handleAddTier: () => void
|
||||
|
||||
Reference in New Issue
Block a user