PageSourceSearch

https://lidomatrip.com/_next/static/chunks/pages/admin/users-29e9952047bdb401.js

js lidomatrip.com collected 2026-10-02 20:26:47 UTC 11,699 bytes, 1 lines download raw bytes

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.