"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[676],{2170:(e,t,s)=>{s.d(t,{_m:()=>a,cb:()=>l,sx:()=>i,yB:()=>n});let r={ADMIN:["view_dashboard","view_staff","create_staff","edit_staff","delete_staff","view_tools","view_records","view_all_records","manage_system"],MODERATOR:["view_dashboard","view_staff","create_staff","edit_staff","view_tools","create_tools","edit_tools","view_records","create_records","edit_records","return_tools","view_all_records"],STAFF:["view_dashboard","view_records"]};function a(e,t){return!!e&&(r[e.user_data.role]||[]).includes(t)}function i(e,t){return!!e&&t.some(t=>a(e,t))}function n(e,t){switch(t){case"dashboard":return a(e,"view_dashboard");case"staff":return a(e,"view_staff");case"tools":return a(e,"view_tools");case"records":return a(e,"view_records");default:return!1}}function l(e){switch(e){case"ADMIN":return"Administrator";case"MODERATOR":return"Moderator";case"STAFF":return"Xodim";default:return e}}},2521:(e,t,s)=>{s.d(t,{q:()=>i});var r=s(3464);let a="https://e-toolsback.lservice.uz/api",i=()=>{let e=r.A.create({baseURL:a});return e.interceptors.response.use(e=>e,e=>{var t,s,r,a,i;let n=null==e?void 0:null===(t=e.response)||void 0===t?void 0:t.status,l=(null==e?void 0:null===(i=e.response)||void 0===i?void 0:null===(a=i.data)||void 0===a?void 0:null===(r=a.message)||void 0===r?void 0:null===(s=r.toLowerCase)||void 0===s?void 0:s.call(r))||"";return(401===n||l.includes("token")||l.includes("unauthorized")||l.includes("auth")||l.includes("expired"))&&window.dispatchEvent(new Event("sessionExpired")),Promise.reject(e)}),{request:async t=>{let{method:s="GET",url:r,data:i,params:n,headers:l,url_target:o,responseType:d}=t;try{return await e({method:s,url:"blank"===o?"".concat(r):"".concat(a).concat(r),data:i,params:n,headers:{...l,"ngrok-skip-browser-warning":"any"},responseType:d}).then(e=>(null==n?void 0:n.no_page)?{count:e.data.length,next:null,previous:null,results:e.data}:e.data).catch(e=>{var t,s;let r=null==e?void 0:null===(s=e.response)||void 0===s?void 0:null===(t=s.data)||void 0===t?void 0:t.message;throw Error(r)})}catch(e){throw Error(e)}}}}},3999:(e,t,s)=>{s.d(t,{cn:()=>i});var r=s(2596),a=s(9688);function i(){for(var e=arguments.length,t=Array(e),s=0;s{s.d(t,{e:()=>j});var r=s(5155),a=s(2115),i=s(7168),n=s(2713),l=s(5273),o=s(7580),d=s(8313),c=s(4783),u=s(4416),v=s(4835),h=s(1007),x=s(6052),f=s(2170),m=s(6874),g=s.n(m),p=s(5695),b=s(9458),w=s(2842);function j(e){var t,s,m,j,y,N,_,k;let{children:A}=e,[z,T,C]=(0,w.lT)(),{user:E}=(0,x.A)(),q=(0,p.usePathname)(),[S,B]=(0,a.useState)(!1),[P,$]=(0,a.useState)(!1),[F,O]=(0,a.useState)(!1),{mutate:D}=(0,b.Ub)(),K=[{id:"dashboard",label:"Boshqaruv Paneli",icon:n.A,section:"dashboard",href:"/"},{id:"records",label:(null==E?void 0:null===(t=E.user_data)||void 0===t?void 0:t.role)==="STAFF"?"Mening Yozuvlarim":"Olish Yozuvlari",icon:l.A,section:"records",href:"/records"},{id:"staff",label:"Xodimlar Boshqaruvi",icon:o.A,section:"staff",href:"/staff"},{id:"tools",label:"Uskunalar Boshqaruvi",icon:d.A,section:"tools",href:"/tools"}],M=()=>{D(void 0,{onSuccess:()=>{C("user",{path:"/"})}})},R=K.filter(e=>(0,f.yB)(E,e.section));return E?(0,r.jsxs)("div",{className:"min-h-screen bg-slate-50 flex",children:[S&&(0,r.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-40 lg:hidden animate-fade-in",onClick:()=>B(!1)}),(0,r.jsx)("aside",{className:"\n fixed lg:static inset-y-0 left-0 z-50 bg-slate-900 text-white transform transition-all duration-300 ease-in-out\n ".concat(S?"translate-x-0":"-translate-x-full lg:translate-x-0","\n ").concat(P?"lg:w-16":"lg:w-64","\n w-64\n "),children:(0,r.jsxs)("div",{className:"flex flex-col h-full",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-slate-700",children:[(0,r.jsxs)("div",{className:"flex items-center space-x-3 transition-opacity duration-300 ".concat(P?"lg:opacity-0 lg:w-0 lg:overflow-hidden":"opacity-100"),children:[(0,r.jsx)("div",{className:"w-8 h-8 bg-orange-500 rounded-lg flex items-center justify-center",children:(0,r.jsx)(d.A,{className:"w-5 h-5 text-white"})}),(0,r.jsx)("h1",{className:"text-lg font-bold whitespace-nowrap",children:"E-Tools"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(i.$,{variant:"ghost",size:"sm",className:"hidden lg:flex text-white hover:bg-slate-800 p-1",onClick:()=>$(!P),children:(0,r.jsx)(c.A,{className:"w-4 h-4"})}),(0,r.jsx)(i.$,{variant:"ghost",size:"sm",className:"lg:hidden text-white hover:bg-slate-800",onClick:()=>B(!1),children:(0,r.jsx)(u.A,{className:"w-4 h-4"})})]})]}),(0,r.jsx)("div",{className:"p-4 border-b border-slate-700 transition-all duration-300 ".concat(P?"lg:opacity-0 lg:h-0 lg:p-0 lg:overflow-hidden":"opacity-100"),children:(0,r.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,r.jsx)("div",{className:"w-10 h-10 bg-slate-700 rounded-lg flex items-center justify-center",children:(0,r.jsx)("span",{className:"text-sm font-medium",children:null===(m=E.user_data.profile)||void 0===m?void 0:null===(s=m.department)||void 0===s?void 0:s.charAt(0)})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-white truncate",children:null===(j=E.user_data.profile)||void 0===j?void 0:j.department}),(0,r.jsx)("p",{className:"text-xs text-slate-400",children:(0,f.cb)(E.user_data.role)})]})]})}),(0,r.jsx)("nav",{className:"flex-1 p-4",children:(0,r.jsx)("ul",{className:"space-y-2",children:R.map(e=>{let t=e.icon,s=q===e.href;return(0,r.jsx)("li",{children:(0,r.jsx)(g(),{href:e.href,children:(0,r.jsxs)(i.$,{variant:"ghost",className:"w-full transition-all duration-200 ".concat(P?"lg:justify-center lg:px-2":"justify-start"," ").concat(s?"bg-orange-500 text-white hover:bg-orange-600":"text-slate-300 hover:text-white hover:bg-slate-800"),onClick:()=>B(!1),title:P?e.label:void 0,children:[(0,r.jsx)(t,{className:"w-4 h-4 mr-3 lg:mr-0"}),(0,r.jsx)("span",{className:"transition-all duration-300 ".concat(P?"lg:hidden":"lg:inline lg:ml-3"),children:e.label})]})})},e.id)})})}),(0,r.jsx)("div",{className:"p-4 border-t border-slate-700",children:(0,r.jsxs)(i.$,{variant:"ghost",className:"w-full transition-all duration-200 text-slate-300 hover:text-white hover:bg-slate-800 ".concat(P?"lg:justify-center lg:px-2":"justify-start"),onClick:M,title:P?"Logout":void 0,children:[(0,r.jsx)(v.A,{className:"w-4 h-4 mr-3 lg:mr-0"}),(0,r.jsx)("span",{className:"transition-all duration-300 ".concat(P?"lg:hidden":"lg:inline lg:ml-3"),children:"Chiqish"})]})})]})}),(0,r.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[(0,r.jsx)("header",{className:"bg-white shadow-sm border-b",children:(0,r.jsxs)("div",{className:"flex items-center justify-between p-4 lg:px-6 lg:py-4",children:[(0,r.jsx)(i.$,{variant:"ghost",size:"sm",className:"lg:hidden",onClick:()=>B(!0),children:(0,r.jsx)(c.A,{className:"w-5 h-5"})}),(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)("div",{className:"flex items-center",children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)(i.$,{variant:"ghost",size:"sm",className:"flex items-center space-x-2 text-slate-700 hover:text-slate-900 hover:bg-slate-100 px-3 py-2 rounded-lg transition-all duration-200",onClick:()=>O(!F),children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:null===(y=E.user_data.profile)||void 0===y?void 0:y.fio}),(0,r.jsx)("div",{className:"w-8 h-8 bg-slate-200 rounded-full flex items-center justify-center",children:(0,r.jsx)("span",{className:"text-sm font-medium text-slate-700",children:null===(_=E.user_data.profile)||void 0===_?void 0:null===(N=_.fio)||void 0===N?void 0:N.charAt(0)})})]}),F&&(0,r.jsxs)("div",{className:"absolute right-0 mt-2 w-48 bg-white rounded-lg shadow-lg border z-50 animate-dropdown-in",children:[(0,r.jsxs)("div",{className:"p-3 border-b border-slate-100",children:[(0,r.jsx)("p",{className:"font-medium text-slate-900",children:null===(k=E.user_data.profile)||void 0===k?void 0:k.fio}),(0,r.jsx)("p",{className:"text-sm text-slate-500",children:(0,f.cb)(E.user_data.role).toLowerCase()})]}),(0,r.jsxs)("div",{className:"py-1",children:[(0,r.jsxs)(i.$,{variant:"ghost",size:"sm",className:"w-full justify-start px-3 py-2 text-slate-700 hover:bg-slate-50 transition-colors duration-150",children:[(0,r.jsx)(h.A,{className:"w-4 h-4 mr-3"}),"Profil"]}),(0,r.jsxs)(i.$,{variant:"ghost",size:"sm",className:"w-full justify-start px-3 py-2 text-red-600 hover:bg-red-50 transition-colors duration-150",onClick:()=>{O(!1),M()},children:[(0,r.jsx)(v.A,{className:"w-4 h-4 mr-3"}),"Chiqish"]})]})]})]})})]})}),(0,r.jsx)("main",{className:"flex-1 p-4 lg:p-8 overflow-auto",children:A})]}),F&&(0,r.jsx)("div",{className:"fixed inset-0 z-40 animate-fade-in",onClick:()=>O(!1)})]}):(0,r.jsx)(r.Fragment,{children:A})}},6052:(e,t,s)=>{s.d(t,{A:()=>o,AuthProvider:()=>l});var r=s(5155),a=s(2115),i=s(2842);let n=(0,a.createContext)(void 0);function l(e){let{children:t}=e,[s,l,o]=(0,i.lT)(["user"]),[d,c]=(0,a.useState)(null),[u,v]=(0,a.useState)(!0);return(0,a.useEffect)(()=>{if(s.user)try{let e;e="string"==typeof s.user?JSON.parse(s.user):s.user,c(e)}catch(e){o("user",{path:"/"}),c(null)}else c(null);v(!1)},[s.user,o]),(0,r.jsx)(n.Provider,{value:{user:d,isLoading:u},children:t})}function o(){let e=(0,a.useContext)(n);if(void 0===e)throw Error("useAuth must be used within an AuthProvider");return e}},7168:(e,t,s)=>{s.d(t,{$:()=>o});var r=s(5155);s(2115);var a=s(9708),i=s(2085),n=s(3999);let l=(0,i.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function o(e){let{className:t,variant:s,size:i,asChild:o=!1,...d}=e,c=o?a.DX:"button";return(0,r.jsx)(c,{"data-slot":"button",className:(0,n.cn)(l({variant:s,size:i,className:t})),...d})}},8145:(e,t,s)=>{s.d(t,{E:()=>o});var r=s(5155);s(2115);var a=s(9708),i=s(2085),n=s(3999);let l=(0,i.F)("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function o(e){let{className:t,variant:s,asChild:i=!1,...o}=e,d=i?a.DX:"span";return(0,r.jsx)(d,{"data-slot":"badge",className:(0,n.cn)(l({variant:s}),t),...o})}},8482:(e,t,s)=>{s.d(t,{BT:()=>o,Wu:()=>d,ZB:()=>l,Zp:()=>i,aR:()=>n});var r=s(5155);s(2115);var a=s(3999);function i(e){let{className:t,...s}=e;return(0,r.jsx)("div",{"data-slot":"card",className:(0,a.cn)("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",t),...s})}function n(e){let{className:t,...s}=e;return(0,r.jsx)("div",{"data-slot":"card-header",className:(0,a.cn)("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...s})}function l(e){let{className:t,...s}=e;return(0,r.jsx)("div",{"data-slot":"card-title",className:(0,a.cn)("leading-none font-semibold",t),...s})}function o(e){let{className:t,...s}=e;return(0,r.jsx)("div",{"data-slot":"card-description",className:(0,a.cn)("text-muted-foreground text-sm",t),...s})}function d(e){let{className:t,...s}=e;return(0,r.jsx)("div",{"data-slot":"card-content",className:(0,a.cn)("px-6",t),...s})}},9458:(e,t,s)=>{s.d(t,{Tk:()=>u,Ub:()=>d,Vp:()=>v,cV:()=>c,iY:()=>h,pH:()=>o});var r=s(2521),a=s(5041),i=s(2960),n=s(2020),l=s(2842);let o=()=>{let{request:e}=(0,r.q)(),t=async t=>await e({method:"POST",url:"/user/login/",data:t});return(0,a.n)({mutationKey:["login"],mutationFn:t})},d=()=>{let[e]=(0,l.lT)(["user"]),{request:t}=(0,r.q)(),s=async()=>{var s;return await t({method:"POST",url:"/user/logout/",headers:{Authorization:"Bearer ".concat(null==e?void 0:null===(s=e.user)||void 0===s?void 0:s.access)}})};return(0,a.n)({mutationKey:["logout"],mutationFn:s})},c=(e,t)=>{let[s]=(0,l.lT)(["user"]),{request:a}=(0,r.q)(),o=async()=>{var r;return await a({url:"/user/",params:{page:e,no_page:t},headers:{Authorization:"Bearer ".concat(null==s?void 0:null===(r=s.user)||void 0===r?void 0:r.access)}})};return(0,i.I)({queryFn:o,queryKey:["users",{page:e,no_page:t}],placeholderData:n.rX})},u=()=>{let[e]=(0,l.lT)(["user"]),{request:t}=(0,r.q)(),s=async s=>await t({method:"POST",url:"/user/",data:s,headers:{Authorization:"Bearer ".concat(e.user.access)}});return(0,a.n)({mutationFn:s,mutationKey:["create-user"]})},v=()=>{let[e]=(0,l.lT)(["user"]),{request:t}=(0,r.q)(),s=async s=>await t({method:"PATCH",url:"/user/".concat(s.id,"/"),data:s,headers:{Authorization:"Bearer ".concat(e.user.access)}});return(0,a.n)({mutationFn:s,mutationKey:["edit-user"]})},h=()=>{let[e]=(0,l.lT)(["user"]),{request:t}=(0,r.q)(),s=async s=>await t({method:"DELETE",url:"/user/".concat(s,"/"),headers:{Authorization:"Bearer ".concat(e.user.access)}});return(0,a.n)({mutationFn:s,mutationKey:["delete-user"]})}}}]);