This commit is contained in:
g
2025-02-08 01:56:42 +00:00
parent 468fd69cb5
commit 7374e56253
13 changed files with 297 additions and 411 deletions

View File

@@ -1,69 +1,82 @@
import { ChangeEvent, Dispatch, SetStateAction } from "react";
import type { LucideIcon } from "lucide-react"
import type React 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>>;
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
handleRemoveTier: (index: number) => void
setProductData: React.Dispatch<React.SetStateAction<ProductData>>
}
// lib/types.ts
export interface ShippingMethod {
_id?: string; // Optional before saving, required after fetching
name: string;
price: number;
_id?: string
name: string
price: number
}
export interface ShippingData {
_id?: string; // Optional before saving
name: string;
price: number;
_id?: string
name: string
price: number
}
export type ApiResponse<T> = {
data?: T;
error?: string;
total?: number;
};
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;
_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 ProductData extends Product {}
export interface PricingTier {
minQuantity: number;
pricePerUnit: number;
_id?: string;
minQuantity: number
pricePerUnit: number
_id?: string
}
export interface Category {
_id: string;
name: string;
_id: string
name: string
}
export interface OrderStatsData {
totalOrders: number
pendingOrders: number
completedOrders: number
cancelledOrders: number
}
export interface Order {
_id: string
orderId: string
status: OrderStatus
totalPrice: number
createdAt: string
telegramUsername?: string
}
export type OrderStatus = "paid" | "unpaid" | "confirming" | "shipped" | "completed" | "disputed" | "cancelled"
export interface StatusConfig {
icon: LucideIcon
color: string
animate?: string
}

13
lib/utils.ts Normal file
View File

@@ -0,0 +1,13 @@
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]): string {
return twMerge(clsx(inputs))
}
export const getGreeting = () => {
const hour = new Date().getHours()
if (hour < 12) return "Good morning"
if (hour < 18) return "Good afternoon"
return "Good evening"
}