PageSourceSearch

https://brandjitsu.com/assets/Store-B8Huxxji.js

js brandjitsu.com collected 2026-10-04 06:19:04 UTC 24,083 bytes, 1 lines download raw bytes

1import{r as e,j as s,ad as r,ae as t,X as a,ag as n,ab as i,an as o,z as l,ac as c}from"./vendor-DKpN-gn6.js";import{u as d,s as u,B as m,c as h}from"./index-CjqWG2Gu.js";import{C as x,b as p,c as j,d as g,a as f}from"./card-C0twyzQf.js";import{I as b}from"./input-BczSeZo5.js";import{b as y,c as v,T as N,d as w,e as C,a as k}from"./table-DbVpf6SP.js";import{B as S}from"./badge-BupusfKi.js";import{T as P,a as A,b as D,c as E}from"./tooltip-FmFdmcE2.js";import{S as _}from"./skeleton-CQZJIIqz.js";import{D as R,a as L,c as I,d as O,e as q,f as F}from"./dialog-vWJa2GV8.js";import{u as T,t as U,a as V,b as z,c as M,d as B,e as G,F as $}from"./form-gUyvjEUn.js";import{z as W}from"./index-Cpv5ucUd.js";import{T as H}from"./textarea-DfQUl5Gc.js";import{S as J,a as K,b as X,c as Q,d as Y}from"./select-CjMQhslo.js";import{n as Z,o as ee,d as se,e as re,p as te,q as ae,r as ne,f as ie,g as oe,u as le,h as ce,I as de}from"./ui-DbiJ6HOd.js";import"./auth-D0Oxv0aP.js";import"./label-D75N5ztj.js";const ue=()=>{const{products:s,setProducts:r,isLoading:t,fetchProducts:a}=(()=>{const[s,r]=e.useState([]),[t,a]=e.useState(!0),{toast:n}=d(),i=async()=>{a(!0);try{const{data:e,error:s}=await u.from("products").select("*").order("name");if(s)throw s;return e?.map((e=>({...e,dimensions:e.dimensions||{height:null,width:null,depth:null},tags:Array.isArray(e.tags)?e.tags:[]})))||[]}catch(e){return n({title:"Error",description:"Failed to load products. Please try again.",variant:"destructive"}),[]}finally{a(!1)}};return e.useEffect((()=>{(async()=>{const e=await i();r(e)})()}),[]),{products:s,setProducts:r,isLoading:t,fetchProducts:i}})(),{addProduct:n,isSubmitting:i}=(s=>{const[r,t]=e.useState(!1),{toast:a}=d();return{addProduct:async e=>{t(!0);try{const r=Array.isArray(e.tags)?e.tags:[],t={...e,tags:r},{data:n,error:i}=await u.from("products").insert([t]).select();if(i)throw i;if(n&&n[0]){const e={...n[0],tags:Array.isArray(n[0].tags)?n[0].tags:[]};s(e)}return a({title:"Success",description:"Product added successfully"}),!0}catch(r){return a({title:"Error",description:"Failed to add product. Please try again.",variant:"destructive"}),!1}finally{t(!1)}},isSubmitting:r}})((e=>{r([...s,e])})),{updateProduct:o,isSubmitting:l}=(s=>{const[r,t]=e.useState(!1),{toast:a}=d();return{updateProduct:async(e,r)=>{t(!0);try{const t=Array.isArray(r.tags)?r.tags:[],n={...r};n.tags=t;const{data:i,error:o}=await u.from("products").update(n).eq("id",e).select();if(o)throw o;if(i&&i[0]){const r={...i[0],tags:Array.isArray(i[0].tags)?i[0].tags:[]};s(r,e)}return a({title:"Success",description:"Product updated successfully"}),!0}catch(n){return a({title:"Error",description:"Failed to update product. Please try again.",variant:"destructive"}),!1}finally{t(!1)}},isSubmitting:r}})(((e,t)=>{r(s.map((s=>s.id===t?e:s)))})),{deleteProduct:c,isDeleting:m}=(s=>{const[r,t]=e.useState(!1),{toast:a}=d();return{deleteProduct:async e=>{t(!0);try{const{error:r}=await u.from("products").delete().eq("id",e);if(r)throw r;return s(e),a({title:"Success",description:"Product deleted successfully"}),!0}catch(r){return a({title:"Error",description:"Failed to delete product. Please try again.",variant:"destructive"}),!1}finally{t(!1)}},isDeleting:r}})((e=>{r(s.filter((s=>s.id!==e)))}));return{products:s,isLoading:t,isSubmitting:i||l||m,fetchProducts:a,addProduct:n,updateProduct:o,deleteProduct:c}};function me({products:e,onEdit:a,onDelete:n}){const i=(e,s)=>e?"object"!=typeof e?"-":e[s]?`${e[s]}`:"-":"-";return s.jsx("div",{className:"border rounded-md",children:s.jsxs(y,{children:[s.jsx(v,{children:s.jsxs(N,{children:[s.jsx(w,{children:"Image"}),s.jsx(w,{children:"Name"}),s.jsx(w,{children:"Category"}),s.jsx(w,{children:"Price"}),s.jsx(w,{children:"Stock"}),s.jsx(w,{children:"Type"}),s.jsx(w,{children:"Dimensions"}),s.jsx(w,{children:"Tags"}),s.jsx(w,{className:"text-right",children:"Actions"})]})}),s.jsxs(C,{children:[0===e.length&&s.jsx(N,{children:s.jsx(k,{colSpan:8,className:"text-center py-6 text-muted-foreground",children:"No products found"})}),e.map((e=>s.jsxs(N,{children:[s.jsx(k,{children:e.image_url?s.jsx("img",{src:e.image_url,alt:e.name,className:"h-12 w-12 object-cover rounded-md"}):s.jsx("div",{className:"h-12 w-12 bg-gray-100 rounded-md flex items-center justify-center text-gray-400",children:"No image"})}),s.jsx(k,{className:"font-medium max-w-[200px] truncate",children:e.name}),s.jsx(k,{children:e.category?s.jsx(S,{variant:"outline",children:e.category}):"-"}),s.jsxs(k,{children:["$",e.price.toFixed(2)]}),s.jsx(k,{children:e.stock_level||0}),s.jsx(k,{children:s.jsx(S,{variant:"secondary",children:e.product_type?e.product_type.charAt(0).toUpperCase()+e.product_type.slice(1):"Physical"})}),s.jsx(k,{children:e.dimensions?s.jsxs("span",{children:[i(e.dimensions,"height")," x ",i(e.dimensions,"width")," x ",i(e.dimensions,"depth")," cm"]}):"-"}),s.jsx(k,{children:s.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.tags&&e.tags.length>0?e.tags.slice(0,2).map(((e,r)=>s.jsx(S,{variant:"secondary",className:"text-xs",children:e},r))):"-",e.tags&&e.tags.length>2&&s.jsxs(S,{variant:"secondary",className:"text-xs",children:["+",e.tags.length-2]})]})}),s.jsx(k,{className:"text-right",children:s.jsxs("div",{className:"flex justify-end space-x-2",children:[s.jsx(P,{children:s.jsxs(A,{children:[s.jsx(D,{asChild:!0,children:s.jsxs(m,{variant:"ghost",size:"icon",onClick:()=>a(e),children:[s.jsx(r,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Edit"})]})}),s.jsx(E,{children:s.jsx("p",{children:"Edit"})})]})}),s.jsx(P,{children:s.jsxs(A,{children:[s.jsx(D,{asChild:!0,children:s.jsxs(m,{variant:"ghost",size:"icon",onClick:()=>n(e),children:[s.jsx(t,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Delete"})]})}),s.jsx(E,{children:s.jsx("p",{children:"Delete"})})]})})]})})]},e.id)))]})]})})}function he(){return s.jsx("div",{className:"border rounded-md",children:s.jsxs(y,{children:[s.jsx(v,{children:s.jsxs(N,{children:[s.jsx(w,{children:"Name"}),s.jsx(w,{children:"Price"}),s.jsx(w,{children:"Stock"}),s.jsx(w,{children:"Dimensions"}),s.jsx(w,{children:"Weight"}),s.jsx(w,{className:"text-right",children:"Actions"})]})}),s.jsx(C,{children:[...Array(5)].map(((e,r)=>s.jsxs(N,{children:[s.jsx(k,{children:s.jsx(_,{className:"h-4 w-[200px]"})}),s.jsx(k,{children:s.jsx(_,{className:"h-4 w-16"})}),s.jsx(k,{children:s.jsx(_,{className:"h-4 w-12"})}),s.jsx(k,{children:s.jsx(_,{className:"h-4 w-24"})}),s.jsx(k,{children:s.jsx(_,{className:"h-4 w-16"})}),s.jsx(k,{className:"text-right",children:s.jsxs("div",{className:"flex justify-end space-x-2",children:[s.jsx(_,{className:"h-8 w-8 rounded-full"}),s.jsx(_,{className:"h-8 w-8 rounded-full"})]})})]},r)))})]})})}const xe=["Book","Workbook","Clothing"],pe=["physical","digital"],je=W.object({name:W.string().min(1,"Product name is required"),description:W.string().optional(),price:W.coerce.number().min(0,"Price must be positive"),stock_level:W.coerce.number().int().min(0,"Stock level must be a positive integer"),category:W.string().optional(),tags:W.array(W.string()).default([]),image_url:W.string().optional().nullable(),weight:W.coerce.number().min(0).optional().nullable(),product_type:W.enum(pe,{errorMap:()=>({message:"Please select a product type"})}),dimensions:W.object({height:W.coerce.number().min(0).optional().nullable(),width:W.coerce.number().min(0).optional().nullable(),depth:W.coerce.number().min(0).optional().nullable()})});function ge({form:e}){return s.jsxs("div",{className:"space-y-6",children:[s.jsx(V,{control:e.control,name:"name",render:({field:e})=>s.jsxs(z,{children:[s.jsx(M,{className:"text-base font-medium mb-1 block",children:"Product Name"}),s.jsx(B,{children:s.jsx(b,{...e,className:"border-gray-300 focus:border-indigo-500"})}),s.jsx(G,{})]})}),s.jsx(V,{control:e.control,name:"description",render:({field:e})=>s.jsxs(z,{children:[s.jsx(M,{className:"text-base font-medium mb-1 block",children:"Description"}),s.jsx(B,{children:s.jsx(H,{...e,rows:4,className:"border-gray-300 focus:border-indigo-500"})}),s.jsx(G,{})]})}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(V,{control:e.control,name:"price",render:({field:e})=>s.jsxs(z,{children:[s.jsx(M,{className:"text-base font-medium mb-1 block",children:"Price (CAD)"}),s.jsx(B,{children:s.jsx(b,{type:"number",step:"0.01",...e,className:"border-gray-300 focus:border-indigo-500"})}),s.jsx(G,{})]})}),s.jsx(V,{control:e.control,name:"stock_level",render:({field:e})=>s.jsxs(z,{children:[s.jsx(M,{className:"text-base font-medium mb-1 block",children:"Stock Level"}),s.jsx(B,{children:s.jsx(b,{type:"number",...e,className:"border-gray-300 focus:border-indigo-500"})}),s.jsx(G,{})]})})]})]})}function fe({form:r}){const t=r.watch("category");return e.useEffect((()=>{}),[t]),s.jsx(V,{control:r.control,name:"category",render:({field:e})=>s.jsxs(z,{children:[s.jsx(M,{className:"text-base font-medium mb-1 block",children:"Category"}),s.jsxs(J,{onValueChange:s=>{e.onChange(s),r.setValue("category",s,{shouldValidate:!0,shouldDirty:!0,shouldTouch:!0})},value:e.value,defaultValue:e.value,children:[s.jsx(B,{children:s.jsx(K,{className:"border-gray-300 focus:border-indigo-500",children:s.jsx(X,{placeholder:"Select a category"})})}),s.jsx(Q,{children:xe.map((e=>s.jsx(Y,{value:e,children:e},e)))})]}),s.jsx(G,{})]})})}function be({title:e,children:r,className:t=""}){return s.jsxs("div",{className:`space-y-4 ${t}`,children:[s.jsx("h3",{className:"text-base font-medium mb-2",children:e}),r]})}function ye({form:e}){return s.jsx(be,{title:"Physical Properties",children:s.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[s.jsxs("div",{children:[s.jsx(V,{control:e.control,name:"dimensions.height",render:({field:e})=>s.jsxs(z,{children:[s.jsx(B,{children:s.jsx(b,{type:"number",step:"0.1",...e,value:e.value||"",onChange:s=>e.onChange(s.target.value?Number(s.target.value):void 0),className:"border-gray-300 focus:border-indigo-500"})}),s.jsx(G,{})]})}),s.jsx("p",{className:"text-sm mt-2 text-gray-500",children:"Height (cm)"})]}),s.jsxs("div",{children:[s.jsx(V,{control:e.control,name:"dimensions.width",render:({field:e})=>s.jsxs(z,{children:[s.jsx(B,{children:s.jsx(b,{type:"number",step:"0.1",...e,value:e.value||"",onChange:s=>e.onChange(s.target.value?Number(s.target.value):void 0),className:"border-gray-300 focus:border-indigo-500"})}),s.jsx(G,{})]})}),s.jsx("p",{className:"text-sm mt-2 text-gray-500",children:"Width (cm)"})]}),s.jsxs("div",{children:[s.jsx(V,{control:e.control,name:"dimensions.depth",render:({field:e})=>s.jsxs(z,{children:[s.jsx(B,{children:s.jsx(b,{type:"number",step:"0.1",...e,value:e.value||"",onChange:s=>e.onChange(s.target.value?Number(s.target.value):void 0),className:"border-gray-300 focus:border-indigo-500"})}),s.jsx(G,{})]})}),s.jsx("p",{className:"text-sm mt-2 text-gray-500",children:"Depth (cm)"})]}),s.jsxs("div",{children:[s.jsx(V,{control:e.control,name:"weight",render:({field:e})=>s.jsxs(z,{children:[s.jsx(B,{children:s.jsx(b,{type:"number",...e,value:e.value||"",onChange:s=>e.onChange(s.target.value?Number(s.target.value):void 0),className:"border-gray-300 focus:border-indigo-500"})}),s.jsx(G,{})]})}),s.jsx("p",{className:"text-sm mt-2 text-gray-500",children:"Weight (g)"})]})]})})}function ve({value:r,onChange:t}){const[o,l]=e.useState(!1),{toast:c}=d();return s.jsx("div",{className:"space-y-4",children:r?s.jsxs("div",{className:"relative w-full",children:[s.jsx("img",{src:r,alt:"Product",className:"object-cover rounded-md border h-64 w-full"}),s.jsx(m,{variant:"destructive",size:"icon",className:"absolute top-2 right-2",onClick:e=>{e.preventDefault(),e.stopPropagation(),t("")},type:"button",children:s.jsx(a,{className:"h-4 w-4"})})]}):s.jsxs("div",{className:"relative",children:[s.jsx(m,{variant:"outline",onClick:e=>{e.preventDefault(),document.getElementById("imageUpload")?.click()},className:"h-64 w-full flex flex-col gap-2 border-dashed border-2 border-gray-300 bg-transparent hover:bg-gray-50 rounded-md",disabled:o,type:"button",children:o?s.jsxs(s.Fragment,{children:[s.jsx(n,{className:"h-8 w-8 animate-spin"}),s.jsx("span",{children:"Uploading..."})]}):s.jsxs(s.Fragment,{children:[s.jsx(i,{className:"h-8 w-8 mb-2"}),s.jsx("span",{className:"text-xl font-medium",children:"Upload Product Image"})]})}),s.jsx("input",{id:"imageUpload",type:"file",accept:"image/*",className:"hidden",onChange:async e=>{e.preventDefault();const s=e.target.files?.[0];if(s)if(s.type.startsWith("image/"))if(s.size>5242880)c({title:"File too large",description:"Image must be less than 5MB",variant:"destructive"});else{l(!0);try{const e=s.name.split(".").pop(),r=`products/${`${Math.random().toString(36).substring(2,15)}-${Date.now()}.${e}`}`,{data:a,error:n}=await u.storage.from("product-images").upload(r,s);if(n)throw n;const{data:i}=u.storage.from("product-images").getPublicUrl(r);t(i.publicUrl),c({title:"Upload successful",description:"Image has been uploaded"})}catch(r){c({title:"Upload failed",description:"There was a problem uploading your image",variant:"destructive"})}finally{l(!1)}}else c({title:"Invalid file type",description:"Please upload an image file",variant:"destructive"})},disabled:o})]})})}function Ne({form:e}){return s.jsx(V,{control:e.control,name:"image_url",render:({field:e})=>s.jsxs(z,{children:[s.jsx(M,{className:"text-base font-medium mb-1 block",children:"Product Image"}),s.jsx(B,{children:s.jsx(ve,{value:e.value||"",onChange:e.onChange})}),s.jsx(G,{})]})})}function we({value:r=[],onChange:t,placeholder:n="Add tags..."}){const[i,o]=e.useState(""),l=Array.isArray(r)?r:[];return s.jsxs("div",{className:"tag-input-container",children:[s.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:l.map((e=>s.jsxs(S,{className:"flex items-center gap-1 px-3 py-1 bg-slate-200 text-slate-800 hover:bg-slate-300",children:[e,s.jsx(a,{className:"h-3 w-3 cursor-pointer",onClick:s=>{s.stopPropagation(),(e=>{const s=l.filter((s=>s!==e));t(s)})(e)}})]},e)))}),s.jsx(b,{type:"text",placeholder:n,value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{if("Enter"===e.key&&""!==i.trim()){if(e.preventDefault(),e.stopPropagation(),!l.includes(i.trim())){const e=[...l,i.trim()];t(e)}o("")}}})]})}function Ce({form:r}){const t=r.watch("tags")||[];return e.useEffect((()=>{}),[t]),s.jsx(be,{title:"Tags",className:"mt-6",children:s.jsx(V,{control:r.control,name:"tags",render:({field:e})=>s.jsxs(z,{children:[s.jsx(M,{children:"Product Tags"}),s.jsx(B,{children:s.jsx(we,{value:e.value||[],onChange:s=>{const r=Array.isArray(s)?s:[];e.onChange(r)},placeholder:"Add tags (press Enter after each tag)"})}),s.jsx(G,{})]})})})}function ke({onCancel:e,isSubmitting:r,isEditing:t}){return s.jsxs("div",{className:"flex justify-start space-x-4 mt-5",children:[s.jsx(m,{type:"button",variant:"outline",onClick:s=>{s.preventDefault(),e()},size:"lg",className:"px-8 h-12 hover:border-brand-orange hover:text-brand-orange hover:bg-transparent",children:"Cancel"}),s.jsx(m,{type:"submit",disabled:r,className:"bg-orange-500 hover:bg-orange-600 px-8 h-12",size:"lg",children:r?"Saving...":t?"Update Product":"Add Product"})]})}function Se({leftColumn:e,rightColumn:r}){return s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsx("div",{className:"space-y-6",children:e}),s.jsx("div",{children:r})]})}var Pe="Radio",[Ae,De]=Z(Pe),[Ee,_e]=Ae(Pe),Re=e.forwardRef(((r,t)=>{const{__scopeRadio:a,name:n,checked:i=!1,required:o,disabled:l,value:c="on",onCheck:d,form:u,...m}=r,[h,x]=e.useState(null),p=ee(t,(e=>x(e))),j=e.useRef(!1),g=!h||(u||!!h.closest("form"));return s.jsxs(Ee,{scope:a,checked:i,disabled:l,children:[s.jsx(se.button,{type:"button",role:"radio","aria-checked":i,"data-state":qe(i),"data-disabled":l?"":void 0,disabled:l,value:c,...m,ref:p,onClick:re(r.onClick,(e=>{i||d?.(),g&&(j.current=e.isPropagationStopped(),j.current||e.stopPropagation())}))}),g&&s.jsx(Oe,{control:h,bubbles:!j.current,name:n,value:c,checked:i,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})}));Re.displayName=Pe;var Le="RadioIndicator",Ie=e.forwardRef(((e,r)=>{const{__scopeRadio:t,forceMount:a,...n}=e,i=_e(Le,t);return s.jsx(te,{present:a||i.checked,children:s.jsx(se.span,{"data-state":qe(i.checked),"data-disabled":i.disabled?"":void 0,...n,ref:r})})}));Ie.displayName=Le;var Oe=r=>{const{control:t,checked:a,bubbles:n=
1!0,...i}=r,o=e.useRef(null),l=ae(a),c=ne(t);return e.useEffect((()=>{const e=o.current,s=window.HTMLInputElement.prototype,r=Object.getOwnPropertyDescriptor(s,"checked").set;if(l!==a&&r){const s=new Event("click",{bubbles:n});r.call(e,a),e.dispatchEvent(s)}}),[l,a,n]),s.jsx("input",{type:"radio","aria-hidden":!0,defaultChecked:a,...i,tabIndex:-1,ref:o,style:{...r.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function qe(e){return e?"checked":"unchecked"}var Fe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Te="RadioGroup",[Ue,Ve]=Z(Te,[ie,De]),ze=ie(),Me=De(),[Be,Ge]=Ue(Te),$e=e.forwardRef(((e,r)=>{const{__scopeRadioGroup:t,name:a,defaultValue:n,value:i,required:o=!1,disabled:l=!1,orientation:c,dir:d,loop:u=!0,onValueChange:m,...h}=e,x=ze(t),p=oe(d),[j,g]=le({prop:i,defaultProp:n,onChange:m});return s.jsx(Be,{scope:t,name:a,required:o,disabled:l,value:j,onValueChange:g,children:s.jsx(ce,{asChild:!0,...x,orientation:c,dir:p,loop:u,children:s.jsx(se.div,{role:"radiogroup","aria-required":o,"aria-orientation":c,"data-disabled":l?"":void 0,dir:p,...h,ref:r})})})}));$e.displayName=Te;var We="RadioGroupItem",He=e.forwardRef(((r,t)=>{const{__scopeRadioGroup:a,disabled:n,...i}=r,o=Ge(We,a),l=o.disabled||n,c=ze(a),d=Me(a),u=e.useRef(null),m=ee(t,u),h=o.value===i.value,x=e.useRef(!1);return e.useEffect((()=>{const e=e=>{Fe.includes(e.key)&&(x.current=!0)},s=()=>x.current=!1;return document.addEventListener("keydown",e),document.addEventListener("keyup",s),()=>{document.removeEventListener("keydown",e),document.removeEventListener("keyup",s)}}),[]),s.jsx(de,{asChild:!0,...c,focusable:!l,active:h,children:s.jsx(Re,{disabled:l,required:o.required,checked:h,...d,...i,name:o.name,ref:m,onCheck:()=>o.onValueChange(i.value),onKeyDown:re((e=>{"Enter"===e.key&&e.preventDefault()})),onFocus:re(i.onFocus,(()=>{x.current&&u.current?.click()}))})})}));He.displayName=We;var Je=e.forwardRef(((e,r)=>{const{__scopeRadioGroup:t,...a}=e,n=Me(t);return s.jsx(Ie,{...n,...a,ref:r})}));Je.displayName="RadioGroupIndicator";var Ke=$e,Xe=He,Qe=Je;const Ye=e.forwardRef((({className:e,...r},t)=>s.jsx(Ke,{className:h("grid gap-2",e),...r,ref:t})));Ye.displayName=Ke.displayName;const Ze=e.forwardRef((({className:e,...r},t)=>s.jsx(Xe,{ref:t,className:h("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...r,children:s.jsx(Qe,{className:"flex items-center justify-center",children:s.jsx(o,{className:"h-2.5 w-2.5 fill-current text-current"})})})));function es({form:e}){return s.jsx(be,{title:"Product Type",children:s.jsx(V,{control:e.control,name:"product_type",render:({field:e})=>s.jsxs(z,{className:"space-y-3",children:[s.jsx(B,{children:s.jsx(Ye,{onValueChange:e.onChange,defaultValue:e.value,className:"flex flex-col space-y-1",children:pe.map((r=>s.jsxs(z,{className:"flex items-center space-x-3 space-y-0",children:[s.jsx(B,{children:s.jsx(Ze,{value:r,checked:e.value===r})}),s.jsx(M,{className:"font-normal cursor-pointer",children:r.charAt(0).toUpperCase()+r.slice(1)})]},r)))})}),s.jsx(G,{})]})})})}function ss({initialData:r,onSubmit:t,onCancel:a,isSubmitting:n}){const{form:i,isEditing:o,handleSubmit:l}=((s,r)=>{const t=T({resolver:U(je),defaultValues:{name:"",description:"",price:0,stock_level:0,category:"",tags:[],image_url:"",weight:void 0,product_type:"physical",dimensions:{height:void 0,width:void 0,depth:void 0}}});return e.useEffect((()=>{if(s){let e={height:void 0,width:void 0,depth:void 0};if(s.dimensions){const r="string"==typeof s.dimensions?JSON.parse(s.dimensions):s.dimensions;e={height:r.height?Number(r.height):void 0,width:r.width?Number(r.width):void 0,depth:r.depth?Number(r.depth):void 0}}const r={name:s.name,description:s.description||"",price:s.price,stock_level:s.stock_level||0,category:s.category||"",tags:Array.isArray(s.tags)?s.tags:[],image_url:s.image_url||"",weight:s.weight||void 0,product_type:s.product_type||"physical",dimensions:e};t.reset(r)}}),[s,t]),{form:t,isEditing:!!s,handleSubmit:async e=>{if(r){const s=await r(e);return s&&t.reset(),s}return!1},formState:t.formState}})(r,t),c="physical"===i.watch("product_type");return s.jsx($,{...i,children:s.jsx("form",{onSubmit:i.handleSubmit(l),className:"space-y-8",children:s.jsx(Se,{leftColumn:s.jsxs(s.Fragment,{children:[s.jsx(ge,{form:i}),s.jsx(es,{form:i}),s.jsx(fe,{form:i}),s.jsx(Ce,{form:i}),c&&s.jsx(ye,{form:i}),s.jsx(ke,{onCancel:a,isSubmitting:n,isEditing:o})]}),rightColumn:s.jsx(Ne,{form:i})})})})}function rs({isOpen:e,onClose:r,onSubmit:t,isSubmitting:a}){return s.jsx(R,{open:e,onOpenChange:e=>!e&&r(),children:s.jsxs(L,{className:"max-w-4xl",children:[s.jsx(I,{className:"pb-4",children:s.jsx(O,{className:"text-3xl font-bold",children:"Add New Product"})}),s.jsx(ss,{onSubmit:t,onCancel:r,isSubmitting:a})]})})}function ts({isOpen:e,onClose:r,onSubmit:t,product:a,isSubmitting:n}){return s.jsx(R,{open:e,onOpenChange:e=>!e&&r(),children:s.jsxs(L,{className:"max-w-4xl",onClick:e=>{e.stopPropagation()},children:[s.jsxs(I,{className:"pb-4",children:[s.jsx(O,{className:"text-3xl font-bold",children:"Edit Product"}),s.jsx(q,{className:"text-base",children:"Make changes to your product and save them when you're done."})]}),a&&s.jsx(ss,{initialData:a,onSubmit:t,onCancel:r,isSubmitting:n})]})})}function as({isOpen:e,onClose:r,onConfirm:t,product:a,isDeleting:n}){return s.jsx(R,{open:e,onOpenChange:e=>!e&&r(),children:s.jsxs(L,{children:[s.jsxs(I,{children:[s.jsx(O,{children:"Delete Product"}),s.jsxs(q,{children:['Are you sure you want to delete "',a?.name,'"? This action cannot be undone.']})]}),s.jsxs(F,{children:[s.jsx(m,{variant:"outline",onClick:r,children:"Cancel"}),s.jsx(m,{variant:"destructive",onClick:async()=>{await t()&&r()},disabled:n,children:n?"Deleting...":"Delete"})]})]})})}Ze.displayName=Xe.displayName;const ns=()=>{const[r,t]=e.useState(""),[a,n]=e.useState(!1),[i,o]=e.useState(!1),[d,u]=e.useState(!1),[h,y]=e.useState(null),{products:v,isLoading:N,isSubmitting:w,addProduct:C,updateProduct:k,deleteProduct:S}=ue(),P=v.filter((e=>e.name.toLowerCase().includes(r.toLowerCase())||e.description&&e.description.toLowerCase().includes(r.toLowerCase())));return s.jsxs("div",{children:[s.jsxs(x,{className:"mb-6",children:[s.jsxs(p,{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[s.jsxs("div",{children:[s.jsx(j,{children:"Store Management"}),s.jsx(g,{children:"Manage products and orders for the BrandJitsu™ store"})]}),s.jsxs("div",{className:"ml-auto flex flex-col sm:flex-row gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsx(l,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 text-gray-400",size:18}),s.jsx(b,{className:"pl-8 w-full",placeholder:"Search products...",value:r,onChange:e=>t(e.target.value)})]}),s.jsxs(m,{onClick:()=>n(!0),children:[s.jsx(c,{size:16,className:"mr-2"})," Add Product"]})]})]}),s.jsx(f,{children:N?s.jsx(he,{}):s.jsx(me,{products:P,onEdit:e=>{const s={...e,tags:Array.isArray(e.tags)?e.tags:[],dimensions:e.dimensions||{height:null,width:null,depth:null}};y(s),o(!0)},onDelete:e=>{y(e),u(!0)}})})]}),s.jsx(rs,{isOpen:a,onClose:()=>n(!1),onSubmit:async e=>{const s=await C(e);return s&&n(!1),s},isSubmitting:w}),s.jsx(ts,{isOpen:i,onClose:()=>o(!1),onSubmit:async e=>
1{if(!h)return!1;const s=await k(h.id,e);return s&&(o(!1),y(null)),s},product:h,isSubmitting:w}),s.jsx(as,{isOpen:d,onClose:()=>u(!1),onConfirm:async()=>{if(!h)return!1;const e=await S(h.id);return e&&(u(!1),y(null)),e},product:h,isDeleting:w})]})};export{ns 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.