Cleanup
This commit is contained in:
109
lib/types.ts
109
lib/types.ts
@@ -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
13
lib/utils.ts
Normal 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"
|
||||
}
|
||||
Reference in New Issue
Block a user