1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9635],{23217:function(e,s,t){"use strict";t.d(s,{Z:function(){return a}});/** 2 * @license lucide-react v0.303.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */let a=(0,t(84297).Z)("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},96895:function(e,s,t){"use strict";t.d(s,{Z:function(){return a}});/** 7 * @license lucide-react v0.303.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */let a=(0,t(84297).Z)("PenSquare",[["path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1qinfi"}],["path",{d:"M18.5 2.5a2.12 2.12 0 0 1 3 3L12 15l-4 1 1-4Z",key:"w2jsv5"}]])},31012:function(e,s,t){"use strict";t.d(s,{Z:function(){return a}});/** 12 * @license lucide-react v0.303.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */let a=(0,t(84297).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},87764:function(e,s,t){"use strict";t.d(s,{Z:function(){return a}});/** 17 * @license lucide-react v0.303.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */let a=(0,t(84297).Z)("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]])},13718:function(e,s,t){"use strict";t.d(s,{Z:function(){return a}});/** 22 * @license lucide-react v0.303.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */let a=(0,t(84297).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},7061:function(e,s,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/users",function(){return t(72605)}])},11990:function(e,s,t){"use strict";t.d(s,{Z:function(){return d}});var a=t(72253),r=t(14932),n=t(47702),l=t(85893),i=t(90512),c=t(23217);function d(e){var s=e.variant,t=e.size,d=e.isLoading,o=void 0!==d&&d,u=e.children,m=e.className,x=e.disabled,p=(0,n._)(e,["variant","size","isLoading","children","className","disabled"]);return(0,l.jsxs)("button",(0,r._)((0,a._)({className:(0,i.Z)("inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",{primary:"bg-primary-600 text-white hover:bg-primary-700 focus:ring-primary-500",secondary:"bg-gray-100 text-gray-700 hover:bg-gray-200 focus:ring-gray-500",outline:"border border-gray-300 text-gray-700 hover:bg-gray-50 focus:ring-primary-500",danger:"bg-red-600 text-white hover:bg-red-700 focus:ring-red-500",white:"bg-white text-slate-900 hover:bg-gray-100 focus:ring-white"}[void 0===s?"primary":s],{sm:"px-3 py-1.5 text-xs",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base"}[void 0===t?"md":t],m),disabled:x||o},p),{children:[o&&(0,l.jsx)(c.Z,{className:"w-4 h-4 mr-2 animate-spin"}),u]}))}},76753:function(e,s,t){"use strict";var a=t(72253),r=t(47702),n=t(85893),l=t(90512),i=(0,t(67294).forwardRef)(function(e,s){var t=e.label,i=e.error,c=e.className,d=e.id,o=(0,r._)(e,["label","error","className","id"]),u=d||o.name;return(0,n.jsxs)("div",{className:"space-y-1",children:[t&&(0,n.jsx)("label",{htmlFor:u,className:"block text-sm font-medium text-gray-700",children:t}),(0,n.jsx)("input",(0,a._)({ref:s,id:u,className:(0,l.Z)("block w-full px-3 py-2 border rounded-lg shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-offset-0 sm:text-sm",i?"border-red-300 focus:ring-red-500 focus:border-red-500":"border-gray-300 focus:ring-primary-500 focus:border-primary-500",c)},o)),i&&(0,n.jsx)("p",{className:"text-sm text-red-600",children:i})]})});i.displayName="Input",s.Z=i},67162:function(e,s,t){"use strict";var a=t(72253),r=t(14932),n=t(47702),l=t(85893),i=t(90512),c=(0,t(67294).forwardRef)(function(e,s){var t=e.label,c=e.error,d=e.options,o=e.className,u=e.id,m=(0,n._)(e,["label","error","options","className","id"]),x=u||m.name;return(0,l.jsxs)("div",{className:"space-y-1",children:[t&&(0,l.jsx)("label",{htmlFor:x,className:"block text-sm font-medium text-gray-700",children:t}),(0,l.jsxs)("select",(0,r._)((0,a._)({ref:s,id:x,className:(0,i.Z)("block w-full px-3 py-2 border rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-offset-0 sm:text-sm",c?"border-red-300 focus:ring-red-500 focus:border-red-500":"border-gray-300 focus:ring-primary-500 focus:border-primary-500",o)},m),{children:[(0,l.jsx)("option",{value:"",children:"Select an option"}),d.map(function(e){return(0,l.jsx)("option",{value:e.value,children:e.label},e.value)})]})),c&&(0,l.jsx)("p",{className:"text-sm text-red-600",children:c})]})});c.displayName="Select",s.Z=c},72605:function(e,s,t){"use strict";t.r(s),t.d(s,{default:function(){return N}});var a=t(11010),r=t(75766),n=t(72253),l=t(14932),i=t(24043),c=t(97582),d=t(85893),o=t(67294),u=t
26(81500),m=t(20034),x=t(52798),p=t(31012),h=t(87764),f=t(96895),y=t(13718),g=t(11990),v=t(76753),b=t(67162),j=t(90512);function N(){var e,s,t,N=(0,i._)((0,o.useState)([]),2),w=N[0],Z=N[1],_=(0,i._)((0,o.useState)(!0),2),k=_[0],C=_[1],S=(0,i._)((0,o.useState)({page:1,pages:1,total:0}),2),U=S[0],M=S[1],q=(0,i._)((0,o.useState)(""),2),A=q[0],E=q[1],P=(0,i._)((0,o.useState)(!1),2),z=P[0],L=P[1],D=(0,i._)((0,o.useState)(null),2),F=D[0],J=D[1],O=(0,i._)((0,o.useState)(!1),2),R=O[0],T=O[1],H=(0,i._)((0,o.useState)(""),2),I=H[0],V=H[1],X=(0,i._)((0,o.useState)({name:"",email:"",password:"",role:"customer",status:"active",phone:"",company:"",country:""}),2),B=X[0],G=X[1];(0,o.useEffect)(function(){K()},[]);var K=(e=(0,a._)(function(){var e,s,t,a=arguments;return(0,c.Jh)(this,function(r){switch(r.label){case 0:e=a.length>0&&void 0!==a[0]?a[0]:1,s=a.length>1&&void 0!==a[1]?a[1]:"",C(!0),r.label=1;case 1:return r.trys.push([1,,3,4]),[4,x.h.getUsers({page:e,limit:20,search:s})];case 2:return(t=r.sent()).success&&t.data&&(Z(t.data.users),M(t.data.pagination)),[3,4];case 3:return C(!1),[7];case 4:return[2]}})}),function(){return e.apply(this,arguments)}),Q=function(e){J(e),G({name:e.name,email:e.email,password:"",role:e.role,status:e.status,phone:e.phone||"",company:e.company||"",country:e.country||""}),L(!0)},W=(s=(0,a._)(function(e){var s;return(0,c.Jh)(this,function(t){switch(t.label){case 0:if(!confirm("Are you sure you want to delete this user?"))return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,x.h.deleteUser(e)];case 2:return t.sent(),K(U.page,A),[3,4];case 3:return s=t.sent(),alert(s.message||"Failed to delete user"),[3,4];case 4:return[2]}})}),function(e){return s.apply(this,arguments)}),Y=(t=(0,a._)(function(e){var s,t,a;return(0,c.Jh)(this,function(r){switch(r.label){case 0:e.preventDefault(),V(""),T(!0),r.label=1;case 1:if(r.trys.push([1,6,7,8]),s="",!F)return[3,3];return[4,x.h.updateUser((0,n._)({id:F.id},B))];case 2:return s=r.sent().message||"User updated successfully",[3,5];case 3:return[4,x.h.createUser(B)];case 4:s=r.sent().message||"User created successfully",r.label=5;case 5:return L(!1),K(U.page,A),alert(s),[3,8];case 6:return(null==(a=null==(t=r.sent())?void 0:t.errors)?void 0:a.password)?V(a.password):a&&Object.keys(a).length?V(Object.values(a)[0]):V((null==t?void 0:t.message)||"Failed to save user"),[3,8];case 7:return T(!1),[7];case 8:return[2]}})}),function(e){return t.apply(this,arguments)}),$=function(e){G((0,l._)((0,n._)({},B),(0,r._)({},e.target.name,e.target.value)))};return(0,d.jsx)(u.Z,{requireAdmin:!0,children:(0,d.jsxs)(m.Z,{children:[(0,d.jsxs)("div",{className:"space-y-6",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h1",{className:"text-2xl font-bold text-gray-900",children:"Users"}),(0,d.jsx)("p",{className:"text-gray-600",children:"Manage platform users."})]}),(0,d.jsxs)(g.Z,{onClick:function(){J(null),G({name:"",email:"",password:"",role:"customer",status:"active",phone:"",company:"",country:""}),L(!0)},children:[(0,d.jsx)(p.Z,{className:"w-4 h-4 mr-2"}),"Add User"]})]}),(0,d.jsxs)("form",{onSubmit:function(e){e.preventDefault(),K(1,A)},className:"flex gap-4",children:[(0,d.jsx)("div",{className:"flex-1 max-w-md",children:(0,d.jsx)(v.Z,{name:"search",value:A,onChange:function(e){return E(e.target.value)},placeholder:"Search users..."})}),(0,d.jsx)(g.Z,{type:"submit",variant:"outline",children:(0,d.jsx)(h.Z,{className:"w-4 h-4"})})]}),(0,d.jsx)("div",{className:"card overflow-hidden p-0",children:k?(0,d.jsx)("div",{className:"flex justify-center py-12",children:(0,d.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary-600"})}):(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,d.jsx)("thead",{className:"bg-gray-50",children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"User"}),(0,d.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Role"}),(0,d.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Status"}),(0,d.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Joined"}),(0,d.jsx)("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase",children:"Actions"})]})}),(0,d.jsx)("tbody",{className:"divide-y divide-gray-200",children:w.map(function(e){return(0,d.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,d.jsx)("td",{className:"px-6 py-4",children:(0,d.jsxs)("div",{className:"flex items-center",children:[(0,d.jsx)("div",{className:"w-10 h-10 rounded-full bg-primary-100 flex items-center justify-center",children:(0,d.jsx)("span",{className:"text-primary-700 font-semibold",children:e.name.charAt(0).toUpperCase()})}),(0,d.jsxs)("div",{className:"ml-4",children:[(0,d.jsx)("p",{className:"font-medium text-gray-900",children:e.name}),(0,d.jsx)("p",{className:"text-sm text-gray-500",children:e.email})]})]})}),(0,d.jsx)("td",{className:"px-6 py-4",children:(0,d.jsx)("span",{className:(0,j.Z)("px-2 py-1 text-xs font-medium rounded-full capitalize","admin"===e.role?"bg-primary-100 text-purple-800":"bg-gray-100 text-gray-800"),children:e.role})}),(0,d.jsx)("td",{className:"px-6 py-4",children:(0,d.jsx)("span",{className:(0,j.Z)("px-2 py-1 text-xs font-medium rounded-full capitalize","active"===e.status?"bg-green-100 text-green-800":"bg-red-100 text-red-800"),children:e.status})}),(0,d.jsx)("td",{className:"px-6 py-4 text-sm text-gray-500",children:new Date(e.created_at).toLocaleDateString()}),(0,d.jsxs)("td",{className:"px-6 py-4 text-right",children:[(0,d.jsx)("button",{onClick:function(){return Q(e)},className:"text-primary-600 hover:text-primary-900 mr-4",children:(0,d.jsx)(f.Z,{className:"w-4 h-4"})}),"admin"!==e.role&&(0,d.jsx)("button",{onClick:function(){return W(e.id)},className:"text-red-600 hover:text-red-900",children:(0,d.jsx)(y.Z,{className:"w-4 h-4"})})]})]},e.id)})})]})})}),U.pages>1&&(0,d.jsx)("div",{className:"flex justify-center gap-2",children:Array.from({length:U.pages},function(e,s){return s+1}).map(function(e){return(0,d.jsx)("button",{onClick:function(){return K(e,A)},className:(0,j.Z)("px-3 py-1 text-sm rounded-md",e===U.page?"bg-primary-600 text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"),children:e},e)})})]}),z&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:(0,d.jsxs)("div",{className:"flex items-center justify-center min-h-screen p-4",children:[(0,d.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:function(){return L(!1)}}),(0,d.jsxs)("div",{className:"relative bg-white rounded-xl shadow-xl max-w-md w-full p-6",children:[(0,d.jsx)("h2",{className:"text-xl font-bold text-gray-900 mb-4",children:F?"Edit User":"Create User"}),I&&(0,d.jsx)("div",{className:"mb-4 p-4 bg-red-50 text-red-600 rounded-lg text-sm",children:I}),(0,d.jsxs)("form",{onSubmit:Y,className:"space-y-4",children:[(0,d.jsx)(v.Z,{label:"Name",name:"name",value:B.name,onChange:$,required:!0}
26),(0,d.jsx)(v.Z,{label:"Email",name:"email",type:"email",value:B.email,onChange:$,required:!0}),(0,d.jsx)(v.Z,{label:F?"Password (leave blank to keep current)":"Password",name:"password",type:"password",value:B.password,onChange:$,required:!F}),(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,d.jsx)(b.Z,{label:"Role",name:"role",value:B.role,onChange:$,options:[{value:"customer",label:"Customer"},{value:"admin",label:"Admin"}]}),(0,d.jsx)(b.Z,{label:"Status",name:"status",value:B.status,onChange:$,options:[{value:"active",label:"Active"},{value:"inactive",label:"Inactive"},{value:"suspended",label:"Suspended"}]})]}),(0,d.jsx)(v.Z,{label:"Phone",name:"phone",value:B.phone,onChange:$}),(0,d.jsx)(v.Z,{label:"Company",name:"company",value:B.company,onChange:$}),(0,d.jsxs)("div",{className:"flex justify-end gap-3 mt-6",children:[(0,d.jsx)(g.Z,{type:"button",variant:"outline",onClick:function(){return L(!1)},children:"Cancel"}),(0,d.jsx)(g.Z,{type:"submit",isLoading:R,children:F?"Update":"Create"})]})]})]})]})})]})})}}},function(e){e.O(0,[4862,2530,7045,9774,2888,179],function(){return e(e.s=7061)}),_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.