import React, { useState, useEffect } from 'react'; import { Zap, LayoutDashboard, Package, Users, FileText, Plus, Trash2, Search, Download, Printer, ChevronLeft, PlusCircle, ShoppingCart, UserPlus, CheckCircle } from 'lucide-react'; const App = () => { // --- State Management --- const [activeSection, setActiveSection] = useState('dash'); const [inventory, setInventory] = useState([ { id: 1, name: "פרוז'קטור 50W", cat: 'תאורת חוץ', price: 280, qty: 15 }, { id: 2, name: 'ספוט לד שקוע', cat: 'תאורת פנים', price: 45, qty: 120 } ]); const [clients, setClients] = useState([ { id: 1, name: 'ישראל ישראלי', phone: '050-1234567', email: 'israel@example.com' } ]); const [quotes, setQuotes] = useState([]); // State for forms const [newProduct, setNewProduct] = useState({ name: '', cat: '', price: '', qty: '' }); const [newClient, setNewClient] = useState({ name: '', phone: '', email: '' }); const [newQuote, setNewQuote] = useState({ clientId: '', items: [], discount: 0 }); // --- Logic Functions --- const addProduct = () => { if (!newProduct.name || !newProduct.price) return; setInventory([...inventory, { ...newProduct, id: Date.now(), price: Number(newProduct.price), qty: Number(newProduct.qty) }]); setNewProduct({ name: '', cat: '', price: '', qty: '' }); }; const addClient = () => { if (!newClient.name || !newClient.phone) return; setClients([...clients, { ...newClient, id: Date.now() }]); setNewClient({ name: '', phone: '', email: '' }); }; const deleteItem = (id, type) => { if (type === 'inventory') setInventory(inventory.filter(item => item.id !== id)); if (type === 'clients') setClients(clients.filter(item => item.id !== id)); }; const createQuote = () => { if (!newQuote.clientId || newQuote.items.length === 0) return; const client = clients.find(c => c.id === Number(newQuote.clientId)); const subtotal = newQuote.items.reduce((sum, item) => sum + (item.price * item.quantity), 0); const total = subtotal * 1.17; // מע"מ const quoteData = { ...newQuote, id: `INV-${Date.now()}`, clientName: client.name, subtotal, total, date: new Date().toLocaleDateString('he-IL') }; setQuotes([quoteData, ...quotes]); setNewQuote({ clientId: '', items: [], discount: 0 }); setActiveSection('quotes'); }; // --- UI Components --- const NavItem = ({ id, icon: Icon, label }) => ( ); return (
{/* Sidebar / Mobile Nav */} {/* Main Content */}
{/* DASHBOARD */} {activeSection === 'dash' && (

שלום, מאור

מה נרצה לעשות היום?

מוצרים במלאי

{inventory.length}

לקוחות רשומים

{clients.length}

הצעות מחיר

{quotes.length}

צריך להוציא הצעת מחיר?

בחר לקוח, בחר מוצרים ושלח לו וואטסאפ תוך דקה.

)} {/* INVENTORY */} {activeSection === 'inventory' && (

ניהול מלאי מוצרים

setNewProduct({...newProduct, name: e.target.value})} /> setNewProduct({...newProduct, price: e.target.value})} /> setNewProduct({...newProduct, qty: e.target.value})} />
{inventory.map(item => ( ))}
מוצר מחיר מלאי
{item.name} ₪{item.price} {item.qty} יח'
)} {/* CLIENTS */} {activeSection === 'clients' && (

ניהול לקוחות

setNewClient({...newClient, name: e.target.value})} /> setNewClient({...newClient, phone: e.target.value})} /> setNewClient({...newClient, email: e.target.value})} />
{clients.map(client => (

{client.name}

{client.phone} | {client.email}

))}
)} {/* QUOTES VIEW */} {activeSection === 'quotes' && (

היסטוריית הצעות מחיר

{quotes.length === 0 ? (

עדיין לא הופקו הצעות מחיר במערכת.

) : (
{quotes.map(quote => (
{quote.id} {quote.date}

{quote.clientName}

סה"כ לתשלום (כולל מע"מ): ₪{quote.total.toLocaleString()}

))}
)}
)} {/* CREATE QUOTE FLOW */} {activeSection === 'createQuote' && (

הפקת הצעה חדשה

{/* Left Column: Form */}
{inventory.map(item => ( ))}
{newQuote.items.length > 0 && (
{newQuote.items.map(item => ( ))}
פריט כמות סה"כ
{item.name} { setNewQuote({ ...newQuote, items: newQuote.items.map(i => i.id === item.id ? {...i, quantity: Number(e.target.value)} : i) }); }} /> ₪{item.price * item.quantity}
)}
{/* Right Column: Summary */}

סיכום הצעה

סה"כ מוצרים: ₪{newQuote.items.reduce((sum, item) => sum + (item.price * item.quantity), 0).toLocaleString()}
מע"מ (17%): ₪{(newQuote.items.reduce((sum, item) => sum + (item.price * item.quantity), 0) * 0.17).toLocaleString()}
סה"כ: ₪{(newQuote.items.reduce((sum, item) => sum + (item.price * item.quantity), 0) * 1.17).toLocaleString()}
)}
); }; export default App;