1import{a as L,b as g,R as A,j as e,H as R,r as O}from"./app-CidIn435.js";import{u as B,a as P,o as T,c as z,s as v}from"./schemas-Cb9p4lyB.js";import{B as D}from"./badge-DWHYuRfk.js";import{B as m}from"./button-CNUD0FKb.js";import{C as p,a as x,b as h,c as j}from"./card-Da6uMMkK.js";import{I as u}from"./input-C_0WdeHr.js";import{L as o}from"./label-koQyr71V.js";import{S as H}from"./switch-CK43Eu2u.js";import{T as k}from"./textarea-0W35tkKT.js";import{A as V}from"./app-layout-CSNwZFpq.js";import{A as q}from"./arrow-left-BhECPDsT.js";import{U as X}from"./select-CWU6B4ov.js";import{X as G}from"./index-DHEKDBYF.js";import{n as J}from"./coerce-aSiEYZy8.js";import"./index-DXqhTTmD.js";import"./createLucideIcon-CZiF_cBb.js";import"./index-Btzy0Aw0.js";import"./separator-Xh5YO49t.js";import"./appearance-dropdown-DIYyV0x1.js";import"./index-DGcDiPy7.js";import"./user-fUBa2Vg-.js";import"./users-WkWildCN.js";import"./trash-2-BE9bgoB9.js";import"./circle-help-dxqbKj-b.js";import"./arrow-right-Da3iXC6V.js";import"./target-CiR434Ws.js";import"./chevron-down-D4J69tJx.js";import"./chevron-left-DNfXFnID.js";import"./loader-circle-uVNhpBx2.js";import"./mail-CqUMyHwb.js";import"./map-pin-DFT9gM8N.js";import"./message-circle-BkjEQv0Q.js";import"./package-CsJAxyqe.js";import"./phone-Ci4gUCQJ.js";import"./search-CGyApBlA.js";import"./zap-DFkc2H0Y.js";import"./circle-check-CEReqvUR.js";const K=T({name:v().min(1,"Category name is required"),type:v().optional(),description:v().optional(),sort_order:J().min(0).default(0),is_active:z().default(!0)});function Ae({category:t}){var C;const{errors:i}=L().props,[n,M]=g.useState(t.image),[s,b]=g.useState(null),[N,w]=g.useState(!1),{register:c,handleSubmit:S,formState:{errors:_},watch:l,setValue:I,setError:y}=B({resolver:P(K),defaultValues:{name:t.name,type:t.type||"",description:t.description||"",sort_order:t.sort_order,is_active:t.is_active}});A.useEffect(()=>
1{i&&Object.keys(i).forEach(r=>{i[r]&&y(r,{type:"server",message:Array.isArray(i[r])?i[r][0]:i[r]})})},[i,y]);const E=r=>{var d;const a=(d=r.target.files)==null?void 0:d[0];a&&b({file:a,preview:URL.createObjectURL(a)})},U=()=>{s&&URL.revokeObjectURL(s.preview),b(null)},F=async r=>{w(!0);const a=new FormData;Object.entries(r).forEach(([d,f])=>{f!=null&&a.append(d,String(f))}),s&&a.append("image",s.file),O.post(route("admin.categories.update",t.id),a,{onFinish:()=>w(!1)})};return e.jsxs(V,{children:[e.jsx(R,{title:"Edit Category"}),e.jsxs("form",{onSubmit:S(F),children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(m,{asChild:!0,variant:"ghost",size:"icon",children:e.jsx("a",{href:route("admin.categories.index"),children:e.jsx(q,{className:"h-5 w-5"})})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Category"}),e.jsxs("p",{className:"text-muted-foreground",children:["Update ",t.name]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(m,{asChild:!0,variant:"outline",children:e.jsx("a",{href:route("admin.categories.index"),children:"Cancel"})}),e.jsx(m,{type:"submit",disabled:N,children:N?"Saving...":"Save Changes"})]})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"space-y-6 lg:col-span-2",children:[e.jsxs(p,{children:[e.jsx(x,{children:e.jsx(h,{children:"Category Information"})}),e.jsxs(j,{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"name",children:"Category Name *"}),e.jsx(u,{id:"name",...c("name"),error:(C=_.name)==null?void 0:C.message})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"type",children:"Type (optional)"}),e.jsx(u,{id:"type",...c("type"),placeholder:"e.g. product, collection"})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"description",children:"Description"}),e.jsx(k,{id:"description",rows:5,...c("description"),placeholder:"Brief description of this category..."})]}),e.jsx("div",{className:"flex items-center gap-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{id:"is_active",checked:l("is_active"),onCheckedChange:r=>I("is_active",r)}),e.jsx(o,{htmlFor:"is_active",children:"Active"})]})})]})]}),e.jsxs(p,{children:[e.jsx(x,{children:e.jsx(h,{children:"Category Image"})}),e.jsx(j,{children:e.jsxs("div",{className:"space-y-4",children:[n&&!s&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:n,alt:"Current",className:"aspect-video w-full rounded-lg border object-cover"}),e.jsx("p",{className:"text-muted-foreground mt-2 text-xs",children:"Current image (upload new to replace)"})]}),e.jsxs("label",{className:"hover:bg-muted/50 flex h-40 w-full cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",children:[e.jsxs("div",{className:"flex flex-col items-center justify-center pt-5 pb-6",children:[e.jsx(X,{className:"text-muted-foreground mb-2 h-8 w-8"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Upload new image (optional)"})]}),e.jsx(u,{type:"file",className:"hidden",accept:"image/*",onChange:E})]}),s&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:s.preview,alt:"New Preview",className:"aspect-video w-full rounded-lg border object-cover"}),e.jsx(m,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2",onClick:U,children:e.jsx(G,{className:"h-4 w-4"})})]})]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(p,{children:[e.jsx(x,{children:e.jsx(h,{children:"Organization"})}),e.jsx(j,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(o,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(u,{id:"sort_order",type:"number",...c("sort_order")})]})})]}),e.jsxs(p,{children:[e.jsx(x,{children:e.jsx(h,{children:"Preview"})}),e.jsxs(j,{className:"space-y-3",children:[(s?s.preview:n)&&e.jsx("img",{src:s?s.preview:n,alt:"Preview",className:"aspect-video w-full rounded-lg object-cover"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold",children:l("name")}
1),l("type")&&e.jsx(D,{variant:"outline",className:"mt-1",children:l("type")})]})]})]})]})]})]})]})}export{Ae 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.