This commit is contained in:
g
2025-02-08 00:54:11 +00:00
parent 30fb2aaaab
commit 468fd69cb5
5 changed files with 375 additions and 331 deletions

View File

@@ -1,3 +1,19 @@
import { ChangeEvent, Dispatch, SetStateAction } from "react";
export interface ProductModalProps {
open: boolean;
onClose: () => void;
onSave: (productData: ProductData) => void;
productData: ProductData;
categories: Category[];
editing: boolean;
handleChange: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
handleTieredPricingChange: (e: React.ChangeEvent<HTMLInputElement>, index: number) => void;
handleAddTier: () => void; // ✅ ADDED
handleRemoveTier: (index: number) => void; // ✅ ADDED
setProductData: React.Dispatch<React.SetStateAction<ProductData>>;
}
// lib/types.ts
export interface ShippingMethod {
_id?: string; // Optional before saving, required after fetching
@@ -11,19 +27,43 @@ export interface ShippingData {
price: number;
}
export interface Product {
_id?: string;
name: string;
price: number;
description?: string;
sku?: string;
stock: number;
createdAt?: Date;
updatedAt?: Date;
}
export type ApiResponse<T> = {
data?: T;
error?: string;
total?: number;
};
};
export interface Product {
_id?: string;
name: string;
description: string;
stock?: number;
unitType: string;
category: string;
pricing: PricingTier[];
image?: string | File | null;
}
export interface ProductData {
_id?: string;
name: string;
description: string;
stock?: number;
unitType: string;
category: string;
pricing: PricingTier[];
image?: string | File | null;
}
export interface PricingTier {
minQuantity: number;
pricePerUnit: number;
_id?: string;
}
export interface Category {
_id: string;
name: string;
}