Files
alrahma_sunday_school_api/apps/admin/.next/static/chunks/0wwp54sprh-2v.js
T
2026-06-11 03:22:12 -04:00

1 line
5.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,6655,e=>{"use strict";let t=e.i(47167).default.env.NEXT_PUBLIC_API_URL??"/admin/api/v1";e.s(["ADMIN_API_BASE",0,t])},63031,e=>{"use strict";var t=e.i(43476),a=e.i(71645),s=e.i(51224),l=e.i(6655);e.s(["default",0,function(){let{language:e,dict:i}=(0,s.useAdminI18n)(),c={en:{title:"Renters",search:"Search renters…",name:"Name",email:"Email",phone:"Phone",status:"Status",joined:"Joined",loading:"Loading…",empty:"No renters found",blocked:"Blocked",active:"Active",unblock:"Unblock",block:"Block"},fr:{title:"Locataires",search:"Rechercher des locataires…",name:"Nom",email:"E-mail",phone:"Téléphone",status:"Statut",joined:"Date dinscription",loading:"Chargement…",empty:"Aucun locataire trouvé",blocked:"Bloqué",active:"Actif",unblock:"Débloquer",block:"Bloquer"},ar:{title:"المستأجرون",search:"ابحث عن مستأجرين…",name:"الاسم",email:"البريد الإلكتروني",phone:"الهاتف",status:"الحالة",joined:"تاريخ التسجيل",loading:"جارٍ التحميل…",empty:"لم يتم العثور على مستأجرين",blocked:"محظور",active:"نشط",unblock:"فك الحظر",block:"حظر"}}[e],[n,r]=(0,a.useState)([]),[d,o]=(0,a.useState)([]),[x,m]=(0,a.useState)(""),[p,u]=(0,a.useState)(!0),[h,f]=(0,a.useState)(null),[b,j]=(0,a.useState)(null);async function N(){try{let e=await fetch(`${l.ADMIN_API_BASE}/admin/renters`,{cache:"no-store",credentials:"include"}),t=await e.json();if(!e.ok)throw Error(t?.message??"Failed");let a=Array.isArray(t.data)?t.data:t.data?.data??[];r(a),o(a)}catch(e){f(e.message)}finally{u(!1)}}async function y(e,t){j(e);try{if(!(await fetch(`${l.ADMIN_API_BASE}/admin/renters/${e}/${t?"unblock":"block"}`,{method:"POST",credentials:"include"})).ok)throw Error("Action failed");await N()}catch(e){f(e.message)}finally{j(null)}}return(0,a.useEffect)(()=>{N()},[]),(0,a.useEffect)(()=>{let e=x.toLowerCase();o(n.filter(t=>`${t.firstName} ${t.lastName}`.toLowerCase().includes(e)||t.email.toLowerCase().includes(e)))},[x,n]),(0,t.jsxs)("div",{className:"shell py-8 space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs uppercase tracking-[0.2em] text-emerald-400",children:i.platform}),(0,t.jsx)("h1",{className:"mt-1 text-3xl font-black",children:c.title})]}),(0,t.jsx)("input",{className:"w-64 px-3 py-2 rounded-xl bg-zinc-800 border border-zinc-700 text-zinc-100 text-sm placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-emerald-500",placeholder:c.search,value:x,onChange:e=>m(e.target.value)})]}),h&&(0,t.jsx)("div",{className:"panel p-4 text-sm text-red-400",children:h}),(0,t.jsx)("div",{className:"panel overflow-hidden",children:(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-sm",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"border-b border-zinc-800",children:[(0,t.jsx)("th",{className:"text-left px-6 py-3 text-xs font-medium text-zinc-500 uppercase tracking-wider",children:c.name}),(0,t.jsx)("th",{className:"text-left px-6 py-3 text-xs font-medium text-zinc-500 uppercase tracking-wider",children:c.email}),(0,t.jsx)("th",{className:"text-left px-6 py-3 text-xs font-medium text-zinc-500 uppercase tracking-wider",children:c.phone}),(0,t.jsx)("th",{className:"text-left px-6 py-3 text-xs font-medium text-zinc-500 uppercase tracking-wider",children:c.status}),(0,t.jsx)("th",{className:"text-left px-6 py-3 text-xs font-medium text-zinc-500 uppercase tracking-wider",children:c.joined}),(0,t.jsx)("th",{className:"px-6 py-3"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-zinc-800/60",children:p?(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:6,className:"px-6 py-12 text-center text-zinc-500",children:c.loading})}):0===d.length?(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:6,className:"px-6 py-12 text-center text-zinc-500",children:c.empty})}):d.map(e=>(0,t.jsxs)("tr",{className:"hover:bg-zinc-800/30 transition-colors",children:[(0,t.jsxs)("td",{className:"px-6 py-4 font-medium text-zinc-100",children:[e.firstName," ",e.lastName]}),(0,t.jsx)("td",{className:"px-6 py-4 text-zinc-400",children:e.email}),(0,t.jsx)("td",{className:"px-6 py-4 text-zinc-400",children:e.phone??"—"}),(0,t.jsx)("td",{className:"px-6 py-4",children:(0,t.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${e.isBlocked?"text-red-400 bg-red-950/40":"text-emerald-400 bg-emerald-950/40"}`,children:e.isBlocked?c.blocked:c.active})}),(0,t.jsx)("td",{className:"px-6 py-4 text-zinc-500 text-xs",children:new Date(e.createdAt).toLocaleDateString()}),(0,t.jsx)("td",{className:"px-6 py-4",children:(0,t.jsx)("button",{onClick:()=>y(e.id,e.isBlocked),disabled:b===e.id,className:`px-3 py-1.5 rounded-lg text-xs font-medium transition-colors disabled:opacity-50 ${e.isBlocked?"bg-emerald-950/50 hover:bg-emerald-900/50 text-emerald-400":"bg-red-950/50 hover:bg-red-900/50 text-red-400"}`,children:e.isBlocked?c.unblock:c.block})})]},e.id))})]})})})]})}])}]);