lms/public/build/assets/navbar-CNCIbVoX.js
2025-12-15 12:26:23 +01:00

2 lines
13 KiB
JavaScript

import{r as u,b as Q,j as e,aT as F,ap as S,aD as L,e as N,c0 as W,bm as E,x as D,T as U,aj as A,L as y,p as Y,u as Z,b8 as ee}from"./vendor-BKmmeuxg.js";import{B as l}from"./button-BpNwv2aE.js";import{C as V,a as se,c as ae,d as te,b as re}from"./card-D9_SJYq6.js";import{S as le}from"./separator-_3LZ_wAA.js";import{D as ie}from"./data-sort-modal-B2Yf_crJ.js";import{D as M}from"./delete-modal-D1GJlb1P.js";import{S as _}from"./switch-Db09nqXX.js";import{T as ne}from"./tabs-D0Mbb5M5.js";import{D as ce,b as de,c as oe,d as me,g as he,e as xe}from"./dialog-B2gN9MvT.js";import{I as b}from"./input-DM0goJrn.js";import{L as x}from"./label-HmIcv5Yx.js";import{S as P,a as R,b as z,c as q,d as f}from"./select-CD9o3HN1.js";import{T as ue,a as w,b as C}from"./tabs-Ifouhv9A.js";import{A as pe}from"./app-logo-CmnEIwal.js";import{A as je}from"./appearance-D2z3xcjR.js";import{N as ve}from"./notification-CYMPYbAP.js";import{P as ge}from"./profile-toggle-CvHrFE0q.js";import{D as fe,a as Ne,b as ye,c as be}from"./dropdown-menu-DO-po5c1.js";import{S as we}from"./scroll-area-C8HGru-R.js";import"./index-WW_1X1qx.js";import"./utils-DxSsnXxD.js";import"./switch-DFFqeub-.js";import"./app-BytVvUs_.js";/* empty css */import"./popover-B4kBsMuI.js";import"./avatar-j28afJTV.js";import"./index.browser-OxPLOBIU.js";const Ce=({navbar:g})=>{const i=g.navbar_items,[c,m]=u.useState("url"),[d,p]=u.useState(null),[h,a]=u.useState(!1),{data:r,setData:n,post:$,put:B,processing:I}=Q({type:"url",slug:"",title:"",value:"",items:[],active:!0,sort:0}),j=i.filter(s=>s.type===c),H=s=>{p(null),n({type:s,slug:"",title:"",value:"",items:[],active:!0,sort:Math.max(...i.map(t=>t.sort),0)+1}),a(!0)},T=s=>{p(s),n({type:s.type,slug:s.slug,title:s.title,value:s.value||"",active:s.active,items:Array.isArray(s.items)?s.items.map(t=>({title:t.title||"",url:t.url||""})):[],sort:s.sort}),a(!0)},X=s=>{s.preventDefault(),d?B(`/dashboard/settings/navbar-items/${d.id}`,{onSuccess:()=>{a(!1),N.reload({only:["navbar"]})}}):$(`/dashboard/settings/navbar/${g.id}/items`,{onSuccess:()=>{a(!1),N.reload({only:["navbar"]})}})},G=()=>{n(s=>({...s,items:[...s.items,{title:"",url:""}]}))},k=(s,t,o)=>{const v=[...r.items];v[s]={...v[s],[t]:o},n(K=>({...K,items:v}))},J=s=>{const t=r.items.filter((o,v)=>v!==s);n(o=>({...o,items:t}))};return e.jsxs("div",{className:"p-4 sm:p-6",children:[e.jsxs(ne,{value:c,onValueChange:m,children:[e.jsxs("div",{className:"mb-6 flex flex-col justify-between gap-6 md:flex-row md:items-center",children:[e.jsxs(ue,{className:"grid h-auto grid-cols-2 sm:h-10 sm:grid-cols-4",children:[e.jsxs(w,{value:"url",className:"flex h-8 cursor-pointer items-center gap-2",children:[e.jsx(F,{className:"h-4 w-4"}),"URL Items (",i.filter(s=>s.type==="url").length,")"]}),e.jsxs(w,{value:"dropdown",className:"flex h-8 cursor-pointer items-center gap-2",children:[e.jsx(S,{className:"h-4 w-4"}),"Dropdowns (",i.filter(s=>s.type==="dropdown").length,")"]}),e.jsxs(w,{value:"action",className:"flex h-8 cursor-pointer items-center gap-2",children:[e.jsx(L,{className:"h-4 w-4"}),"Actions (",i.filter(s=>s.type==="action").length,")"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{title:"Navbar Items",data:j,handler:e.jsxs(l,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(W,{className:"h-4 w-4"}),"Reorder"]}),onOrderChange:(s,t)=>{N.post(route("settings.navbar.items.reorder"),{sortedData:s},{preserveScroll:!0,onSuccess:()=>t&&t(!1)})},renderContent:s=>e.jsxs(V,{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(x,{htmlFor:"active",children:"Active"}),e.jsx(_,{id:"active",defaultChecked:s.active,onCheckedChange:t=>{N.put(`/dashboard/settings/navbar-items/${s.id}`,{...s,active:t})}})]})]})}),c!=="action"&&e.jsxs(l,{onClick:()=>H(c),className:"flex items-center gap-2",children:[e.jsx(E,{className:"h-4 w-4"}),"Add ",e.jsx("span",{className:"capitalize",children:c})]})]})]}),e.jsx(C,{value:"url",className:"space-y-4",children:j.length>0?e.jsx("div",{className:"space-y-4",children:j.map(s=>e.jsxs("div",{className:"bg-muted flex items-center gap-3 rounded-lg p-3",children:[e.jsx(F,{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-sm text-gray-600",children:s.value})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(l,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:()=>T(s),children:e.jsx(D,{className:"h-3 w-3"})}),e.jsx(M,{routePath:route("settings.navbar.items.destroy",s.id),actionComponent:e.jsx(l,{variant:"ghost",className:"bg-destructive/8 hover:bg-destructive/6 h-8 w-8",children:e.jsx(U,{className:"text-destructive h-3 w-3"})})})]})]},s.id))}):e.jsx("div",{className:"py-8 text-center text-gray-500",children:'No URL items found. Click "Add URL Item" to create one.'})}),e.jsx(C,{value:"dropdown",className:"space-y-4",children:j.length>0?e.jsx("div",{className:"space-y-4",children:j.map((s,t)=>e.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(S,{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 gap-2",children:[e.jsx(l,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:()=>T(s),children:e.jsx(D,{className:"h-3 w-3"})}),e.jsx(M,{routePath:route("settings.navbar.items.destroy",s.id),actionComponent:e.jsx(l,{variant:"ghost",className:"bg-destructive/8 hover:bg-destructive/6 h-8 w-8",children:e.jsx(U,{className:"text-destructive h-3 w-3"})})})]})]}),s.items&&Array.isArray(s.items)&&e.jsx("div",{className:"ml-8 space-y-1",children:s.items.map((o,v)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:o.title}),e.jsxs("span",{className:"text-gray-400",children:["(",o.url,")"]})]},v))})]},s.id))}):e.jsx("div",{className:"py-8 text-center text-gray-500",children:'No dropdown items found. Click "Add Dropdown" to create one.'})}),e.jsx(C,{value:"action",className:"space-y-4",children:j.length>0?e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:j.map(s=>e.jsxs("div",{className:"bg-muted flex items-center justify-between gap-3 rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(L,{className:"h-4 w-4"}),e.jsx("p",{className:"text-sm font-medium",children:s.title})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(x,{htmlFor:"airplane-mode",children:"Active"}),e.jsx(_,{id:"airplane-mode",checked:s.active,onCheckedChange:t=>{N.put(`/dashboard/settings/navbar-items/${s.id}`,{...s,active:t})}})]})]},s.id))}):e.jsx("div",{className:"py-8 text-center text-gray-500",children:'No action items found. Click "Add Action Item" to create one.'})})]}),e.jsx(ce,{open:h,onOpenChange:a,children:e.jsxs(de,{className:"max-w-2xl",children:[e.jsxs(oe,{children:[e.jsxs(me,{children:[d?"Edit":"Create"," ",r.type.charAt(0).toUpperCase()+r.type.slice(1)," Item"]}),e.jsx(he,{children:d?"Update the details of this navbar item.":"Add a new navbar item to your navigation."})]}),e.jsxs("form",{onSubmit:X,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(x,{children:"Status"}),e.jsxs(P,{value:r.active?"Active":"Deactive",onValueChange:s=>n(t=>({...t,active:s==="Active"})),children:[e.jsx(R,{children:e.jsx(z,{placeholder:"Select status"})}),e.jsxs(q,{children:[e.jsx(f,{value:"Active",children:"Active"}),e.jsx(f,{value:"Deactive",children:"Deactive"})]})]})]}),e.jsxs("div",{children:[e.jsx(x,{htmlFor:"title",children:"Title"}),e.jsx(b,{id:"title",value:r.title,onChange:s=>n(t=>({...t,title:s.target.value})),placeholder:"Enter title",required:!0})]}),e.jsxs("div",{children:[e.jsx(x,{htmlFor:"slug",children:"Slug"}),e.jsx(b,{id:"slug",value:r.slug,onChange:s=>n(t=>({...t,slug:s.target.value})),placeholder:"Enter unique slug",required:!0})]}),r.type==="url"&&e.jsxs("div",{children:[e.jsx(x,{htmlFor:"value",children:"URL"}),e.jsx(b,{id:"value",value:r.value,onChange:s=>n(t=>({...t,value:s.target.value})),placeholder:"Enter URL (e.g., /courses, https://example.com)",required:!0})]}),r.type==="dropdown"&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx(x,{children:"Dropdown Items"}),e.jsxs(l,{type:"button",variant:"outline",size:"sm",onClick:G,children:[e.jsx(E,{className:"mr-1 h-3 w-3"}),"Add Item"]})]}),e.jsx("div",{className:"max-h-48 space-y-2 overflow-y-auto",children:r.items.map((s,t)=>e.jsxs("div",{className:"flex items-center gap-2 rounded border p-2",children:[e.jsx(b,{value:s.title,onChange:o=>k(t,"title",o.target.value),placeholder:"Title",className:"flex-1"}),e.jsx(b,{value:s.url,onChange:o=>k(t,"url",o.target.value),placeholder:"URL",className:"flex-1"}),e.jsx(l,{type:"button",variant:"ghost",size:"sm",onClick:()=>J(t),children:e.jsx(A,{className:"h-3 w-3"})})]},t))})]}),r.type==="action"&&e.jsxs("div",{children:[e.jsx(x,{htmlFor:"action-type",children:"Action Type"}),e.jsxs(P,{value:r.slug,onValueChange:s=>n(t=>({...t,slug:s})),children:[e.jsx(R,{children:e.jsx(z,{placeholder:"Select action type"})}),e.jsxs(q,{children:[e.jsx(f,{value:"theme",children:"Theme Toggle"}),e.jsx(f,{value:"search",children:"Search"}),e.jsx(f,{value:"notification",children:"Notifications"}),e.jsx(f,{value:"profile",children:"User Profile"})]})]})]}),e.jsxs(xe,{children:[e.jsx(l,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(l,{type:"submit",disabled:I,children:I?"Saving...":d?"Update":"Create"})]})]})]})})]})},O=({auth:g,navbar:i})=>{const[c,m]=u.useState(!1),d=a=>{if(!a.active)return null;switch(a.type){case"url":return e.jsx(y,{href:a.value||"",className:"py-1 text-sm font-normal",children:a.title},a.id);case"dropdown":return e.jsxs(fe,{children:[e.jsxs(Ne,{className:"flex cursor-pointer items-center py-1 text-sm",children:[a.title,e.jsx(S,{className:"ml-1 h-4 w-4"})]}),e.jsx(ye,{align:"start",className:"min-w-20",children:a.items&&Array.isArray(a.items)&&a.items.map((r,n)=>e.jsx(be,{asChild:!0,className:"cursor-pointer px-5",children:e.jsx(y,{href:r.url||"",children:r.title})},n))})]},a.id);default:return null}},p=a=>{if(a.type==="action"&&a.active)switch(a.slug){case"theme":return e.jsx(je,{});case"notification":return e.jsx(ve,{});case"profile":return e.jsx(ge,{});default:return null}return null},h=i.navbar_items.sort((a,r)=>a.sort-r.sort);return e.jsxs("div",{className:"border-border bg-background rounded-lg border px-4 transition-colors",children:[e.jsxs("div",{className:"flex h-16 items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-10",children:[e.jsx(y,{href:"/",children:e.jsx(pe,{})}),e.jsx("div",{className:"hidden gap-4 md:flex md:items-center",children:h.map(a=>e.jsx(u.Fragment,{children:d(a)},a.id))})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[g?h.map(a=>e.jsx(u.Fragment,{children:p(a)},a.id)):e.jsxs(e.Fragment,{children:[e.jsx(l,{asChild:!0,variant:"outline",className:"h-auto rounded-sm px-5 py-2.5 shadow-none",children:e.jsx(y,{href:route("register"),children:"Sign Up"})}),e.jsx(l,{asChild:!0,className:"h-auto rounded-sm px-5 py-2.5 shadow-none",children:e.jsx(y,{href:route("login"),children:"Log In"})})]}),e.jsx(l,{size:"icon",variant:"secondary",className:"md:hidden",onClick:()=>m(!c),children:c?e.jsx(A,{className:"h-6 w-6"}):e.jsx(Y,{className:"h-6 w-6"})})]})]}),c&&e.jsx(we,{className:"animate-fade-in h-[calc(100vh-72px)] border-t md:hidden",children:e.jsx("div",{className:"flex flex-col space-y-4 py-4",children:h.map(a=>e.jsx(u.Fragment,{children:d(a)},a.id))})})]})},Ye=()=>{const{props:g}=Z(),{navbar:i,translate:c}=g,{settings:m,button:d}=c,[p,h]=u.useState(!1);return e.jsxs(V,{children:[e.jsx(se,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(ae,{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"h-5 w-5"}),m.live_navbar_preview]}),e.jsxs(te,{className:"hidden sm:block",children:[m.interactive_preview," ",i.title," (",i.slug,")"]})]}),p?e.jsxs(l,{onClick:()=>h(!1),variant:"outline",children:[e.jsx(A,{className:"mr-2 h-4 w-4"}),d.close]}):e.jsxs(l,{onClick:()=>h(!0),className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-4 w-4"}),d.edit_navbar]})]})}),e.jsx(le,{}),p?e.jsx(Ce,{navbar:i}):e.jsxs(re,{className:"space-y-6 p-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground mb-1 text-sm",children:m.before_login}),e.jsx(O,{auth:!1,navbar:i})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground mb-1 text-sm",children:m.after_login}),e.jsx(O,{auth:!0,navbar:i})]})]})]})};export{Ye as default};