PageSourceSearch

https://samugiken.com/_next/static/chunks/pages/admin/role-c398330db1c60611.js

js samugiken.com collected 2026-10-07 01:50:56 UTC 6,998 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6913],{25422:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/role",function(){return n(66997)}])},39577:function(e,t,n){"use strict";var r=n(52676),i=n(98807),o=n(78051),a=n(92966),l=n(63309);t.Z=e=>{let{children:t,className:n,...s}=e;return(0,r.jsx)(i.Z,{trigger:["click"],rootClassName:(0,l.cn)("!min-w-[100px]",n),...s,children:t||(0,r.jsx)(o.ZP,{className:"!px-2",children:(0,r.jsx)(a.Z,{})})})}},98131:function(e,t,n){"use strict";var r=n(52676),i=n(79406),o=n(78051);t.Z=e=>{let{visible:t,onOk:n,onCancel:a,title:l,content:s,danger:c=!1,okButtonText:u,cancelButtonText:d,loading:g,disabled:p}=e;return(0,r.jsxs)(i.Z,{open:t,title:l,footer:null,closeIcon:null,centered:!0,onCancel:()=>{p||null==a||a()},children:[s,(0,r.jsxs)("div",{className:"flex gap-5 mt-5",children:[(0,r.jsx)(o.ZP,{size:"large",onClick:a,block:!0,disabled:p,children:d||"Cancel"}),(0,r.jsx)(o.ZP,{size:"large",type:"primary",danger:c,onClick:n,block:!0,loading:g,disabled:p,children:u||"Ok"})]})]})}},40361:function(e,t,n){"use strict";var r=n(52676),i=n(83995),o=n(57722);t.Z=e=>{let{status:t}=e;return t===i.J.ACTIVE?(0,r.jsx)(o.Z,{color:"green",children:"Active"}):t===i.J.INACTIVE?(0,r.jsx)(o.Z,{color:"red",children:"Inactive"}):null}},95809:function(e,t,n){"use strict";var r=n(75271);t.Z=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],[t,n]=(0,r.useState)(e);return{visible:t,open:()=>{n(!0)},close:()=>{n(!1)},toggle:()=>{n(e=>!e)}}}},56346:function(e,t,n){"use strict";var r=n(75271),i=n(94170);t.Z=e=>{let[t,n]=(0,r.useState)({page:1,pageSize:10,total:0,sortOrder:i.As.DESC,sortField:"createdAt",...e});return[t,n,(e,t,r)=>{n(t=>{var n;return{...t,page:e.current||1,pageSize:e.pageSize||10,sortField:null!==(n=null==r?void 0:r.field)&&void 0!==n?n:null==t?void 0:t.sortField,sortOrder:"ascend"==r.order?i.As.ASC:r.order?i.As.DESC:t.sortOrder}})}]}},83995:function(e,t,n){"use strict";var r,i;n.d(t,{J:function(){return r}}),(i=r||(r={})).ACTIVE="ACTIVE",i.INACTIVE="INACTIVE"},66997:function(e,t,n){"use strict";n.r(t),n.d(t,{__N_SSP:function(){return b},default:function(){return w}});var r=n(52676),i=n(98774),o=n(73414),a=n(78051),l=n(49810),s=n(26134),c=n(75271),u=n(76517),d=n(27026),g=n.n(d),p=n(69947),f=n(69834),E=n(4475),I=n(71030),v=n(77894),m=n(39577),x=n(98131),h=n(95809),C=n(56346),Z=n(83214),A=n(85304),N=n(73143),R=n(2194),S=n(34104),j=n(34769),y=n(1705),_=n(40361),O=n(83995),k=()=>{let e=(0,p.NL)(),t=(0,o.useRouter)(),{user:n}=(0,A.a)(),[i,a,l]=(0,C.Z)(),[d,k]=(0,c.useState)(null),T=(0,h.Z)(),b=(0,h.Z)(),w=(0,f.a)({queryKey:["role","pagination",i],queryFn:async()=>{let e=await (0,N.JV)({page:i.page,pageSize:i.pageSize,sortField:i.sortField,sortOrder:i.sortOrder});return a(t=>({...t,page:e.data.page,total:e.data.total})),e},placeholderData:E.Wk,select:e=>e.data.rows}),D=(0,I.D)({mutationFn:e=>(0,N.cq)(e),onSuccess:()=>{b.close(),w.refetch(),e.invalidateQueries({exact:!0,queryKey:["role","option"]})}}),P=(0,I.D)({mutationFn:N.Rd,onSuccess:()=>{T.close(),w.refetch(),e.invalidateQueries({exact:!0,queryKey:["role","option"]})}}),F=(e,t)=>{u.Am.promise(D.mutateAsync({id:e,active:t}),{pending:"Updating role status...",success:"Role status updated successfully",error:{render(e){let{data:t}=e;return"Error updating role status: ".concat((0,Z._g)(t))}}})},V=e=>{u.Am.promise(P.mutateAsync({id:e}),{pending:"Deleting role...",success:"Role deleted successfully",error:{render(e){let{data:t}=e;return"Error deleting role: ".concat((0,Z._g)(t))}}})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v.Z,{columns:[{title:"Name",dataIndex:"name",render:(e,t)=>(0,r.jsx)(g(),{href:"/admin/role/".concat(t.refId),className:"font-bold",children:e})},{title:"Status",dataIndex:"active",render:e=>(0,r.jsx)(_.Z,{status:e?O.J.ACTIVE:O.J.INACTIVE})},{title:"Created At",dataIndex:"createdAt",render:e=>(0,Z.i$)(e)},{dataIndex:"refId",width:50,render:(e,i)=>(0,r.jsx)(m.Z,{menu:{items:[{key:"view",label:"View",icon:(0,r.jsx)(R.Z,{}),onClick:()=>{t.push("/admin/role/".concat(e))}},...(0,s.f)(n.role.accessRights.ROLE.UPDATE,[...(0,s.f)(i.active,[{key:"deactivate",label:"Deactivate",icon:(0,r.jsx)(S.Z,{}),onClick:()=>{k(i),b.open()}}],[{key:"activate",label:"Activate",icon:(0,r.jsx)(j.Z,{}),onClick:()=>{k(i),b.open()}}])]),{type:"divider"},...(0,s.f)(n.role.accessRights.ROLE.DELETE,[{key:"delete",label:"Delete",danger:!0,className:"",icon:(0,r.jsx)(y.Z,{}),onClick:()=>{k(i),T.open()}}])]}})}],dataSource:w.data,onChange:l,loading:w.isFetching,rowKey:e=>e.refId,scroll:{x:1e3},pagination:{current:i.page,pageSize:i.pageSize,defaultPageSize:1,showSizeChanger:!0,pageSizeOptions:[10,25,50,100],showTotal:(e,t)=>"Pagination: ".concat(t[0],"-").concat(t[1]," of ").concat(e," items"),total:i.total}}),(0,r.jsx)(x.Z,{visible:T.visible,title:(null==d?void 0:d.name)||"",content:"Are you sure you want to delete this role?",okButtonText:"Delete",onCancel:()=>{T.close(),k(null)},onOk:()=>{d&&V(d.refId)},danger:!0,loading:P.isPending,disabled:P.isPending}),(0,r.jsx)(x.Z,{visible:b.visible,title:(null==d?void 0:d.name)||"",content:"Are you sure you want to update the role status?",okButtonText:"Update",onCancel:()=>{b.close(),k(null)},onOk:()=>{d&&F(d.refId,!d.active)},loading:D.isPending,disabled:D.isPending})]})},T=n(62581),b=!0,w=e=>{var t;let{user:n}=e,c=(0,o.useRouter)();return(0,r.jsxs)(l.Z,{user:n,activeMenu:["role"],children:[...(0,s.f)(!!(null==n?void 0:null===(t=n.role.accessRights)||void 0===t?void 0:t.ROLE.CREATE),[(0,r.jsx)("div",{className:"flex justify-end mb-5",children:(0,r.jsxs)(a.ZP,{type:"primary",onClick:()=>c.push(T.Z.NEW_ROLE),children:[(0,r.jsx)(i.Z,{}),"New"]})}
1,"new-role-button")]),(0,r.jsx)("div",{children:(0,r.jsx)(k,{})})]})}},73143:function(e,t,n){"use strict";n.d(t,{JV:function(){return c},Rd:function(){return l},Rn:function(){return i},cq:function(){return s},fA:function(){return o},ul:function(){return a},xQ:function(){return u}});var r=n(5409);let i=()=>r.Z.get("/admin/role/options"),o=e=>r.Z.post("/admin/role",e),a=(e,t)=>r.Z.put("/admin/role/".concat(e),t),l=e=>r.Z.delete("/admin/role/".concat(e.id),{params:e}),s=e=>r.Z.put("/admin/role/".concat(e.id,"/status"),{active:e.active}),c=e=>r.Z.get("/admin/role",{params:e}),u=e=>r.Z.get("/admin/role/".concat(e.id))},94170:function(e,t,n){"use strict";var r,i,o,a,l,s,c,u,d,g;n.d(t,{As:function(){return o},fH:function(){return a},hY:function(){return i}}),(s=r||(r={})).EN="en",s.ZH_HK="zh-HK",(c=i||(i={})).LOGIN="login",c.FORGET_PASSWORD="forget_password",c.SIGNUP="signup",(u=o||(o={})).ASC="asc",u.DESC="desc",(d=a||(a={})).VERIFIED="VERIFIED",d.PENDING_FOR_VERIFICATION="PENDING_FOR_VERIFICATION",d.VERIFICATION_EXPIRED="VERIFICATION_EXPIRED",(g=l||(l={})).ADMIN="Admin",g.CUSTOMER="Customer"}},function(e){e.O(0,[5989,4237,7610,8174,9834,8051,9513,4540,928,4298,4190,6631,7444,9406,150,5934,9059,8672,1795,8374,7894,2686,9810,2888,9774,179],function(){return e(e.s=25422)}),_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.