1import{r as p,j as e,P as g,s as o,t as d}from"./index-Bh0IneH4.js";import{B as x}from"./button-DudJ4ljj.js";import{I as c}from"./input-OgLmtDQc.js";import{T as j}from"./textarea-B3e7CyyS.js";import{T as v}from"./trash-2-BFgEU9Hr.js";import{S as N}from"./save-CDwHojPn.js";import"./index-D86Nzid0.js";import"./index-B8k91cqS.js";import"./clsx-B-dksMZM.js";import"./utils-0exNfmSl.js";function D(){const[l,n]=p.useState([]),m=async()=>{const{data:s}=await o.from("delivery_profiles").select("*").order("name");n(s??[])};p.useEffect(()=>{m()},[]);const h=async()=>{const{error:s}=await o.from("delivery_profiles").insert({name:"New profile",processing_time:"",carrier:"",cost:0,free_shipping:!1});if(s)return d.error(s.message);m()},u=async s=>{const{error:i}=await o.from("delivery_profiles").update(s).eq("id",s.id);if(i)return d.error(i.message);d.success("Saved")},f=async s=>{confirm("Delete this profile?")&&(await o.from("delivery_profiles").delete().eq("id",s),m())};return e.jsxs("div",{className:"p-4 sm:p-8 max-w-3xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-3xl",children:"Shipping Profiles"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Reusable delivery settings you can assign to products."})]}),e.jsxs(x,{onClick:h,children:[e.jsx(g,{className:"h-4 w-4 mr-2"}),"New profile"]})]}),e.jsxs("div",{className:"space-y-4",children:[l.map((s,i)=>e.jsxs("div",{className:"border border-hairline rounded-lg bg-paper p-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Name"}),e.jsx(c,{value:s.name,onChange:a=>n(l.map((r,t)=>t===i?{...r,name:a.target.value}:r))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Processing time"}),e.jsx(c,{value:s.processing_time??"",onChange:a=>n(l.map((r,t)=>t===i?{...r,processing_time:a.target.value}:r)),placeholder:"e.g. Ships in 2 days"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Carrier"}),e.jsx(c,{value:s.carrier??"",onChange:a=>n(l.map((r,t)=>t===i?{...r,carrier:a.target.value}:r)),placeholder:"DHL, FedEx, UPSâ¦"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Cost ($)"}),e.jsx(c,{type:"number",step:"0.01",value:s.cost,onChange:a=>n(l.map((r,t)=>t===i?{...r,cost:Number(a.target.value)}:r))})]}),e.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:s.free_shipping,onChange:a=>n(l.map((r,t)=>t===i?{...r,free_shipping:a.target.checked}:r))}),"Free shipping"]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Notes"}),e.jsx(j,{value:s.notes??"",onChange:a=>n(l.map((r,t)=>t===i?{...r,notes:a.target.value}:r))})]})]}),e.jsxs("div",{className:"flex justify-between items-center mt-3",children:[e.jsxs(x,{variant:"ghost",size:"sm",onClick:()=>f(s.id),children:[e.jsx(v,{className:"h-3.5 w-3.5 mr-1"}),"Delete"]}),e.jsxs(x,{size:"sm",onClick:()=>u(s),children:[e.jsx(N,{className:"h-3.5 w-3.5 mr-2"}),"Save"]})]})]},s.id)),l.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No profiles yet."})]})]})}export{D as component};
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.