PageSourceSearch

https://somerch.co/assets/admin.ui-v29i5Yri.js

js somerch.co collected 2026-09-24 13:38:51 UTC 13,695 bytes, 1 lines download raw bytes

1import{n as Ve,aT as Ce,eq as Qe,er as Ge,es as Xe,et as Ye,r as u,eu as We,j as e,Q as E,Y as U,F as Je,I as p,B as h,ao as he,X as xe,af as Ze,ag as es,ah as H,ai as C,aj as ss,am as v,d$ as ts,T as K,V as $,ap as f,s as I,o as as,ac as we,ad as ye,a_ as ge,aW as ns,aX as rs,aY as pe,aZ as fe}from"./index-CPbGo_jB.js";import{A as is}from"./AdminLayout-DiU4To-3.js";import{u as ls,a as je,s as os,K as cs,P as ds,D as us,c as ms,S as hs,v as xs,b as ve,d as gs,C as ps}from"./sortable.esm-CVD4NuvK.js";import{A as fs,a as js,b as vs,c as bs,d as Ns,e as Cs,f as ws,g as ys}from"./alert-dialog-CeZlMPDy.js";import{S as Se,a as _e,b as Ie,c as Ae,d as De}from"./select-QsDp1f3R.js";import{A as Ss}from"./arrow-down-dTvXHrMH.js";import{P as _s}from"./pencil-C-44hLAe.js";import{T as Ee}from"./trash-2-DAm8Y-8B.js";import{P as be}from"./plus-9CZtYUjm.js";import{G as Is}from"./grip-vertical-ReX-dkA4.js";import{C as As}from"./CopyButton-DWJQijZr.js";import{U as Ds}from"./upload-9GsQ4eOn.js";import"./layout-dashboard-BZkAP-34.js";import"./gift-B4Zv7BTM.js";import"./calendar-days-DI0yn_kZ.js";import"./clipboard-Brc2SZ2t.js";import"./copy-BezM5OdV.js";function Es({id:t,children:a}){const{attributes:i,listeners:o,setNodeRef:m,transform:d,transition:c,isDragging:n}=gs({id:t});return e.jsxs(H,{ref:m,style:{transform:ps.Transform.toString(d),transition:c},className:n?"relative z-10 bg-muted":void 0,children:[e.jsx(v,{children:e.jsx("button",{type:"button","aria-label":"Drag to reorder",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground active:cursor-grabbing",...i,...o,children:e.jsx(Is,{className:"h-4 w-4"})})}),a]})}function B({section:t,title:a,fields:i=["label","url"],bare:o=!1,externalLangId:m}){const{currentLanguage:d}=Ve(),{data:c}=Ce(),n=c?.find(s=>s.is_default)||null,{data:Le,isLoading:Te}=Qe(t),Fe=Ge(),Re=Xe(),ze=Ye(),[L,T]=u.useState(null),[Q,G]=u.useState(""),[X,Y]=u.useState(""),[W,J]=u.useState(""),[Z,ee]=u.useState(""),[ke,Me]=u.useState(""),[y,se]=u.useState(""),[te,ae]=u.useState(""),[ne,re]=u.useState(""),[ie,le]=u.useState(""),[F,S]=u.useState(!1),[R,z]=u.useState(null),_=m||ke||n?.id||"",b=i.includes("description"),N=i.includes("image_url"),k=(Le||[]).filter(s=>s.section===t),[j,M]=u.useState(k);u.useEffect(()=>{M(k)},[JSON.stringify(k.map(s=>s.id))]);const w=j,O=We(),Oe=ls(je(ds,{activationConstraint:{distance:4}}),je(cs,{coordinateGetter:os})),oe=async s=>{const r=j;M(s);try{await O.mutateAsync(s.map((l,x)=>({id:l.id,sort_order:x}))),f.success("Order updated")}catch{M(r),f.error("Failed to update order")}},Pe=s=>{const{active:r,over:l}=s;if(!l||r.id===l.id)return;const x=j.findIndex(P=>P.id===r.id),g=j.findIndex(P=>P.id===l.id);x<0||g<0||oe(ve(j,x,g))},ce=(s,r)=>{const l=s+r;l<0||l>=j.length||oe(ve(j,s,l))},de=s=>{const r=s.platform_menu_translations||[];return r.find(l=>l.language_id===_)||r.find(l=>l.language_id===n?.id)||r[0]},He=s=>{const r=de(s);T(s.id),G(r?.label||""),Y(r?.url||"#"),J(r?.description||""),ee(r?.image_url||"")},Be=async()=>{if(!(!L||!_))try{await Re.mutateAsync({menu_id:L,language_id:_,label:Q,url:X,description:b?W:void 0,image_url:N?Z:void 0}),f.success("Item updated"),T(null)}catch{f.error("Failed to update")}},Ke=async()=>{if(!y.trim()||!n?.id)return;const s=w.reduce((r,l)=>Math.max(r,l.sort_order||0),-1);try{await Fe.mutateAsync({section:t,sort_order:s+1,label:y,url:te||"#",language_id:n.id,description:b?ne:void 0,image_url:N?ie:void 0}),f.success("Item added"),se(""),ae(""),re(""),le(""),S(!1)}catch{f.error("Failed to add")}},$e=async()=>{if(R){try{await ze.mutateAsync(R),f.success("Item deleted")}catch{f.error("Failed to delete")}z(null)}};if(Te)return e.jsx(E,{children:e.jsx(U,{className:"p-6",children:e.jsx(Je,{className:"h-32 w-full"})})});const qe=2+(b?1:0)+(N?1:0)+1,ue=e.jsxs(e.Fragment,{children:[F&&e.jsxs("div",{className:"flex gap-2 mb-4 flex-wrap",children:[e.jsx(p,{placeholder:"Label",value:y,onChange:s=>se(s.target.value),className:"flex-1 min-w-[120px]"}),e.jsx(p,{placeholder:"URL",value:te,onChange:s=>ae(s.target.value),className:"flex-1 min-w-[120px]"}),b&&e.jsx(p,{placeholder:"Description",value:ne,onChange:s=>re(s.target.value),className:"flex-1 min-w-[120px]"}),N&&e.jsx(p,{placeholder:"Image URL",value:ie,onChange:s=>le(s.target.value),className:"flex-1 min-w-[120px]"}),e.jsx(h,{size:"sm",onClick:Ke,disabled:!y.trim(),children:e.jsx(he,{className:"h-4 w-4"})}),e.jsx(h,{size:"sm",variant:"ghost",onClick:()=>S(!1),children:e.jsx(xe,{className:"h-4 w-4"})})]}
1),e.jsxs(Ze,{children:[e.jsx(es,{children:e.jsxs(H,{children:[e.jsx(C,{className:"w-8"}),e.jsx(C,{children:"Label"}),e.jsx(C,{children:"URL"}),b&&e.jsx(C,{children:"Description"}),N&&e.jsx(C,{children:"Image URL"}),e.jsx(C,{className:"w-40",children:"Actions"})]})}),e.jsx(us,{sensors:Oe,collisionDetection:ms,onDragEnd:Pe,children:e.jsx(hs,{items:w.map(s=>s.id),strategy:xs,children:e.jsxs(ss,{children:[w.length===0&&e.jsx(H,{children:e.jsx(v,{colSpan:qe+1,className:"text-center text-muted-foreground py-8",children:'No items yet. Click "Add" to create one.'})}),w.map((s,r)=>{const l=de(s),x=L===s.id;return e.jsxs(Es,{id:s.id,children:[e.jsx(v,{children:x?e.jsx(p,{value:Q,onChange:g=>G(g.target.value),className:"h-8"}):e.jsx("span",{className:"text-sm",children:l?.label||"—"})}),e.jsx(v,{children:x?e.jsx(p,{value:X,onChange:g=>Y(g.target.value),className:"h-8"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:l?.url||"#"})}),b&&e.jsx(v,{children:x?e.jsx(p,{value:W,onChange:g=>J(g.target.value),className:"h-8"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:l?.description||"—"})}),N&&e.jsx(v,{children:x?e.jsx(p,{value:Z,onChange:g=>ee(g.target.value),className:"h-8"}):e.jsx("span",{className:"text-sm text-muted-foreground truncate max-w-[200px] block",children:l?.image_url||"—"})}),e.jsx(v,{children:e.jsx("div",{className:"flex items-center gap-1",children:x?e.jsxs(e.Fragment,{children:[e.jsx(h,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:Be,children:e.jsx(he,{className:"h-4 w-4"})}),e.jsx(h,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>T(null),children:e.jsx(xe,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(h,{size:"icon",variant:"ghost",className:"h-8 w-8",title:"Move up",disabled:r===0||O.isPending,onClick:()=>ce(r,-1),children:e.jsx(ts,{className:"h-4 w-4"})}),e.jsx(h,{size:"icon",variant:"ghost",className:"h-8 w-8",title:"Move down",disabled:r===w.length-1||O.isPending,onClick:()=>ce(r,1),children:e.jsx(Ss,{className:"h-4 w-4"})}),e.jsx(h,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>He(s),children:e.jsx(_s,{className:"h-4 w-4"})}),e.jsx(h,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive",onClick:()=>z(s.id),children:e.jsx(Ee,{className:"h-4 w-4"})})]})})})]},s.id)})]})})})]})]}),me=e.jsx(fs,{open:!!R,onOpenChange:s=>!s&&z(null),children:e.jsxs(js,{children:[e.jsxs(vs,{children:[e.jsx(bs,{children:"Delete menu item?"}),e.jsx(Ns,{children:"This will permanently delete this menu item and all its translations."})]}),e.jsxs(Cs,{children:[e.jsx(ws,{children:"Cancel"}),e.jsx(ys,{onClick:$e,children:"Delete"})]})]})});return o?e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground",children:a}),e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>S(!F),children:[e.jsx(be,{className:"h-4 w-4 mr-1"})," Add"]})]}),ue,me]}):e.jsxs(e.Fragment,{children:[e.jsxs(E,{children:[e.jsxs(K,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsx($,{className:"text-base font-medium",children:a}),e.jsxs("div",{className:"flex items-center gap-2",children:[c&&c.length>1&&e.jsxs(Se,{value:_,onValueChange:Me,children:[e.jsx(_e,{className:"w-[140px] h-9",children:e.jsx(Ie,{placeholder:"Language"})}),e.jsx(Ae,{children:c.map(s=>e.jsxs(De,{value:s.id,children:[s.name," ",s.is_default?"(default)":""]},s.id))})]}),e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>S(!F),children:[e.jsx(be,{className:"h-4 w-4 mr-1"})," Add"]})]})]}),e.jsx(U,{children:ue})]}),me]})}function Us({title:t,subsections:a}){const{data:i}=Ce(),o=i?.find(n=>n.is_default)||null,[m,d]=u.useState(""),c=m||o?.id||"";return e.jsxs(E,{children:[e.jsxs(K,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsx($,{className:"text-base font-medium",children:t}),i&&i.length>1&&e.jsxs(Se,{value:c,onValueChange:d,children:[e.jsx(_e,{className:"w-[140px] h-9",children:e.jsx(Ie,{placeholder:"Language"})}),e.jsx(Ae,{children:i.map(n=>e.jsxs(De,{value:n.id,children:[n.name," ",n.is_default?"(default)":""]},n.id))})]})]}),e.jsx(U,{className:"space-y-6",children:a.map(n=>e.jsx(B,{section:n.section,title:n.subtitle,fields:n.fields,bare:!0,externalLangId:c},n.section))})]})}const Ue={NAME:"general",HEADER_FOLDER:"ui/header"},A=Ue.NAME,D=Ue.HEADER_FOLDER,Ls=`${D}/`;function Ts(t){return t.toLowerCase().replace(/[^a-z0-9.\-_]+/g,"-").replace(/-+/g,"-").replace(/^-+/,"")||"image"}function Fs(t){if(!t.startsWith(Ls)||t.includes(".."))throw new Error("Invalid header asset path")}function Ne(t){return I.storage.from(A).getPublicUrl(t).data.publicUrl}class Rs{async list(){const{data:a,error:i}=await I.storage.from(A).list(D,{sortBy:{column:"name",order:"asc"}});if(i)throw i;return(a||[]).filter(o=>o.id!==null).map(o=>{const m=`${D}/${o.name}`;return{name:o.name,path:m,url:Ne(m),size:o.metadata?.size??null,updated_at:o.updated_at??null}})}async upload(a){const i=Ts(a.name),o=`${D}/${i}`,{error:m}=await I.storage.from(A).upload(o,a,{upsert:!0,contentType:a.type||void 0});if(m)throw m;return{name:i,path:o,url:Ne(o),size:a.size,updated_at:new Date().toISOString()}}async remove(a){Fs(a);const{error:i}=await I.storage.from(A).remove([a]);if(i)throw i}}const q=new Rs,V="ui-header-assets",zs=()=>as({queryKey:[V],queryFn:()=>q.list()}),ks=()=>{const t=we();return ye({mutationFn:a=>q.upload(a),onSuccess:()=>
1t.invalidateQueries({queryKey:[V]})})},Ms=()=>{const t=we();return ye({mutationFn:a=>q.remove(a),onSuccess:()=>t.invalidateQueries({queryKey:[V]})})};function Os(){const t=u.useRef(null),{data:a=[]}=zs(),i=ks(),o=Ms(),m=async d=>{try{for(const c of Array.from(d)){const n=await i.mutateAsync(c);ge({title:"Uploaded",description:n.name})}}catch(c){const n=c instanceof Error?c.message:"Upload failed";ge({title:"Upload failed",description:n,variant:"destructive"})}};return e.jsxs(E,{children:[e.jsx(K,{children:e.jsx($,{children:"Images and files"})}),e.jsxs(U,{className:"space-y-4",children:[e.jsx("input",{ref:t,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:d=>{const c=Array.from(d.target.files??[]);d.target.value="",c.length&&m(c)}}),e.jsxs(h,{variant:"outline",onClick:()=>t.current?.click(),disabled:i.isPending,children:[e.jsx(Ds,{className:"mr-2 h-4 w-4"}),"Upload file"]}),a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No files yet. Uploads are stored in general/ui/header/ and can be copied into Image URL fields."}):e.jsx("div",{className:"rounded-md border",children:a.map(d=>e.jsxs("div",{className:"flex items-center gap-3 border-b p-3 text-sm last:border-b-0",children:[e.jsx("span",{className:"truncate",children:d.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:d.size?`${Math.round(d.size/1024)} KB`:""}),e.jsxs("div",{className:"ml-auto flex gap-1",children:[e.jsx(As,{text:d.url,size:"icon"}),e.jsx(h,{variant:"ghost",size:"icon","aria-label":"Delete file",disabled:o.isPending,onClick:()=>{o.mutateAsync(d.path)},children:e.jsx(Ee,{className:"h-4 w-4"})})]})]},d.path))})]})]})}const Ps=[{section:"footer_products",title:"Products"},{section:"footer_use_cases",title:"Use Cases"},{section:"footer_services",title:"Services"},{section:"footer_company",title:"Company"},{section:"footer_resources",title:"Resources"},{section:"footer_platform",title:"Platform"},{section:"footer_contact",title:"Contact Info"},{section:"footer_bottom",title:"Bottom Bar Links"}],Hs=[{section:"header_products_featured",title:"Products — Featured Cards",fields:["label","url","image_url"]},{section:"header_collections",title:"Collections — Image Cards",fields:["label","url","image_url"]},{section:"header_use_cases",title:"Use Cases — Image Cards",fields:["label","url","image_url"]}],Bs=[{title:"Services",subsections:[{section:"header_services",subtitle:"Text Items",fields:["label","url","description"]},{section:"header_services_featured",subtitle:"Featured Cards",fields:["label","url","image_url"]}]},{title:"Contacts",subsections:[{section:"header_contacts",subtitle:"Text Items",fields:["label","url","description"]},{section:"header_contacts_featured",subtitle:"Featured Cards",fields:["label","url","image_url"]}]}];function Ks(){return e.jsx(is,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"UI Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage header and footer navigation menus."})]}),e.jsxs(ns,{defaultValue:"footer",className:"w-full",children:[e.jsxs(rs,{children:[e.jsx(pe,{value:"header",children:"Header"}),e.jsx(pe,{value:"footer",children:"Footer"})]}),e.jsxs(fe,{value:"header",className:"space-y-4 mt-6",children:[Hs.map(t=>e.jsx(B,{section:t.section,title:t.title,fields:t.fields},t.section)),Bs.map(t=>e.jsx(Us,{title:t.title,subsections:t.subsections},t.title)),e.jsx(Os,{})]}),e.jsx(fe,{value:"footer",className:"space-y-4 mt-6",children:Ps.map(t=>e.jsx(B,{section:t.section,title:t.title},t.section))})]})]})})}const lt=Ks;export{lt 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.