1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9635],{64168:function(e,s,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/users",function(){return t(81138)}])},81138:function(e,s,t){"use strict";t.r(s),t.d(s,{default:function(){return j}});var n=t(85893),a=t(67294),l=t(41664),i=t.n(l),r=t(11163),c=t(44389),d=t(49759),o=t(84858),x=t(35157),h=t(32474);let u=[{key:"all",label:"ÙÙ
٠کاربراÙ"},{key:"hosts",label:"Ù
ÛØ²Ø¨Ø§ÙâÙØ§"},{key:"guests",label:"Ù
ÙÙ
اÙâÙØ§"},{key:"admins",label:"ادÙ
ÛÙâÙØ§"}],m={CONFIRMED:{label:"تاÛÛØ¯ شدÙ",tone:"green"},CHECKING:{label:"در ØØ§Ù بررسÛ",tone:"yellow"},NOT_CONFIRMED:{label:"تاÛÛØ¯ ÙØ´Ø¯Ù",tone:"gray"}};function p(e){let{u:s}=e;return(0,n.jsxs)("div",{className:"flex items-center gap-x-6 flex-wrap gap-y-4",children:[(0,n.jsx)(h.Ct,{tone:s.isHost?"green":"gray",children:s.isHost?"Ù
ÛØ²Ø¨Ø§Ù":"Ù
ÙÙ
اÙ"}),"ADMIN"===s.role&&(0,n.jsx)(h.Ct,{tone:"purple",children:"ادÙ
ÛÙ"}),s.isSpecialHost&&(0,n.jsx)(h.Ct,{tone:"blue",children:"Ù
ÛØ²Ø¨Ø§Ù ÙÛÚÙ"}),!s.isActive&&(0,n.jsx)(h.Ct,{tone:"red",children:"ØºÛØ±ÙعاÙ"}),s.yellowCardsCount>0&&(0,n.jsxs)(h.Ct,{tone:"yellow",children:[(0,h.N)(s.yellowCardsCount)," کارت زرد"]})]})}function j(){let e=(0,r.useRouter)(),[s,t]=(0,a.useState)(1),[l,j]=(0,a.useState)(""),[f,N]=(0,a.useState)("all"),[y,v]=(0,a.useState)("newest"),[C,b]=(0,a.useState)(""),[w,S]=(0,a.useState)(""),[I,A]=(0,a.useState)("list"),[F,k]=(0,a.useState)(!1),[P,_]=(0,a.useState)(!1),D=new URLSearchParams({page:String(s),pageSize:"20",tab:f,sort:y,...l?{q:l}:{},...C?{verificationStatus:C}:{},...w?{isActive:w}:{}}),{data:O,isLoading:E,mutate:H}=(0,c.u)(`/api/admin/users?${D.toString()}`,e=>(0,o.Px)(e));(0,a.useEffect)(()=>{O&&(0,x.g)("users",O.items.map(e=>e.id),e.asPath)},[O,e.asPath]);let{data:R,mutate:M}=(0,c.u)("/api/admin/users/tab-counts",e=>(0,o.SC)(e));async function z(e,s){await (0,o.SC)(`/api/admin/users/${e}`,{method:"PATCH",body:JSON.stringify(s)}),H(),M()}return(0,n.jsxs)(d.Z,{title:"Ù
Ø¯ÛØ±Ûت کاربراÙ",breadcrumb:(0,n.jsx)(i(),{href:"/admin",children:"Ø¯Ø§Ø´Ø¨ÙØ±Ø¯"}),actions:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(h.zx,{onClick:()=>k(!0),children:[(0,n.jsx)("i",{className:"icon-Plus text-16"})," Ø§ÛØ¬Ø§Ø¯ کاربر Ø¬Ø¯ÛØ¯"]}),(0,n.jsx)(h.Qm,{tabs:u,value:f,counts:R,onChange:function(e){N(e),t(1)}})]}),toolbar:(0,n.jsxs)(h.o8,{children:[(0,n.jsxs)("div",{className:"flex items-center gap-x-8 flex-1 min-w-[240px]",children:[(0,n.jsx)(h.Hf,{value:l,onChange:e=>{j(e),t(1)},placeholder:"ÙØ§Ù
Ø Ù
ÙØ¨Ø§ÛÙØ اÛÙ
ÛÙ ÛØ§ کد Ù
ÙÛ..."}),(0,n.jsx)(h.hA,{icon:"icon-Filters",label:"ÙÛÙØªØ±Ùا",active:P||!!C||!!w,onClick:()=>_(e=>!e)}),(0,n.jsx)(h.hA,{icon:"icon-Rows-Sorting",label:"گرÙÙ Ø¨ÙØ¯Û"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-x-8",children:[(0,n.jsx)(h.rP,{icon:"icon-Refresh",label:"Ø¨Ø§Ø±Ú¯Ø°Ø§Ø±Û Ù
جدد",onClick:()=>H()}),O&&(0,n.jsx)(h.p0,{page:s,pageSize:20,total:O.meta.total,pageCount:O.meta.pageCount,onPage:t}),(0,n.jsx)(h.r_,{value:I,onChange:A})]})]}),children:[(0,n.jsxs)("div",{className:"flex flex-col gap-y-16",children:[P&&(0,n.jsxs)(h.Zb,{className:"p-16 flex items-end gap-x-12 gap-y-12 flex-wrap",children:[(0,n.jsx)(h.gN,{label:"Ø§ØØ±Ø§Ø² ÙÙÛØª",children:(0,n.jsxs)(h.Ph,{value:C,onChange:e=>{b(e.target.value),t(1)},children:[(0,n.jsx)("option",{value:"",children:"ÙÙ
Ù"}),(0,n.jsx)("option",{value:"CONFIRMED",children:"تاÛÛØ¯ شدÙ"}),(0,n.jsx)("option",{value:"CHECKING",children:"در ØØ§Ù بررسÛ"}),(0,n.jsx)("option",{value:"NOT_CONFIRMED",children:"تاÛÛØ¯ ÙØ´Ø¯Ù"})]})}),(0,n.jsx)(h.gN,{label:"ÙØ¶Ø¹Ûت",children:(0,n.jsxs)(h.Ph,{value:w,onChange:e=>{S(e.target.value),t(1)},children:[(0,n.jsx)("option",{value:"",children:"ÙÙ
Ù"}),(0,n.jsx)("option",{value:"true",children:"ÙØ¹Ø§Ù"}),(0,n.jsx)("option",{value:"false",children:"ØºÛØ±ÙعاÙ"})]})}),(0,n.jsx)(h.gN,{label:"Ù
Ø±ØªØ¨âØ³Ø§Ø²Û",children:(0,n.jsxs)(h.Ph,{value:y,onChange:e=>v(e.target.value),children:[(0,n.jsx)("option",{value:"newest",children:"Ø¬Ø¯ÛØ¯ØªØ±ÛÙ"}),(0,n.jsx)("option",{value:"oldest",children:"ÙØ¯ÛÙ
ÛâØªØ±ÛÙ"}),(0,n.jsx)("option",{value:"reservations",children:"Ø¨ÛØ´ØªØ±Û٠رزرÙ"}),(0,n.jsx)("option",{value:"name",children:"ÙØ§Ù
"})]})}),(C||w)&&(0,n.jsx)(h.zx,{variant:"ghost",onClick:()=>{b(""),S(""),t(1)},children:"ØØ°Ù ÙÛÙØªØ±Ùا"})]}),E&&(0,n.jsx)("div",{className:"grid gap-12",children:Array.from({length:6}).map((e,s)=>(0,n.jsx)(h.Od,{className:"h-[64px]"},s))}),O&&0===O.items.length&&(0,n.jsx)(h.Zb,{children:(0,n.jsx)(h.ub,{text:"Ú©Ø§Ø±Ø¨Ø±Û Ø¨Ø§ اÛÙ ÙÛÙØªØ±Ùا Ù¾ÛØ¯Ø§ ÙØ´Ø¯"})}),O&&O.items.length>0&&"list"===I&&(0,n.jsx)(h.Zb,{className:"overflow-x-auto",children:(0,n.jsxs)("table",{className:"w-full text-right border-collapse",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{className:"bg-gray-F5F5F7 text-12 leading-18 text-gray-6C6A7D",children:[(0,n.jsx)("th",{className:"px-16 py-12 font-m w-40",children:"ردÛÙ"}),(0,n.jsx)("th",{className:"px-16 py-12 font-m",children:"کاربر"}),(0,n.jsx)("th",{className:"px-16 py-12 font-m",children:"Ø´Ù
ار٠تÙ
اس"}),(0,n.jsx)("th",{className:"px-16 py-12 font-m",children:"رزرÙÙØ§"}),(0,n.jsx)("th",{className:"px-16 py-12 font-m",children:"آخرÛ٠رزرÙ"}),(0,n.jsx)("th",{className:"px-16 py-12 font-m",children:"عضÙÛØª"}),(0,n.jsx)("th",{className:"px-16 py-12 font-m",children:"Ø§ØØ±Ø§Ø² ÙÙÛØª"}),(0,n.jsx)("th",{className:"px-16 py-12 font-m",children:"Ù
اÙÛØª"}),(0,n.jsx)("th",{className:"px-16 py-12 font-m",children:"ÙØ¹Ø§Ù"}),(0,n.jsx)("th",{className:"px-16 py-12 font-m"})]})}),(0,n.jsx)("tbody",{className:"divide-y divide-gray-F0F0F0",children:O.items.map((e,t)=>{var a;return(0,n.jsxs)("tr",{className:"hover:bg-gray-F5F5F7 transition",children:[(0,n.jsx)("td",{className:"px-16 py-12 text-13 text-gray-6C6A7D",children:(0,h.N)((s-1)*20+t+1)}),(0,n.jsx)("td",{className:"px-16 py-12",children:(0,n.jsxs)(i(),{href:`/admin/users/${e.id}`,className:"flex items-center gap-x-10",children:[(0,n.jsx)("span",{className:"w-32 h-32 rounded-full bg-gray-F0F0F0 flex items-center justify-center text-12 shrink-0",children:(null===(a=e.name)||void 0===a?void 0:a[0])??"Ø"}),(0,n.jsx)("span",{className:"text-14 leading-20 text-black",children:e.name??"بدÙÙ ÙØ§Ù
"})]})}),(0,n.jsx)("td",{className:"px-16 py-12 text-14 text-gray-6C6A7D",children:e.phone}),(0,n.jsx)("td",{className:"px-16 py-12 text-14",children:(0,h.N)(e.reservationsCount)}),(0,n.jsx)("td",{className:"px-16 py-12 text-14 text-gray-6C6A7D",children:(0,h.IY)(e.lastReservationAt)}),(0,n.jsx)("td",{className:"px-16 py-12 text-14 text-gray-6C6A7D",children:(0,h.IY)(e.createdAt)}),(0,n.jsx)("td",{className:"px-16 py-12",children:(0,n.jsx)(h.Ct,{tone:m[e.verificationStatus].tone,children:m[e.verificationStatus].label})}),(0,n.jsx)("td",{className:"px-16 py-12",children:(0,n.jsx)(p,{u:e})}),(0,n.jsx)("td",{className:"px-16 py-12",children:(0,n.jsx)(h.ZD,{checked:e.isActive,onChange:s=>
1z(e.id,{isActive:s})})}),(0,n.jsx)("td",{className:"px-16 py-12",children:(0,n.jsx)(i(),{href:`/admin/users/${e.id}`,className:"text-14 font-m text-primary-dark whitespace-nowrap",children:"Ù
Ø´Ø§ÙØ¯Ù Ø¬Ø²Ø¦ÛØ§Øª â"})})]},e.id)})})]})}),O&&O.items.length>0&&"cards"===I&&(0,n.jsx)("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-16",children:O.items.map(e=>{var s;return(0,n.jsxs)(h.Zb,{className:"p-16 flex flex-col items-center text-center gap-y-10",children:[(0,n.jsx)("span",{className:"w-64 h-64 rounded-full bg-gray-F0F0F0 flex items-center justify-center text-20",children:(null===(s=e.name)||void 0===s?void 0:s[0])??"Ø"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-14 leading-20 font-m text-black",children:e.name??"بدÙÙ ÙØ§Ù
"}),(0,n.jsx)("p",{className:"text-12 leading-18 text-gray-6C6A7D",children:e.phone})]}),(0,n.jsx)(p,{u:e}),(0,n.jsxs)("p",{className:"text-12 leading-18 text-gray-6C6A7D",children:[(0,h.N)(e.reservationsCount)," رزر٠\xb7 عضÙÛØª ",(0,h.IY)(e.createdAt)]}),(0,n.jsx)(i(),{href:`/admin/users/${e.id}`,className:"w-full mt-auto",children:(0,n.jsx)(h.zx,{variant:"secondary",className:"w-full",children:"Ù
Ø´Ø§ÙØ¯Ù Ø¬Ø²Ø¦ÛØ§Øª"})})]},e.id)})})]}),(0,n.jsx)(g,{open:F,onClose:()=>k(!1),onCreated:()=>{k(!1),H(),M()}})]})}function g(e){let{open:s,onClose:t,onCreated:l}=e,[i,r]=(0,a.useState)({name:"",phone:"",contactPhone:"",nationalCode:"",email:"",address:"",password:"",isHost:!1}),[c,d]=(0,a.useState)(null),[x,u]=(0,a.useState)(!1),m=e=>s=>r(t=>({...t,[e]:s.target.value}));async function p(e){e.preventDefault(),d(null),u(!0);try{await (0,o.SC)("/api/admin/users",{method:"POST",body:JSON.stringify(Object.fromEntries(Object.entries(i).filter(e=>{let[,s]=e;return""!==s&&!1!==s})))}),l(),r({name:"",phone:"",contactPhone:"",nationalCode:"",email:"",address:"",password:"",isHost:!1})}catch(e){d(e instanceof Error?e.message:"خطا در Ø§ÛØ¬Ø§Ø¯ کاربر")}finally{u(!1)}}return(0,n.jsx)(h.u_,{open:s,onClose:t,title:"Ø§ÛØ¬Ø§Ø¯ کاربر Ø¬Ø¯ÛØ¯",children:(0,n.jsxs)("form",{onSubmit:p,className:"grid md:grid-cols-2 gap-12",children:[(0,n.jsx)(h.gN,{label:"ÙØ§Ù
Ù ÙØ§Ù
خاÙÙØ§Ø¯Ú¯Û",children:(0,n.jsx)(h.II,{value:i.name,onChange:m("name")})}),(0,n.jsx)(h.gN,{label:"Ø´Ù
ار٠Ù
ÙØ¨Ø§ÛÙ *",children:(0,n.jsx)(h.II,{value:i.phone,onChange:m("phone"),required:!0,placeholder:"09xxxxxxxxx",inputMode:"numeric"})}),(0,n.jsx)(h.gN,{label:"Ø´Ù
ار٠تÙ
اس دÛگر",children:(0,n.jsx)(h.II,{value:i.contactPhone,onChange:m("contactPhone"),inputMode:"numeric"})}),(0,n.jsx)(h.gN,{label:"کد Ù
ÙÛ",children:(0,n.jsx)(h.II,{value:i.nationalCode,onChange:m("nationalCode"),inputMode:"numeric"})}),(0,n.jsx)(h.gN,{label:"اÛÙ
ÛÙ",children:(0,n.jsx)(h.II,{value:i.email,onChange:m("email"),type:"email"})}),(0,n.jsx)(h.gN,{label:"رÙ
ز Ø¹Ø¨ÙØ± (Ø§Ø®ØªÛØ§Ø±Û)",children:(0,n.jsx)(h.II,{value:i.password,onChange:m("password"),type:"password",placeholder:"در ØµÙØ±Øª خاÙÛ Ø¨ÙØ¯ÙØ ÙØ±Ùد با کد ÛکبارÙ
صرÙ"})}),(0,n.jsx)(h.gN,{label:"آدرس Ù
ØÙ",className:"md:col-span-2",children:(0,n.jsx)(h.II,{value:i.address,onChange:m("address")})}),(0,n.jsxs)("label",{className:"md:col-span-2 flex items-center gap-x-10 text-14 text-black",children:[(0,n.jsx)(h.ZD,{checked:i.isHost,onChange:e=>r(s=>({...s,isHost:e}))}),"کاربر Ù
ÛØ²Ø¨Ø§Ù باشد"]}),!!c&&(0,n.jsx)("p",{className:"md:col-span-2 text-13 text-[#C62828]",children:c}),(0,n.jsxs)("div",{className:"md:col-span-2 flex items-center gap-x-10 justify-end mt-4",children:[(0,n.jsx)(h.zx,{type:"button",variant:"secondary",onClick:t,children:"Ø§ÙØµØ±Ø§Ù"}),(0,n.jsx)(h.zx,{type:"submit",disabled:x,children:x?"در ØØ§Ù ثبت...":"ثبت"})]})]})})}},35157:function(e,s,t){"use strict";t.d(s,{g:function(){return l},o:function(){return i}});var n=t(67294);let a="lidoma_admin_nav:";function l(e,s,t){try{let n={ids:s,returnUrl:t,savedAt:Date.now()};window.sessionStorage.setItem(a+e,JSON.stringify(n))}catch{}}function i(e,s){let[t,l]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(null==s){l(null);return}let t=function(e){try{let s=window.sessionStorage.getItem(a+e);if(!s)return null;let t=JSON.parse(s);if(Date.now()-t.savedAt>18e5)return null;return t}catch{return null}}(e);if(!t){l(null);return}let n=t.ids.findIndex(e=>String(e)===String(s));if(-1===n){l(null);return}l({index:n,total:t.ids.length,prevId:n>0?t.ids[n-1]:null,nextId:n<t.ids.length-1?t.ids[n+1]:null,returnUrl:t.returnUrl})},[e,s]),t}}},function(e){e.O(0,[4389,9759,9774,2888,179],function(){return e(e.s=64168)}),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.