function EmployeesPage({ employees, setEmployees, lang }){ const t = STR[lang]; const te = t.employees; const f = nd(lang); const [form, setForm] = useState({ fullName:"", position:"", phone:"", notes:"" }); const [confirmId, setConfirmId] = useState(null); const addEmployee = () => { if(!form.fullName.trim()){ alert(te.needName); return; } setEmployees([...employees, { ...form, id:"emp"+Date.now() }]); setForm({ fullName:"", position:"", phone:"", notes:"" }); }; const removeEmployee = (id) => { setEmployees(employees.filter(e=>e.id!==id)); setConfirmId(null); }; return (
{te.sub}
{te.emptySub}
| {te.colName} | {te.colPosition} | {te.colPhone} | {te.colNotes} | |
|---|---|---|---|---|
| {e.fullName} | {e.position || "—"} | {f(e.phone || "—")} | {e.notes || "—"} |
{confirmId===e.id ? (
|
{categorySub}
{tx.emptySub}
| {tx.colTitle} | {tx.colDate} | {tx.colNotes} | {tx.colAmount} | |
|---|---|---|---|---|
| {it.title} | {f(it.date || "—")} | {it.notes || "—"} | {f(fmtMoney(it.amount))} {tx.currency} |
{isDari?"اطلاعات بهطور خودکار در Firebase (Google) ذخیره و همگامسازی میشوند.\nهمه کاربران به یک پایگاه داده مشترک وصل هستند.":"Data is saved and synced automatically with Firebase (Google).\nAll users share the same cloud database."}
{ts.sub}
{pwMsg}
}| {ts.colFullName} | {isDari?"ایمیل":"Email"} | {ts.colRole} | |
|---|---|---|---|
| {u.fullName} | {u.username} | {ts.roles[u.role] || u.role} |
{isDari ? "کاربر را با ایمیل او تایید کنید. او میتواند بعداً با همین ایمیل، حساب خودش را از صفحه ورود بسازد و رمز عبور خودش را انتخاب کند." : "Approve the user by their email. They can then create their own account with that email from the sign-in screen and choose their own password."}
{userMsg}
}{isDari?"دادهها در فضای ابری Firebase ذخیره میشوند. برای جلوگیری از از دست دادن اطلاعات، به طور منظم بکاپ بگیرید.":"Data is stored in the cloud (Firebase). Export regularly to prevent data loss."}
{/* Export */}{isDari?"یک فایل JSON از تمام دادههای شما دانلود میشود":"Downloads a JSON file with all your data"}
⚠️ {isDari?"این عمل دادههای فعلی را جایگزین میکند":"This will replace all current data"}
{ const file = e.target.files[0]; if(!file) return; const reader = new FileReader(); reader.onload = (ev)=>{ try{ const parsed = JSON.parse(ev.target.result); if(!parsed.customers){ alert(isDari?"فایل نامعتبر است":"Invalid backup file"); return; } FBStore.restore(ev.target.result).then(()=>{ alert(isDari?"بازیابی موفق بود. صفحه بارگذاری مجدد میشود.":"Restore successful. Page will reload."); window.location.reload(); }).catch((e2)=>{ alert((isDari?"خطا در بازیابی: ":"Restore failed: ")+((e2&&e2.message)||e2)); }); }catch(err){ alert(isDari?"خطا در خواندن فایل":"Error reading file"); } }; reader.readAsText(file); e.target.value = ""; }}/>{isDari?"بازنشانی سیستم تمام دادههای ذخیره شده را حذف میکند. این کار قابل بازگشت نیست — قبل از انجام آن حتماً بکاپ بگیرید.":"Resetting the system deletes all saved data. This cannot be undone — export a backup first."}