PageSourceSearch

https://intel-base.ai/assets/ProductionSchedule-Bx5KZ976.js

js intel-base.ai collected 2026-10-05 15:36:56 UTC 12,452 bytes, 3 lines download raw bytes

1import{r as a,j as e}from"./react-vendor-BDFCGFgF.js";import{S as he}from"./switch-CDZxLm2G.js";import{B as M,bp as ge,F as ye,L as je,s as V,n as be}from"./index-CnoOAt8u.js";import{u as we,a as Ne,M as Me,P as ke,b as ve,c as z}from"./useProductionProjects-CXwOJ4cf.js";import{P as B}from"./plus-3ewMnmS_.js";import{f as p,s as S}from"./format-DJS7CEkF.js";import{e as L}from"./endOfWeek-CMFPHzg-.js";import{a as v}from"./addDays-NfUR6mCk.js";import{s as Ce}from"./subDays-B-7wsp4R.js";import{s as Se}from"./subWeeks-BiNLRu7P.js";import{a as Oe}from"./addWeeks-DETzrEcg.js";import{s as De,e as Ee}from"./subMonths-DWrKw-3M.js";import{b as Pe}from"./addYears-tgY2ntIb.js";import{e as K}from"./endOfDay-eyt9T6Pl.js";import{s as _e}from"./differenceInCalendarDays-KslS0qet.js";import{e as Q}from"./endOfMonth-C08TnTHg.js";import{s as X}from"./calendar-DTN8aJPG.js";import{i as C}from"./isToday-ppysdnpx.js";import"./radix-C1DJG546.js";import"./supabase-Cw9ajmI9.js";import"./checkbox-DwpghOvO.js";import"./collapsible-C0iSODCT.js";import"./chevron-left-C1VtbHb9.js";import"./pencil-B1jpozG0.js";import"./square-check-big-B3T__af9.js";import"./twitter-B-2cD-fv.js";import"./linkedin-yjMJ20ks.js";import"./popover-B1IedZu1.js";import"./palette-CEoifBG2.js";import"./trash-2-6JZzy-jZ.js";import"./select-BBkpWt_j.js";import"./target-B8viWvru.js";import"./package-D0FbceT-.js";import"./sticky-note-28f7M90l.js";import"./isSameDay-BKY3pOTd.js";import"./isSameYear-DA0c0U3m.js";import"./constructNow-CuLaQTdI.js";function $e(t,u,c=!1){if(u==="day")return{start:_e(t),end:K(t)};if(u==="week"){const x=S(t,{weekStartsOn:1}),f=c?L(t,{weekStartsOn:1}):K(v(x,4));return{start:x,end:f}}return{start:X(t),end:Q(t)}}const Y=Array.from({length:24},(t,u)=>u);function Te({date:t,items:u,onSlotClick:c,onItemClick:x}){const f=a.useRef(null),g=a.useMemo(()=>{const r={};return u.forEach(d=>{const i=d.start.getHours();(r[i]||(r[i]=[])).push(d)}),r},[u]);return a.useEffect(()=>{f.current&&(f.current.scrollTop=6*60)},[t]),e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsx("div",{className:"text-center py-2 border-b",children:e.jsx("span",{className:`text-sm font-medium ${C(t)?"bg-primary text-primary-foreground px-3 py-1 rounded-full":""}`,children:p(t,"EEEE, MMMM d")})}),e.jsx("div",{ref:f,className:"flex-1 overflow-y-auto",children:Y.map(r=>e.jsxs("div",{className:"flex border-b min-h-[60px] group/slot",onClick:()=>c(t,r),children:[e.jsx("div",{className:"w-16 flex-shrink-0 text-[11px] text-muted-foreground text-right pr-3 pt-1 select-none",children:p(new Date(2e3,0,1,r),"h a")}),e.jsxs("div",{className:"flex-1 border-l px-2 py-1 space-y-1 relative cursor-pointer",children:[e.jsx("button",{className:"absolute top-1 right-1 opacity-0 group-hover/slot:opacity-70 hover:!opacity-100 transition-opacity bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center z-10",onClick:d=>{d.stopPropagation(),c(t,r)},children:e.jsx(B,{className:"h-3 w-3"})}),(g[r]||[]).map(d=>e.jsx(z,{item:d,onClick:x},d.id))]})]},r))})]})}function He({currentDate:t,items:u,onSlotClick:c,onItemClick:x,showWeekends:f}){const g=a.useRef(null),r=S(t,{weekStartsOn:1}),d=Array.from({length:7},(o,m)=>v(r,m)),i=f?d:d.filter((o,m)=>m<5),y="56px",j=a.useMemo(()=>{const o={};return u.forEach(m=>{const h=`${p(m.start,"yyyy-MM-dd")}-${m.start.getHours()}`;(o[h]||(o[h]=[])).push(m)}),o},[u]);return a.useEffect(()=>{g.current&&(g.current.scrollTop=6*48)},[t]),e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsxs("table",{className:"w-full border-collapse",style:{tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:y}}),i.map((o,m)=>e.jsx("col",{},m))]}),e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"border-r"}),i.map(o=>e.jsxs("th",{className:"text-center py-2 border-r last:border-r-0 font-normal",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase",children:p(o,"EEE")}),e.jsx("div",{className:`text-sm font-medium ${C(o)?"bg-primary text-primary-foreground w-7 h-7 rounded-full flex items-center justify-center mx-auto":""}`,children:p(o,"d")})]},o.toISOString()))]})})]}),e.jsx("div",{ref:g,className:"flex-1 overflow-y-auto",children:e.jsxs("table",{className:"w-full border-collapse",style:{tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:y}}),i.map((o,m)=>e.jsx("col",{},m))]}),e.jsx("tbody",{children:Y.map(o=>e.jsxs("tr",{children:[e.jsx("td",{className:"text-[10px] text-muted-foreground text-right pr-2 pt-0.5 select-none border-r al
1ign-top",style:{width:y},children:p(new Date(2e3,0,1,o),"h a")}),i.map(m=>{const h=`${p(m,"yyyy-MM-dd")}-${o}`;return e.jsxs("td",{className:"border-r border-b min-h-[48px] h-12 px-0.5 py-0.5 cursor-pointer relative group/cell align-top",onClick:()=>c(m,o),children:[e.jsx("button",{className:"absolute top-0.5 right-0.5 opacity-0 group-hover/cell:opacity-70 hover:!opacity-100 transition-opacity bg-primary text-primary-foreground rounded-full w-4 h-4 flex items-center justify-center z-10",onClick:b=>{b.stopPropagation(),c(m,o)},children:e.jsx(B,{className:"h-2.5 w-2.5"})}),e.jsx("div",{className:"overflow-hidden",children:(j[h]||[]).map(b=>e.jsx(z,{item:b,onClick:x,compact:!0},b.id))})]},h)})]},o))})]})})]})}function Ie({currentDate:t,items:u,onSlotClick:c,onItemClick:x}){const f=a.useMemo(()=>{const r=X(t),d=Q(t),i=S(r,{weekStartsOn:1}),y=L(d,{weekStartsOn:1});return Ee({start:i,end:y})},[t]),g=a.useMemo(()=>{const r={};return u.forEach(d=>{const i=p(d.start,"yyyy-MM-dd");(r[i]||(r[i]=[])).push(d)}),r},[u]);return e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsx("div",{className:"grid grid-cols-7 border-l border-t flex-shrink-0",children:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(r=>e.jsx("div",{className:"py-1 text-center text-xs font-medium text-muted-foreground border-r border-b bg-muted/30",children:r},r))}),e.jsx("div",{className:"grid grid-cols-7 border-l flex-1",style:{gridTemplateRows:`repeat(${Math.ceil(f.length/7)}, 1fr)`},children:f.map(r=>{const d=p(r,"yyyy-MM-dd"),i=g[d]||[],y=r.getMonth()===t.getMonth();return e.jsxs("div",{className:`min-h-0 p-1.5 border-r border-b cursor-pointer group/daycell relative hover:bg-muted/30 transition-colors overflow-hidden
2                ${y?"bg-background":"bg-muted/20"}
3                ${C(r)?"ring-1 ring-primary ring-inset":""}`,onClick:()=>c(r,8),children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:`text-xs font-medium ${C(r)?"bg-primary text-primary-foreground w-6 h-6 rounded-full flex items-center justify-center":""} ${y?"":"text-muted-foreground/50"}`,children:p(r,"d")}),i.length>2&&e.jsx(be,{variant:"secondary",className:"text-[10px] h-4 px-1",children:i.length})]}),e.jsxs("div",{className:"space-y-0.5",children:[i.slice(0,3).map(j=>e.jsx(z,{item:j,onClick:x,compact:!0},j.id)),i.length>3&&e.jsxs("span",{className:"text-[10px] text-muted-foreground pl-1",children:["+",i.length-3," more"]})]})]},d)})})]})}function bt(){const[t,u]=a.useState("week"),[c,x]=a.useState(new Date),[f,g]=a.useState(!1),[r,d]=a.useState(!0),[i,y]=a.useState({production:!0}),[j,o]=a.useState(!1),[m,h]=a.useState(!1),[b,O]=a.useState(null),[Z,D]=a.useState(null),[ee,E]=a.useState(),[te,P]=a.useState(),[k,A]=a.useState([]),[_,se]=a.useState([]),{calendars:F,createCalendar:re,updateCalendar:ae,deleteCalendar:ne,toggleVisibility:oe,updateMembers:le}=we(),[N,ie]=a.useState(!1),{start:ce,end:de}=$e(c,t,N),{projects:$,createProject:me,updateProject:ue,deleteProject:pe}=Ne(ce,de);a.useEffect(()=>{async function s(){const{data:{user:l}}=await V.auth.getUser();if(!l)return;const{data:n}=await V.from("reporting_relationships").select("report_id").eq("manager_id",l.id),W=(n||[]).map(w=>w.report_id),R=[l.id,...W],{data:U}=await V.from("profiles").select("id, full_name").in("id",R);se((U||[]).map(w=>({id:w.id,name:w.full_name||"Unknown"})))}s()},[]);const T=a.useMemo(()=>{const s=[];return(k.length>0?$.filter(n=>n.assigned_to&&k.includes(n.assigned_to)):$).forEach(n=>{const[W,R]=n.start_time.split(":").map(Number),[U,w]=n.end_time.split(":").map(Number),G=new Date(n.project_date+"T00:00:00");G.setHours(W,R);const J=new Date(n.project_date+"T00:00:00");J.setHours(U,w);const fe=n.status==="in_progress"?"🔵":n.status==="completed"?"✅":n.status==="on_hold"?"⏸️":"";s.push({id:n.id,type:"shift",title:`${fe} ${n.assigned_name||"Unassigned"} — ${n.title}`,subtitle:n.estimated_units?`${n.estimated_units} ${n.unit_type||"units"}`:n.location||void 0,start:G,end:J,color:n.color||void 0,metadata:{productionProject:n}})}),s},[$,k]),xe=a.useMemo(()=>
3{if(t==="day")return p(c,"EEEE, MMMM d, yyyy");if(t==="week"){const s=S(c,{weekStartsOn:1}),l=N?L(c,{weekStartsOn:1}):v(s,4);return`${p(s,"MMM d")} – ${p(l,"MMM d, yyyy")}`}return p(c,"MMMM yyyy")},[c,t,N]),q=a.useCallback(s=>{x(l=>t==="day"?s==="prev"?Ce(l,1):v(l,1):t==="week"?s==="prev"?Se(l,1):Oe(l,1):s==="prev"?De(l,1):Pe(l,1))},[t]),H=(s,l)=>{D(null),E(s),P(l),o(!0)},I=s=>{var l;(l=s.metadata)!=null&&l.productionProject&&(D(s.metadata.productionProject),E(void 0),P(void 0),o(!0))};return e.jsxs("div",{className:"flex flex-col h-[calc(100vh-4rem)] px-4 pt-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 pb-2 border-b flex-shrink-0 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(M,{variant:"ghost",size:"icon",className:"h-7 w-7 lg:hidden",onClick:()=>g(s=>!s),"aria-label":"Toggle schedule sidebar",children:e.jsx(ge,{className:"h-4 w-4"})}),e.jsx(ye,{className:"h-5 w-5 text-primary hidden md:block"}),e.jsx("h1",{className:"text-lg font-semibold hidden md:block",children:"Production Schedule"}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(M,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>x(new Date),children:"Today"}),e.jsx(M,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>q("prev"),"aria-label":"Previous period",children:e.jsx("span",{className:"text-sm",children:"‹"})}),e.jsx("span",{className:"text-xs sm:text-sm font-semibold min-w-[100px] sm:min-w-[140px] text-center",children:xe}),e.jsx(M,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>q("next"),"aria-label":"Next period",children:e.jsx("span",{className:"text-sm",children:"›"})})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(M,{size:"sm",className:"h-7 text-xs",onClick:()=>{D(null),E(new Date),P(8),o(!0)},children:[e.jsx(B,{className:"h-3.5 w-3.5 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"New Project"})]}),t==="week"&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(he,{id:"ps-weekends",checked:N,onCheckedChange:ie,className:"scale-75"}),e.jsx(je,{htmlFor:"ps-weekends",className:"text-[11px] text-muted-foreground cursor-pointer select-none",children:"7-day"})]}),e.jsx("div",{className:"flex items-center border rounded-md overflow-hidden",children:["day","week","month"].map(s=>e.jsx("button",{onClick:()=>u(s),className:`px-2 sm:px-3 py-1 text-xs font-medium transition-colors ${t===s?"bg-primary text-primary-foreground":"hover:bg-muted"}`,children:s.charAt(0).toUpperCase()+s.slice(1)},s))})]})]}),e.jsxs("div",{className:"flex gap-3 mt-2 flex-1 min-h-0",children:[e.jsx(Me,{currentDate:c,onDateSelect:x,systemCalendarVisibility:i,onSystemCalendarToggle:(s,l)=>y(n=>({...n,[s]:l})),customCalendars:F,onToggleCalendarVisibility:oe,onEditCalendar:s=>{O(s),h(!0)},onAddCalendar:()=>{O(null),h(!0)},teamMembers:_,selectedMembers:k,onMemberToggle:s=>A(l=>l.includes(s)?l.filter(n=>n!==s):[...l,s]),onClearMembers:()=>A([]),open:f,onOpenChange:g,desktopOpen:r,onDesktopOpenChange:d}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[t==="day"&&e.jsx(Te,{date:c,items:T,onSlotClick:H,onItemClick:I}),t==="week"&&e.jsx(He,{currentDate:c,items:T,onSlotClick:H,onItemClick:I,showWeekends:N}),t==="month"&&e.jsx(Ie,{currentDate:c,items:T,onSlotClick:H,onItemClick:I})]})]}),e.jsx(ke,{open:j,onOpenChange:o,editingProject:Z,defaultDate:ee,defaultHour:te,customCalendars:F,teamMembers:_,onSave:me,onUpdate:ue,onDelete:pe,onCreateCalendar:()=>{O(null),h(!0)}}),e.jsx(ve,{open:m,onOpenChange:h,editingCalendar:b,teamMembers:_,onSave:re,onUpdate:ae,onUpdateMembers:le,onDelete:ne})]})}export{bt 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.