PageSourceSearch

https://forksy.ai/assets/index-B5PTbBEd10.js

js forksy.ai collected 2026-10-05 13:36:47 UTC 4,745 bytes, 1 lines download raw bytes

1import{u as U,j as s,i as V,ai as Y,B as G,J as W}from"./ui-vendor-CYOVLxNwXU.js";import{a as X,u as Z,a6 as ee,n as B,q as j,a9 as $,aa as se,B as te,d as H,h as O,E as F}from"./index-CUBBvIcp0x.js";import{a as o}from"./react-vendor-cgUCpBnF-D.js";import{C as ae}from"./dialog-BrkEIkWf6y.js";import{O as re}from"./OperatingHoursTimeline-BTRBzV-2rh.js";import"./charts-vendor-D43QTVcFaE.js";import"./radix-vendor-DXvFAmVrUY.js";import"./flow-vendor-BrciDm0dtA.js";import"./modal-e0noyidOkp.js";import"./calendar-Eb6NehLA1A.js";import"./format-Dx8HDyBAfr.js";import"./addDays-Bn2zG8hyoD.js";import"./isSameDay-DjygnclStw.js";const M=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],_=M.map(e=>({day:e,ranges:[],closed:!0}));function q(e){return e?M.map(n=>{const a=e[n];if(!a||a.closed)return{day:n,ranges:[],closed:!0};let t=[];if(a.ranges)t=a.ranges.map((l,i)=>{const[h,c]=l.open.split(":").map(Number),[C,S]=l.close.split(":").map(Number);return{id:`${n}-${i}`,start:h*60+c,end:C*60+S}});else if(a.open&&a.close){const[l,i]=a.open.split(":").map(Number),[h,c]=a.close.split(":").map(Number);t=[{id:`${n}-0`,start:l*60+i,end:h*60+c}]}return{day:n,ranges:t,closed:!1}}):_}function E(e){if(e==null)return null;if(typeof e=="string")try{return JSON.parse(e)}catch{return null}return e}function xe(){const{t:e}=X(),{user:n}=Z(),a=U(),t=n?.id||"",l=ee(n?.role||"user",n?.permissions||null,"edit_own_schedule"),[i,h]=o.useState(_),[c,C]=o.useState([]),[S,p]=o.useState(_),[w,f]=o.useState([]),[u,g]=o.useState(!1),[b,x]=o.useState(!1),[A,k]=o.useState(!1),[z,N]=o.useState(!1),{data:y,isLoading:P}=B(j.userSchedules.detail(t),`/api/user-schedules/${t}`,{enabled:!!t}),{data:v,isLoading:Q}=B(j.clientConfig.detail(),"/api/client-config"),D=P||Q,I=!!y?.schedule?.operating_hours;o.useEffect(()=>{if(D||A)return;const r=E(v?.config?.operating_hours),d=q(r),m=E(v?.config?.special_dates)||[];h(d),C(m);const L=y?.schedule?.operating_hours;L?(p(q(L)),f(E(y?.schedule?.special_dates)||[]),g(!0)):(p(d),f(m),g(!1)),k(!0)},[y,v,D,A]);const J=async()=>{x(!0);try{const r={};for(const d of S)r[d.day]=d.closed||d.ranges.length===0?{closed:!0}:{closed:!1,ranges:d.ranges.map(m=>({open:`${String(Math.floor(m.start/60)).padStart(2,"0")}:${String(m.start%60).padStart(2,"0")}`,close:`${String(Math.floor(m.end/60)).padStart(2,"0")}:${String(m.end%60).padStart(2,"0")}`}))};await H(`/api/user-schedules/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({operating_hours:r,special_dates:w})}),a.invalidateQueries({queryKey:j.userSchedules.detail(t)})}catch(r){console.error("Failed to save schedule:",r),O(F.DATA_SAVE_FAILED)}finally{x(!1)}},K=async()=>{x(!0);try{await H(`/api/user-schedules/${t}`,{method:"DELETE"}),a.invalidateQueries({queryKey:j.userSchedules.detail(t)}),p(i),f(c),g(!1)}catch(r){console.error("Failed to reset schedule:",r),O(F.DATA_SAVE_FAILED)}finally{x(!1),N(!1)}},R=r=>{if(r){g(!0);return}if(I){N(!0);return}p(i),f(c),g(!1)};if(!t||D)return s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx($,{})});const T=l&&u;return s.jsxs("div",{className:"space-y-4 p-0 md:p-6",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[s.jsx(V,{className:"h-5 w-5"}),e.nav.mySchedule]}),s.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:u?e.gcal.schedule.customScheduleHint:e.gcal.schedule.followingBusinessHint})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 rounded-md border border-border bg-muted/40 px-3 py-2.5 text-sm",children:[u?s.jsx(Y,{className:"h-4 w-4 text-primary"}):s.jsx(G,{className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"font-medium text-foreground",children:u?e.gcal.schedule.customSchedule:e.gcal.schedule.noCustomSchedule}),s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:e.gcal.schedule.setCustomSchedule}),s.jsx(se,{checked:u,onCheckedChange:R,disabled:!l||b,"aria-label":e.gcal.schedule.setCustomSchedule})]})]}),s.jsx("div",{className:T?"":"pointer-events-none select-none opacity-50",children:s.jsx(re,{schedule:u?S:i,onChange:p,specialDates:u?w:c,onSpecialDatesChange:f})}),T&&s.jsx("div",{className:"flex justify-end",children:s.jsxs(te,{size:"sm",onClick:J,disabled:b,children:[b?s.jsx($,{className:"h-4 w-4 mr-1"}):s.jsx(W,{className:"h-3 w-3 mr-1"}),e.gcal.schedule.saveSchedule]})}),s.jsx(ae,{open:z,onClose:()=>N(!1),onConfirm:K,title:e.gcal.schedule.useBusinessDefault,message:e.gcal.schedule.resetConfirmSelf,confirmText:e.gcal.schedule.useBusinessDefault,confirmVariant:"danger"})]})}
1export{xe 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.