lms/public/build/assets/footer-64eQ-8Kk.js
2025-12-15 12:26:23 +01:00

2 lines
16 KiB
JavaScript

import{r as I,b as le,j as e,ao as $,cK as U,bu as R,cL as q,e as N,c0 as ie,bm as C,x as y,T as D,aj as S,cM as re,cN as ce,cO as ne,cP as oe,cQ as de,cR as me,u as Q,L as B,D as he,b8 as xe}from"./vendor-BKmmeuxg.js";import{B as r}from"./button-BpNwv2aE.js";import{C as F,b as O,a as ue,c as pe,d as je}from"./card-D9_SJYq6.js";import{S as ve}from"./separator-_3LZ_wAA.js";import{D as fe}from"./data-sort-modal-B2Yf_crJ.js";import{D as T}from"./delete-modal-D1GJlb1P.js";import{S as V}from"./switch-Db09nqXX.js";import{T as ge}from"./tabs-D0Mbb5M5.js";import{D as Ne,b as ye,c as be,d as we,g as Ce,e as ke}from"./dialog-B2gN9MvT.js";import{I as v}from"./input-DM0goJrn.js";import{L as j}from"./label-HmIcv5Yx.js";import{S as H,a as G,b as Y,c as K,d as P}from"./select-CD9o3HN1.js";import{T as Ae,a as k,b as A}from"./tabs-Ifouhv9A.js";import{A as Ie}from"./app-logo-CmnEIwal.js";import{B as Se}from"./badge-AQfLLMpR.js";import"./index-WW_1X1qx.js";import"./utils-DxSsnXxD.js";import"./scroll-area-C8HGru-R.js";import"./switch-DFFqeub-.js";const _e=({footer:f})=>{const c=f.footer_items,[u,d]=I.useState("list"),[m,p]=I.useState(null),[h,o]=I.useState(!1),{data:a,setData:i,post:g,put:b,processing:M}=le({type:"list",slug:"",title:"",items:[],active:!0,sort:0}),x=c.filter(s=>s.type===u),X=s=>{p(null),i({type:s,slug:"",title:"",items:[],active:!0,sort:Math.max(...c.map(t=>t.sort),0)+1}),o(!0)},w=s=>{p(s),i({type:s.type,slug:s.slug,title:s.title,active:s.active,items:Array.isArray(s.items)?s.items:[],sort:s.sort}),o(!0)},J=s=>{s.preventDefault(),m?b(`/dashboard/settings/footer-items/${m.id}`,{onSuccess:()=>{o(!1),N.reload({only:["footer"]})}}):g(`/dashboard/settings/footer/${f.id}/items`,{onSuccess:()=>{o(!1),N.reload({only:["footer"]})}})},W=()=>{i(s=>({...s,items:[...s.items,{title:"",url:""}]}))},z=(s,t,l)=>{const n=[...a.items];n[s]={...n[s],[t]:l},i(L=>({...L,items:n}))},Z=s=>{const t=a.items.filter((l,n)=>n!==s);i(l=>({...l,items:t}))},ee=()=>{i(s=>({...s,items:[...s.items,{title:"",url:"",icon:"facebook"}]}))},_=(s,t,l)=>{const n=[...a.items];n[s]={...n[s],[t]:l},i(L=>({...L,items:n}))},se=()=>{i(s=>({...s,items:[...s.items,{image:""}]}))},te=(s,t)=>{const l=[...a.items];l[s]={image:t},i(n=>({...n,items:l}))},E=s=>{const t=a.items.filter((l,n)=>n!==s);i(l=>({...l,items:t}))},ae=[{value:"facebook",label:"Facebook",icon:e.jsx(re,{className:"h-4 w-4"})},{value:"twitter",label:"Twitter",icon:e.jsx(ce,{className:"h-4 w-4"})},{value:"instagram",label:"Instagram",icon:e.jsx(ne,{className:"h-4 w-4"})},{value:"linkedin",label:"LinkedIn",icon:e.jsx(oe,{className:"h-4 w-4"})},{value:"github",label:"GitHub",icon:e.jsx(de,{className:"h-4 w-4"})},{value:"youtube",label:"YouTube",icon:e.jsx(me,{className:"h-4 w-4"})}];return e.jsxs("div",{className:"p-4 sm:p-6",children:[e.jsxs(ge,{value:u,onValueChange:d,children:[e.jsxs("div",{className:"mb-6 flex flex-col justify-between gap-6 md:flex-row md:items-center",children:[e.jsxs(Ae,{className:"grid h-auto grid-cols-2 sm:h-10 sm:grid-cols-4",children:[e.jsxs(k,{value:"list",className:"flex h-8 cursor-pointer items-center gap-2",children:[e.jsx($,{className:"h-4 w-4"}),"List (",c.filter(s=>s.type==="list").length,")"]}),e.jsxs(k,{value:"social_media",className:"flex h-8 cursor-pointer items-center gap-2",children:[e.jsx(U,{className:"h-4 w-4"}),"Social (",c.filter(s=>s.type==="social_media").length,")"]}),e.jsxs(k,{value:"payment_methods",className:"flex h-8 cursor-pointer items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"Payment (",c.filter(s=>s.type==="payment_methods").length,")"]}),e.jsxs(k,{value:"copyright",className:"flex h-8 cursor-pointer items-center gap-2",children:[e.jsx(q,{className:"h-4 w-4"}),"Copyright (",c.filter(s=>s.type==="copyright").length,")"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{title:"Footer Items",data:x,handler:e.jsxs(r,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(ie,{className:"h-4 w-4"}),"Reorder"]}),onOrderChange:(s,t)=>{N.post(route("settings.footer.items.reorder"),{sortedData:s},{preserveScroll:!0,onSuccess:()=>t&&t(!1)})},renderContent:s=>e.jsxs(F,{className:"flex w-full items-center justify-between px-4 py-3",children:[e.jsx("p",{children:s.title}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(j,{htmlFor:"active",children:"Active"}),e.jsx(V,{id:"active",defaultChecked:s.active,onCheckedChange:t=>{N.put(`/dashboard/settings/navbar-items/${s.id}`,{...s,active:t})}})]})]})}),e.jsxs(r,{onClick:()=>X(u),className:"flex items-center gap-2",children:[e.jsx(C,{className:"h-4 w-4"}),"Add ",e.jsx("span",{className:"capitalize",children:u.replace("_"," ")})]})]})]}),e.jsx(A,{value:"list",className:"space-y-4",children:x.length>0?e.jsx("div",{className:"space-y-4",children:x.map(s=>e.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($,{className:"h-4 w-4"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:s.title}),e.jsx("div",{className:"text-muted-foreground text-sm",children:s.items&&Array.isArray(s.items)?`${s.items.length} items`:"0 items"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(r,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:()=>w(s),children:e.jsx(y,{className:"h-3 w-3"})}),e.jsx(T,{routePath:route("settings.footer.items.destroy",s.id),actionComponent:e.jsx(r,{variant:"ghost",className:"bg-destructive/8 hover:bg-destructive/6 h-8 w-8",children:e.jsx(D,{className:"text-destructive h-3 w-3"})})})]})]}),s.items&&Array.isArray(s.items)&&e.jsx("div",{className:"mt-2 ml-8 space-y-1",children:s.items.map((t,l)=>e.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t.title}),t.url&&e.jsxs("span",{className:"text-muted-foreground/60",children:["(",t.url,")"]})]},l))})]},s.id))}):e.jsx("div",{className:"text-muted-foreground py-8 text-center",children:'No list items found. Click "Add List" to create one.'})}),e.jsx(A,{value:"social_media",className:"space-y-4",children:x.length>0?e.jsx("div",{className:"space-y-4",children:x.map(s=>e.jsx("div",{className:"bg-muted rounded-lg p-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(U,{className:"h-4 w-4"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:s.title}),e.jsx("div",{className:"text-muted-foreground text-sm",children:s.items&&Array.isArray(s.items)?`${s.items.length} social links`:"0 social links"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(r,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:()=>w(s),children:e.jsx(y,{className:"h-3 w-3"})}),e.jsx(T,{routePath:route("settings.footer.items.destroy",s.id),actionComponent:e.jsx(r,{variant:"ghost",className:"bg-destructive/8 hover:bg-destructive/6 h-8 w-8",children:e.jsx(D,{className:"text-destructive h-3 w-3"})})})]})]})},s.id))}):e.jsx("div",{className:"text-muted-foreground py-8 text-center",children:'No social media sections found. Click "Add Social Media" to create one.'})}),e.jsx(A,{value:"payment_methods",className:"space-y-4",children:x.length>0?e.jsx("div",{className:"space-y-4",children:x.map(s=>e.jsx("div",{className:"bg-muted rounded-lg p-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(R,{className:"h-4 w-4"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:s.title}),e.jsx("div",{className:"text-muted-foreground text-sm",children:s.items&&Array.isArray(s.items)?`${s.items.length} payment methods`:"0 payment methods"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(r,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:()=>w(s),children:e.jsx(y,{className:"h-3 w-3"})}),e.jsx(T,{routePath:route("settings.footer.items.destroy",s.id),actionComponent:e.jsx(r,{variant:"ghost",className:"bg-destructive/8 hover:bg-destructive/6 h-8 w-8",children:e.jsx(D,{className:"text-destructive h-3 w-3"})})})]})]})},s.id))}):e.jsx("div",{className:"text-muted-foreground py-8 text-center",children:'No payment methods found. Click "Add Payment Methods" to create one.'})}),e.jsx(A,{value:"copyright",className:"space-y-4",children:x.length>0?e.jsx("div",{className:"space-y-4",children:x.map(s=>e.jsx("div",{className:"bg-muted rounded-lg p-3",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(q,{className:"h-4 w-4"}),e.jsx("div",{className:"flex-1",children:e.jsx("div",{className:"font-medium",children:s.title})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(r,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:()=>w(s),children:e.jsx(y,{className:"h-3 w-3"})}),e.jsx(j,{htmlFor:"active",children:"Active"}),e.jsx(V,{id:"active",checked:s.active,onCheckedChange:t=>{N.put(`/dashboard/settings/footer-items/${s.id}`,{...s,active:t})}})]})]})},s.id))}):e.jsx("div",{className:"text-muted-foreground py-8 text-center",children:'No copyright text found. Click "Add Copyright" to create one.'})})]}),e.jsx(Ne,{open:h,onOpenChange:o,children:e.jsxs(ye,{className:"max-h-[90vh] max-w-3xl overflow-y-auto",children:[e.jsxs(be,{children:[e.jsxs(we,{children:[m?"Edit":"Create"," ",a.type.charAt(0).toUpperCase()+a.type.slice(1).replace("_"," ")," Item"]}),e.jsx(Ce,{children:m?"Update the details of this footer item.":"Add a new footer item to your footer."})]}),e.jsxs("form",{onSubmit:J,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(j,{children:"Status"}),e.jsxs(H,{value:a.active?"Active":"Inactive",onValueChange:s=>i(t=>({...t,active:s==="Active"})),children:[e.jsx(G,{children:e.jsx(Y,{placeholder:"Select status"})}),e.jsxs(K,{children:[e.jsx(P,{value:"Active",children:"Active"}),e.jsx(P,{value:"Inactive",children:"Inactive"})]})]})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"title",children:"Title"}),e.jsx(v,{id:"title",value:a.title,onChange:s=>i(t=>({...t,title:s.target.value})),placeholder:"Enter title",required:!0})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"slug",children:"Slug"}),e.jsx(v,{id:"slug",value:a.slug,onChange:s=>i(t=>({...t,slug:s.target.value})),placeholder:"Enter unique slug",required:!0})]}),a.type==="list"&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx(j,{children:"List Items"}),e.jsxs(r,{type:"button",variant:"outline",size:"sm",onClick:W,children:[e.jsx(C,{className:"mr-1 h-3 w-3"}),"Add Item"]})]}),e.jsx("div",{className:"max-h-48 space-y-2 overflow-y-auto",children:a.items.map((s,t)=>e.jsxs("div",{className:"flex items-center gap-2 rounded border p-2",children:[e.jsx(v,{value:s.title||"",onChange:l=>z(t,"title",l.target.value),placeholder:"Title",className:"flex-1"}),e.jsx(v,{value:s.url||"",onChange:l=>z(t,"url",l.target.value),placeholder:"URL (optional)",className:"flex-1"}),e.jsx(r,{type:"button",variant:"ghost",size:"sm",onClick:()=>Z(t),children:e.jsx(S,{className:"h-3 w-3"})})]},t))})]}),a.type==="social_media"&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx(j,{children:"Social Media Links"}),e.jsxs(r,{type:"button",variant:"outline",size:"sm",onClick:ee,children:[e.jsx(C,{className:"mr-1 h-3 w-3"}),"Add Social Link"]})]}),e.jsx("div",{className:"max-h-48 space-y-2 overflow-y-auto",children:a.items.map((s,t)=>e.jsxs("div",{className:"flex items-center gap-2 rounded border p-2",children:[e.jsx(v,{value:s.title||"",onChange:l=>_(t,"title",l.target.value),placeholder:"Platform name",className:"flex-1"}),e.jsx(v,{value:s.url||"",onChange:l=>_(t,"url",l.target.value),placeholder:"Profile URL",className:"flex-1"}),e.jsxs(H,{value:s.icon||"facebook",onValueChange:l=>_(t,"icon",l),children:[e.jsx(G,{className:"w-32",children:e.jsx(Y,{})}),e.jsx(K,{children:ae.map(l=>e.jsx(P,{value:l.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[l.icon,l.label]})},l.value))})]}),e.jsx(r,{type:"button",variant:"ghost",size:"sm",onClick:()=>E(t),children:e.jsx(S,{className:"h-3 w-3"})})]},t))})]}),a.type==="payment_methods"&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx(j,{children:"Payment Method Images"}),e.jsxs(r,{type:"button",variant:"outline",size:"sm",onClick:se,children:[e.jsx(C,{className:"mr-1 h-3 w-3"}),"Add Payment Method"]})]}),e.jsx("div",{className:"max-h-48 space-y-2 overflow-y-auto",children:a.items.map((s,t)=>e.jsxs("div",{className:"flex items-center gap-2 rounded border p-2",children:[e.jsx(v,{value:s.image||"",onChange:l=>te(t,l.target.value),placeholder:"Image URL or path",className:"flex-1"}),e.jsx(r,{type:"button",variant:"ghost",size:"sm",onClick:()=>E(t),children:e.jsx(S,{className:"h-3 w-3"})})]},t))})]}),e.jsxs(ke,{children:[e.jsx(r,{type:"button",variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(r,{type:"submit",disabled:M,children:M?"Saving...":m?"Update":"Create"})]})]})]})})]})},Le=()=>{const{props:f}=Q(),{footer:c,system:u}=f,d=c.footer_items.sort((a,i)=>a.sort-i.sort),m=d.filter(a=>a.type==="list"&&a.active),p=d.find(a=>a.type==="copyright"&&a.active),h=d.find(a=>a.type==="social_media"&&a.active),o=d.find(a=>a.type==="payment_methods"&&a.active);return e.jsxs("div",{className:"overflow-hidden bg-[rgba(255,222,99,0.06)]",children:[e.jsxs("div",{className:"space-y-9 px-4 pt-[60px] pb-5",children:[e.jsxs("div",{className:"flex flex-col items-start justify-between gap-10 md:flex-row",children:[e.jsxs("div",{className:"w-full space-y-5 md:max-w-[300px]",children:[e.jsx("div",{children:e.jsx(B,{href:"/",children:e.jsx(Ie,{})})}),e.jsx("p",{className:"text-muted-foreground text-sm",children:u.fields.description}),h&&e.jsx("div",{className:"flex flex-wrap gap-3",children:h.items&&Array.isArray(h.items)&&h.items.map((a,i)=>e.jsx(r,{size:"icon",variant:"ghost",className:"bg-muted hover:bg-primary hover:text-primary-foreground text-muted-foreground rounded-full transition-colors",asChild:!0,children:e.jsxs("a",{href:a.url,target:"_blank",children:[e.jsx(he,{name:a.icon,className:"h-5 w-5"}),e.jsx("span",{className:"sr-only",children:a.title})]})},i))})]}),e.jsx("div",{className:"flex w-full flex-col justify-between gap-10 md:max-w-[640px] md:flex-row",children:m.map(a=>{var i;return e.jsxs("div",{className:"relative w-full",children:[e.jsx("p",{className:"mb-3 text-lg font-semibold",children:a.title}),e.jsx("ul",{className:"text-muted-foreground flex flex-col gap-2 text-sm",children:(i=a.items)==null?void 0:i.map((g,b)=>a.slug==="address"?e.jsx("li",{children:g.title},`item-${b}`):e.jsx("li",{children:e.jsx(B,{href:g.url,children:g.title})},`item-${b}`))})]})})})]}),o&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-lg font-semibold",children:o.title}),e.jsx("div",{className:"flex flex-wrap gap-3",children:o.items&&Array.isArray(o.items)&&o.items.map((a,i)=>e.jsx("div",{className:"flex h-7 items-center justify-center gap-5 md:justify-start",children:a.image?e.jsx("img",{src:a.image,alt:`Payment method ${i+1}`,className:"h-full w-auto object-contain"}):e.jsxs(Se,{variant:"outline",className:"text-xs",children:["Payment ",i+1]})},i))})]})]}),p&&e.jsx("div",{className:"px-6 py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:p.title})})]})},Xe=()=>{const{props:f}=Q(),{footer:c,translate:u}=f,{settings:d,button:m}=u,[p,h]=I.useState(!1);return c?e.jsxs(F,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(pe,{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-5 w-5"}),d.live_footer_preview]}),e.jsxs(je,{className:"hidden sm:block",children:[d.interactive_preview," ",c.title," (",c.slug,")"]})]}),p?e.jsxs(r,{onClick:()=>h(!1),variant:"outline",children:[e.jsx(S,{className:"mr-2 h-4 w-4"}),m.close]}):e.jsxs(r,{onClick:()=>h(!0),className:"flex items-center gap-2",children:[e.jsx(y,{className:"h-4 w-4"}),m.edit_footer]})]})}),e.jsx(ve,{}),p?e.jsx(_e,{footer:c}):e.jsx(O,{className:"p-5",children:e.jsx(Le,{})})]}):e.jsx(F,{children:e.jsx(O,{className:"flex items-center justify-center py-8",children:e.jsx("p",{className:"text-muted-foreground",children:d.footer_config_not_found})})})};export{Xe as default};