1import{a as m,j as e}from"./chunk-three-BTWAGdoL.js";import{u as z,a as H,b as V}from"./chunk-query-NCR7N3-H.js";import{v as Y,C as c,A as n,E as d,F as g,G as o,n as j,B as i,I as Q}from"./index-CmZofxmK.js";import{S as y}from"./switch-Bl7c15gA.js";import{u as B}from"./chunk-router-DABpbG10.js";import{p as A,ai as G,ah as K,bj as D,g as U,V as X,b as S,a4 as $,_ as J,a3 as _,X as Z,bh as W,r as ee,G as se,aK as te,R as ae,S as ie,P as re,ab as le,a1 as ce,C as ne,q as de,T as oe}from"./chunk-icons-CmzO8GHu.js";import"./chunk-radix-CYYWsbOs.js";import"./chunk-maps-ByCLyVpA.js";import"./chunk-utils-CL3reoUV.js";import"./chunk-uppy-Ddo71Xia.js";import"./chunk-charts-D8AvoNRl.js";function fe(){const F=z(),{toast:r}=Y(),[,E]=B(),[w,h]=m.useState(!1),[x,v]=m.useState(""),[N,f]=m.useState(!1),[P,p]=m.useState(!1),{data:b,isLoading:T}=H({queryKey:["wholesale-me"],queryFn:async()=>{const t=await fetch("/api/wholesale/me",{credentials:"include"});if(!t.ok)throw new Error("Failed to fetch store");return t.json()}}),s=b?.store,L=b?.user,u=b?.isOwner,a=V({mutationFn:async t=>{const l=await fetch("/api/wholesale/store",{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(t)});if(!l.ok){const q=await l.json().catch(()=>null);throw new Error(q?.message||"Failed to update settings")}return l.json()},onSuccess:()=>{F.invalidateQueries({queryKey:["wholesale-me"]}),r({title:"Settings updated",description:"Your changes have been saved."})},onError:t=>{r({title:"Error",description:t.message||"Failed to update settings.",variant:"destructive"})}}),k=(t,l)=>{a.mutate({[t]:l})},M=()=>{if(!x.trim()||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(x)){r({title:"Invalid email",description:"Please enter a valid email address.",variant:"destructive"});return}a.mutate({contactEmail:x.trim()}),h(!1)},I=async()=>{if(s?.hmixCode)try{await navigator.clipboard.writeText(s.hmixCode),f(!0),r({title:"Copied!",description:"HMIX code copied to clipboard."}),setTimeout(()=>f(!1),2e3)}catch{r({title:"Copy failed",description:"Could not copy code.",variant:"destructive"})}},R=()=>{a.mutate({isActive:!1}),p(!1)};if(T)return e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]","data-testid":"loading-settings",children:e.jsx(A,{className:"w-8 h-8 animate-spin text-[#D4AF37]"})});if(!s)return null;const O=s.subscriptionPlan==="yearly"?"Annual":"Monthly",C={active:"bg-green-500/10 text-green-400 border-green-500/30",trial:"bg-blue-500/10 text-blue-400 border-blue-500/30",expired:"bg-red-500/10 text-red-400 border-red-500/30",cancelled:"bg-gray-500/10 text-gray-400 border-gray-500/30"};return e.jsxs("div",{className:"space-y-6 max-w-3xl","data-testid":"wholesale-settings",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold text-white","data-testid":"text-settings-title",children:"Settings"}),e.jsx("p",{className:"text-white/50 mt-1",children:"Manage your store configuration and preferences"})]}),e.jsxs(c,{className:"bg-gradient-to-br from-black/60 to-black/40 border-[#D4AF37]/10 backdrop-blur-sm",children:[e.jsxs(n,{children:[e.jsxs(d,{className:"text-lg text-white flex items-center gap-2",children:[s.isActive?e.jsx(G,{className:"w-5 h-5 text-green-400"}):e.jsx(K,{className:"w-5 h-5 text-red-400"}),"Store Visibility"]}),e.jsx(g,{className:"text-white/50",children:"Control whether your store is visible to customers"})]}),e.jsxs(o,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-black/30 border border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(D,{className:"w-5 h-5 text-[#D4AF37]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white font-medium",children:"Store Active"}),e.jsx("p",{className:"text-white/40 text-sm",children:s.isActive?"Your store is live and visible to customers":"Your store is hidden from customers"})]})]}),e.jsx(y,{checked:s.isActive,onCheckedChange:t=>k("isActive",t),disabled:a.isPending,"data-testid":"switch-store-active"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-black/30 border border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(U,{className:"w-5 h-5 text-[#D4AF37]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white font-medium",children:"Velvet Rope"}),e.jsx("p",{className:"text-white/40 text-sm",children:s.isVelvetRope?"Exclusive access â only approved customers can view":"Open to all customers"})]})]}),e.jsx(y,{checked:s.isVelvetRope,onCheckedChange:t=>k("isVelvetRope",t),disabled:a.isPending,"data-testid":"switch-velvet-rope"})]})]})]}),e.jsxs(c,{className:"bg-gradient-to-br from-black/60 to-black/40 border-[#D4AF37]/10 backdrop-blur-sm",children:[e.jsx(n,{children:e.jsxs(d,{className:"text-lg text-white flex items-center gap-2",children:[e.jsx(X,{className:"w-5 h-5 text-[#D4AF37]"}),"Subscription & Plan"]})}),e.jsxs(o,{className:"space-y-4",children:[e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-lg bg-black/30 border border-white/5",children:[e.jsx("p",{className:"text-white/40 text-xs uppercase tracking-wider mb-1",children:"Current Plan"}),e.jsx("p",{className:"text-white font-semibold text-lg",children:O})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-black/30 border border-white/5",children:[e.jsx("p",{className:"text-white/40 text-xs uppercase tracking-wider mb-1",children:"Status"}),e.jsx(j,{variant:"outline",className:C[s.subscriptionStatus]||C.trial,children:s.subscriptionStatus.charAt(0).toUpperCase()+s.subscriptionStatus.slice(1)})]})]}),s.subscriptionStartDate&&e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-lg bg-black/30 border border-white/5",children:[e.jsx("p",{className:"text-white/40 text-xs uppercase tracking-wider mb-1",children:"Started"}),e.jsx("p",{className:"text-white/80 text-sm",children:new Date(s.subscriptionStartDate).toLocaleDateString()})]}),s.subscriptionEndDate&&e.jsxs("div",{className:"p-4 rounded-lg bg-black/30 border border-white/5",children:[e.jsx("p",{className:"text-white/40 text-xs uppercase tracking-wider mb-1",children:"Renews / Expires"}),e.jsx("p",{className:"text-white/80 text-sm",children:new Date(s.subscriptionEndDate).toLocaleDateString()})]})]}),s.hmixCode&&e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-black/30 border border-white/5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-white/40 text-xs uppercase tracking-wider mb-1",children:"HMIX Code"}),e.jsx("p",{className:"text-[#D4AF37] font-mono font-bold text-lg",children:s.hmixCode})]}),e.jsx(i,{size:"sm",variant:"ghost",className:N?"text-green-400":"text-white/50 hover:text-[#D4AF37]",onClick:I,"data-testid":"button-copy-hmix",children:N?e.jsx(S,{className:"w-4 h-4"}):e.jsx($,{className:"w-4 h-4"})})]})]})]}),e.jsxs(c,{className:"bg-gradient-to-br from-black/60 to-black/40 border-[#D4AF37]/10 backdrop-blur-sm",children:[e.jsx(n,{children:e.jsxs(d,{className:"text-lg text-white flex items-center gap-2",children:[e.jsx(J,{className:"w-5 h-5 text-[#D4AF37]"}),"Account Information"]})}),e.jsxs(o,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-black/30 border border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(_,{className:"w-5 h-5 text-[#D4AF37]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white/40 text-xs",children:"Contact Email"}),w?e.jsx(Q,{value:x,onChange:t=>v(t.target.value),placeholder:"[email protected]",className:"mt-1 bg-black/50 border-[#D4AF37]/30 text-white h-8 text-sm w-64",autoFocus:!0,"data-testid":"input-new-email"}):e.jsx("p",{className:"text-white font-medium",children:s.contactEmail})]})]}),u&&e.jsx("div",{className:"flex items-center gap-2",children:w?e.jsxs(e.Fragment,{children:[e.jsx(i,{size:"sm",variant:"ghost",className:"text-green-400 hover:bg-green-500/10 h-8 w-8 p-0",onClick:M,disabled:a.isPending,"data-testid":"button-save-email",children:e.jsx(S,{className:"w-4 h-4"})}),e.jsx(i,{size:"sm",variant:"ghost",className:"text-red-400 hover:bg-red-500/10 h-8 w-8 p-0",onClick:()=>h(!1),"data-testid":"button-cancel-email",children:e.jsx(Z,{className:"w-4 h-4"})})]}):e.jsx(i,{size:"sm",variant:"ghost",className:"text-white/50 hover:text-[#D4AF37] h-8 w-8 p-0",onClick:()=>{v(s.contactEmail),h(!0)},"data-testid":"button-edit-email",children:e.jsx(W,{className:"w-4 h-4"})})})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-black/30 border border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ee,{className:"w-5 h-5 text-[#D4AF37]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white/40 text-xs",children:"Owner"}),e.jsx("p",{className:"text-white font-medium",children:L?.name||"â"})]})]}),u&&e.jsx(j,{variant:"outline",className:"bg-[#D4AF37]/10 text-[#D4AF37] border-[#D4AF37]/30",children:"Owner"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-black/30 border border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(se,{className:"w-5 h-5 text-[#D4AF37]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white/40 text-xs",children:"Store Slug"}),e.jsxs("p",{className:"text-white font-mono text-sm",children:["/wholesale/",s.slug]})]})]}),s.slug&&e.jsx("a",{href:`/wholesale/${s.slug}`,target:"_blank",rel:"noopener noreferrer",className:"text-white/50 hover:text-[#D4AF37] transition-colors","data-testid":"link-store-page",children:e.jsx(te,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-black/30 border border-white/5",children:[e.jsx("p",{className:"text-white/40 text-xs",children:"Approval Status"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(j,{variant:"outline",className:s.isApproved?"bg-green-500/10 text-green-400 border-green-500/30":"bg-amber-500/10 text-amber-400 border-amber-500/30",children:s.isApproved?"Approved":"Pending Approval"}),!s.isApproved&&e.jsx("p",{className:"text-white/40 text-xs",children:"Your store is awaiting admin a
1pproval"})]})]})]})]}),e.jsxs(c,{className:"bg-gradient-to-br from-black/60 to-black/40 border-[#D4AF37]/10 backdrop-blur-sm",children:[e.jsxs(n,{children:[e.jsxs(d,{className:"text-lg text-white flex items-center gap-2",children:[e.jsx(ae,{className:"w-5 h-5 text-[#D4AF37]"}),"Quick Manage"]}),e.jsx(g,{className:"text-white/50",children:"Jump to sections to add, edit, or delete items"})]}),e.jsx(o,{className:"space-y-2",children:[{icon:ie,label:"Edit Store Profile",desc:"Update name, images, description, location",path:"/wholesale/profile"},{icon:re,label:"Manage Inventory",desc:"Add, edit, or remove products",path:"/wholesale/inventory"},{icon:le,label:"Manage Discounts",desc:"Create or edit discount codes",path:"/wholesale/discounts"},{icon:ce,label:"Manage Team",desc:"Add or remove team members, set permissions",path:"/wholesale/team"}].map(t=>e.jsxs("button",{onClick:()=>E(t.path),className:"w-full flex items-center gap-4 p-4 rounded-lg bg-black/30 border border-white/5 hover:border-[#D4AF37]/30 hover:bg-[#D4AF37]/5 transition-all cursor-pointer group","data-testid":`quick-nav-${t.label.toLowerCase().replace(/\s+/g,"-")}`,children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-[#D4AF37]/10 flex items-center justify-center group-hover:bg-[#D4AF37]/20 transition-colors",children:e.jsx(t.icon,{className:"w-5 h-5 text-[#D4AF37]"})}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsx("p",{className:"text-white font-medium",children:t.label}),e.jsx("p",{className:"text-white/40 text-sm",children:t.desc})]}),e.jsx(ne,{className:"w-5 h-5 text-white/20 group-hover:text-[#D4AF37] transition-colors"})]},t.path))})]}),u&&e.jsxs(c,{className:"bg-gradient-to-br from-black/60 to-black/40 border-red-500/20 backdrop-blur-sm",children:[e.jsxs(n,{children:[e.jsxs(d,{className:"text-lg text-red-400 flex items-center gap-2",children:[e.jsx(de,{className:"w-5 h-5"}),"Danger Zone"]}),e.jsx(g,{className:"text-white/50",children:"Irreversible actions â proceed with caution"})]}),e.jsx(o,{className:"space-y-4",children:e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-black/30 border border-red-500/10",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-white font-medium",children:"Deactivate Store"}),e.jsx("p",{className:"text-white/40 text-sm",children:"Hide your store from all customers. You can reactivate later."})]}),P?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(i,{variant:"destructive",size:"sm",onClick:R,disabled:a.isPending,"data-testid":"button-confirm-deactivate",children:[a.isPending?e.jsx(A,{className:"w-4 h-4 animate-spin mr-1"}):e.jsx(oe,{className:"w-4 h-4 mr-1"}),"Confirm"]}),e.jsx(i,{variant:"ghost",size:"sm",className:"text-white/50",onClick:()=>p(!1),"data-testid":"button-cancel-deactivate",children:"Cancel"})]}):e.jsxs(i,{variant:"outline",className:"border-red-500/30 text-red-400 hover:bg-red-500/10",onClick:()=>p(!0),disabled:!s.isActive,"data-testid":"button-deactivate-store",children:[e.jsx(D,{className:"w-4 h-4 mr-2"}),s.isActive?"Deactivate":"Already Inactive"]})]})})]}),e.jsx("div",{className:"pb-8"})]})}export{fe as default};
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.