import"../chunks/Bzak7iHL.js";import{p as ke,d as Ue,e as Ne,a as v,b as Se,j as a,u as je,f as p,c as t,s as r,r as e,n as Ve,t as E}from"../chunks/CnGaPG_y.js";import{d as Le,s as o}from"../chunks/BBilxCvN.js";import{i as F}from"../chunks/BqhvobEz.js";import{e as Re,i as $e}from"../chunks/_bkH3ryn.js";import{s as ee}from"../chunks/Bu9wkQ5s.js";import{s as _}from"../chunks/B764PkgB.js";async function Ee(M,f){var s;try{if(!(await fetch(`/api/admin/users/${(s=a(f))==null?void 0:s.id}/reset-password`,{method:"POST"})).ok)throw new Error("Failed to send password reset email.");alert("Password reset email sent successfully.")}catch(c){alert(c.message)}}var Fe=p('

User not found

The user you are looking for does not exist.

'),Me=()=>console.log("activating user"),Te=p(' '),ze=p('
Order IDDateAmountStatus
'),Be=p("

No orders found for this user.

"),Ce=p('

Profile Image

'),Ke=p('

Profile Image

No image uploaded

'),qe=p('
← Back to Users

User Details

Contact Information

Email:

Phone: N/A

Address: N/A

Account Details

Member Since:

Last Login:

Status:

Role:

Recent Orders

');function Ze(M,f){ke(f,!0);let s=je(()=>{var l;return(l=f.data)==null?void 0:l.user});function c(l){return new Date(l).toLocaleDateString("en-UK",{day:"numeric",month:"short",year:"numeric"})}var T=Ue(),te=Ne(T);{var re=l=>{var x=Fe();v(l,x)},ae=l=>{var x=qe(),h=t(x),z=r(t(h),2),m=t(z);m.__click=[Me];var se=t(m,!0);e(m);var de=r(m,2);de.__click=[Ee,s],e(z),e(h);var B=r(h,2),y=t(B),w=t(y),A=t(w),P=t(A),ie=t(P,!0);e(P);var C=r(P,2),I=t(C),oe=t(I,!0);e(I);var K=r(I,2),le=t(K,!0);e(K),e(C),e(A);var q=r(A,2),D=t(q),G=r(t(D),2),H=t(G),ve=r(t(H));e(H),Ve(4),e(G),e(D);var J=r(D,2),Q=r(t(J),2),O=t(Q),ne=r(t(O));e(O);var k=r(O,2),pe=r(t(k));e(k);var U=r(k,2),N=r(t(U),2),ce=t(N,!0);e(N),e(U);var W=r(U,2),S=r(t(W),2),xe=t(S,!0);e(S),e(W),e(Q),e(J),e(q),e(w);var X=r(w,2),me=r(t(X),2);{var ge=d=>{var i=ze(),n=t(i),g=r(t(n));Re(g,21,()=>a(s).Order,$e,(he,b)=>{var j=Te(),V=t(j),ye=t(V,!0);e(V);var L=r(V),we=t(L,!0);e(L);var R=r(L),Ae=t(R);e(R);var Z=r(R),$=t(Z),Pe=t($,!0);e($),e(Z),e(j),E((u,Ie,De,Oe)=>{o(ye,a(b).id),o(we,u),o(Ae,`$${Ie??""}`),_($,1,De),o(Pe,Oe)},[()=>c(a(b).createdAt),()=>a(b).totalPrice.toFixed(2),()=>`inline-flex rounded-full px-2 text-xs font-semibold ${a(b).ProductOnOrder.some(u=>!u.isIssued)?"bg-red-100 text-red-800":"bg-green-100 text-green-800"}`,()=>a(b).ProductOnOrder.some(u=>!u.isIssued)?"Pending":"Issued"]),v(he,j)}),e(g),e(n),e(i),v(d,i)},be=d=>{var i=Be();v(d,i)};F(me,d=>{a(s).Order.length>0?d(ge):d(be,!1)})}e(X),e(y);var Y=r(y,2),ue=t(Y);{var fe=d=>{var i=Ce(),n=r(t(i),2);e(i),E(()=>{var g;ee(n,"src",(g=a(s).profileImage)==null?void 0:g.url),ee(n,"alt",`${a(s).name}'s Profile`)}),v(d,i)},_e=d=>{var i=Ke();v(d,i)};F(ue,d=>{a(s).imageId?d(fe):d(_e,!1)})}e(Y),e(B),e(x),E((d,i,n)=>{_(m,1,`rounded-lg px-4 py-2 ${a(s).isVerified?"bg-red-500 text-white hover:bg-red-600":"bg-green-500 text-white hover:bg-green-600"}`),o(se,a(s).isVerified?"Deactivate User":"Activate User"),o(ie,d),o(oe,a(s).name),o(le,a(s).email),o(ve,` ${a(s).email??""}`),o(ne,` ${i??""}`),o(pe,` ${n??""}`),_(N,1,`ml-1 inline-flex rounded-full px-2 text-xs font-semibold ${a(s).isVerified?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`),o(ce,a(s).isVerified?"Active":"Inactive"),_(S,1,`ml-1 inline-flex rounded-full px-2 text-xs font-semibold ${a(s).role.name==="ADMIN"?"bg-purple-100 text-purple-800":"bg-green-100 text-green-800"}`),o(xe,a(s).role.name)},[()=>a(s).name.charAt(0),()=>c(a(s).createdAt),()=>c(a(s).updatedAt)]),v(l,x)};F(te,l=>{a(s)?l(ae,!1):l(re)})}v(M,T),Se()}Le(["click"]);export{Ze as component};