- Backend: FastAPI app with all models, services, schemas, routes - Admin Panel: Next.js dashboard with all modules (CRM, POS, repairs, warranties, billing, notifications, etc.) - Ecommerce: storefront (submodule) + product catalog - AI Agents: .agents/ skill library for Antigravity IDE - Docs: architecture, billing, notification gateway markdown - Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
78 lines
3.8 KiB
TypeScript
78 lines
3.8 KiB
TypeScript
import React, { useState } from 'react';
|
|
import { X, Plus, Trash2 } from 'lucide-react';
|
|
|
|
interface PartNumbersModalProps {
|
|
open: boolean;
|
|
onClose: () => void;
|
|
onSubmit: (partNumbers: string[]) => void;
|
|
title?: string;
|
|
}
|
|
|
|
export function PartNumbersModal({ open, onClose, onSubmit, title = "Enter Replacement Part Numbers" }: PartNumbersModalProps) {
|
|
const [partNumbers, setPartNumbers] = useState<{ name: string; partNo: string }[]>([{ name: '', partNo: '' }]);
|
|
|
|
if (!open) return null;
|
|
|
|
const handleAdd = () => setPartNumbers([...partNumbers, { name: '', partNo: '' }]);
|
|
const handleRemove = (idx: number) => setPartNumbers(partNumbers.filter((_, i) => i !== idx));
|
|
const handleChange = (idx: number, field: 'name' | 'partNo', val: string) => {
|
|
const newArr = [...partNumbers];
|
|
newArr[idx][field] = val;
|
|
setPartNumbers(newArr);
|
|
};
|
|
|
|
const handleSubmit = (e: React.FormEvent) => {
|
|
e.preventDefault();
|
|
const valid = partNumbers
|
|
.filter(p => p.name.trim() || p.partNo.trim())
|
|
.map(p => `${p.name.trim() || 'Unknown'}: ${p.partNo.trim() || 'Unknown'}`);
|
|
onSubmit(valid);
|
|
};
|
|
|
|
return (
|
|
<div className="fixed inset-0 z-[100] bg-black/60 flex items-center justify-center p-4">
|
|
<div className="bg-card border border-border w-full max-w-md crm-radius-modal shadow-xl overflow-hidden flex flex-col">
|
|
<div className="flex items-center justify-between px-5 py-4 border-b border-border">
|
|
<h2 className="text-[15px] font-semibold text-foreground">{title}</h2>
|
|
<button onClick={onClose} className="w-8 h-8 rounded hover:bg-muted text-muted-foreground flex items-center justify-center">
|
|
<X className="w-4 h-4" />
|
|
</button>
|
|
</div>
|
|
<form onSubmit={handleSubmit} className="flex-1 flex flex-col min-h-0">
|
|
<div className="p-5 overflow-y-auto space-y-3 flex-1 min-h-[200px]">
|
|
{partNumbers.map((part, idx) => (
|
|
<div key={idx} className="flex items-center gap-2">
|
|
<input
|
|
type="text"
|
|
placeholder="Part Name (e.g. Screen)"
|
|
value={part.name}
|
|
onChange={e => handleChange(idx, 'name', e.target.value)}
|
|
className="flex-1 h-9 px-3 bg-card border border-border crm-radius-control text-[13px] focus:outline-none focus:border-primary"
|
|
/>
|
|
<input
|
|
type="text"
|
|
placeholder="Serial / IMEI / Part ID"
|
|
value={part.partNo}
|
|
onChange={e => handleChange(idx, 'partNo', e.target.value)}
|
|
className="flex-1 h-9 px-3 bg-card border border-border crm-radius-control text-[13px] focus:outline-none focus:border-primary"
|
|
/>
|
|
{partNumbers.length > 1 && (
|
|
<button type="button" onClick={() => handleRemove(idx)} className="h-9 w-9 flex items-center justify-center shrink-0 border border-red-200 text-red-500 hover:bg-red-50 rounded">
|
|
<Trash2 className="w-4 h-4" />
|
|
</button>
|
|
)}
|
|
</div>
|
|
))}
|
|
<button type="button" onClick={handleAdd} className="mt-2 text-[13px] text-primary font-medium hover:underline flex items-center gap-1">
|
|
<Plus className="w-3 h-3" /> Add another part
|
|
</button>
|
|
</div>
|
|
<div className="px-5 py-4 border-t border-border flex items-center justify-end gap-3 bg-muted/20">
|
|
<button type="button" onClick={onClose} className="px-4 py-2 text-[13px] font-medium text-foreground border border-border rounded hover:bg-muted">Cancel</button>
|
|
<button type="submit" className="px-4 py-2 text-[13px] font-medium text-white bg-primary rounded hover:bg-primary/90">Submit & Complete</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|