PageSourceSearch

https://clozure.net/assets/AIScheduler-US22B2zn.js

js clozure.net collected 2026-10-02 01:06:42 UTC 10,034 bytes, 1 lines download raw bytes

1import{p as Q,r as C,j as e}from"./react-vendor-Ca39dfnS.js";import{b as W,a as f,u as N}from"./query-vendor-CZuItqE6.js";import{u as z,K as B,B as x,C as r,a as l,b as c,d,e as g,c as H,a5 as k}from"./main-klyVOJfp.js";import{A as L,a as _}from"./avatar-CjfO7Txh.js";import{s as G,q as Z,r as J,f as h}from"./chart-vendor-B24y44e_.js";import{$ as U,Z as A,H as V,r as X,a2 as Y,aK as ee,s as se,bi as te,ai as ae,aJ as ne,P as ie,at as re}from"./ui-vendor-CDWeqcbU.js";import"./modulepreload-polyfill-B5Qt9EMX.js";const le=t=>t.suggestedTime||t.suggestedDate||new Date().toISOString(),D=t=>t.type||t.suggestionType||"meeting",ce=t=>t.duration??30,de=t=>t.reason||t.description||"AI-generated suggestion",oe=t=>t.attendees||[],E=t=>{const n=typeof t.confidence=="string"?parseFloat(t.confidence):t.confidence??0;return n<=1?Math.round(n*100):Math.round(n)};function fe(){const{businessId:t}=Q(),{toast:n}=z(),u=W(),[M,v]=C.useState(0),[j,O]=C.useState(new Date),P=G(Z(new Date,M),{weekStartsOn:1}),$=Array.from({length:5},(s,a)=>J(P,a)),{data:T=[],isLoading:I}=f({queryKey:["/api/gap/coo/scheduler/suggestions",t],enabled:!!t}),{data:b=[]}=f({queryKey:["/api/gap/coo/scheduler/slots",t,j.toISOString()],enabled:!!t}),{data:y=[]}=f({queryKey:["/api/gap/coo/scheduler/resources",t],enabled:!!t}),w=N({mutationFn:async s=>{const a=await fetch(`/api/gap/coo/scheduler/suggestions/${s}/accept`,{method:"POST",credentials:"include"});if(!a.ok){const i=await a.json().catch(()=>null);throw new Error(i?.error||`Failed to accept (${a.status})`)}return a.json()},onSuccess:()=>{u.invalidateQueries({queryKey:["/api/gap/coo/scheduler/suggestions",t]}
1),u.invalidateQueries({queryKey:[`/api/businesses/${t}/meetings`]}),n({title:"Meeting scheduled",description:"The meeting was added to your calendar."})},onError:s=>{n({title:"Could not accept suggestion",description:s.message,variant:"destructive"})}}),S=N({mutationFn:async s=>{const a=await fetch(`/api/gap/coo/scheduler/suggestions/${s}/reject`,{method:"POST",credentials:"include"});if(!a.ok){const i=await a.json().catch(()=>null);throw new Error(i?.error||`Failed to reject (${a.status})`)}return a.json()},onSuccess:()=>{u.invalidateQueries({queryKey:["/api/gap/coo/scheduler/suggestions",t]}),n({title:"Suggestion dismissed"})},onError:s=>{n({title:"Could not dismiss suggestion",description:s.message,variant:"destructive"})}}),p=N({mutationFn:async()=>{const s=await fetch(`/api/gap/coo/scheduler/generate/${t}`,{method:"POST",credentials:"include"});if(!s.ok)throw new Error("Failed to generate suggestions");return s.json()},onSuccess:s=>{u.invalidateQueries({queryKey:["/api/gap/coo/scheduler/suggestions",t]}),n({title:`Generated ${s?.created??0} new suggestions`})},onError:()=>{n({title:"Failed to generate suggestions",variant:"destructive"})}}),o=(T||[]).filter(s=>(s.status??"pending")==="pending"),F=o.length?(o.reduce((s,a)=>s+E(a),0)/o.length).toFixed(0):"0",q=s=>s==="video"?e.jsx(ne,{className:"h-4 w-4"}):s==="call"?e.jsx(ie,{className:"h-4 w-4"}):e.jsx(re,{className:"h-4 w-4"}),K=s=>s>=90?"text-green-600":s>=70?"text-yellow-600":"text-orange-600";return e.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[e.jsx(B,{department:"COO",title:"AI Scheduler",subtitle:"Intelligent meeting and resource scheduling",actions:e.jsxs(x,{variant:"outline",className:"bg-white/20 text-white hover:bg-white/30 border-white/20",onClick:()=>p.mutate(),disabled:p.isPending,children:[e.jsx(U,{className:`h-4 w-4 mr-2 ${p.isPending?"animate-spin":""}`}),"Generate Suggestions"]}),compact:!0}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs(r,{children:[e.jsx(l,{className:"pb-2",children:e.jsx(c,{className:"text-sm font-medium text-muted-foreground",children:"Pending Suggestions"})}),e.jsx(d,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-5 w-5 text-purple-500"}),e.jsx("span",{className:"text-3xl font-bold",children:o.length})]})})]}),e.jsxs(r,{children:[e.jsx(l,{className:"pb-2",children:e.jsx(c,{className:"text-sm font-medium text-muted-foreground",children:"Avg Confidence"})}),e.jsx(d,{children:e.jsxs("span",{className:"text-3xl font-bold",children:[F,"%"]})})]}),e.jsxs(r,{children:[e.jsx(l,{className:"pb-2",children:e.jsx(c,{className:"text-sm font-medium text-muted-foreground",children:"Available Slots Today"})}),e.jsx(d,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{className:"h-5 w-5 text-green-500"}),e.jsx("span",{className:"text-3xl font-bold",children:b?.filter(s=>s.available).length||0})]})})]}),e.jsxs(r,{children:[e.jsx(l,{className:"pb-2",children:e.jsx(c,{className:"text-sm font-medium text-muted-foreground",children:"Resources"})}),e.jsx(d,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-5 w-5 text-blue-500"}),e.jsx("span",{className:"text-3xl font-bold",children:y?.length||0})]})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(r,{className:"lg:col-span-2",children:[e.jsxs(l,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"AI Scheduling Suggestions"}),e.jsxs(g,{variant:"outline",children:[o.length," pending"]})]}),e.jsx(H,{children:"Review and approve AI-generated meeting times"})]}),e.jsx(d,{children:I?e.jsx("div",{className:"space-y-4",children:Array.from({length:3}).map((s,a)=>e.jsx(k,{className:"h-32 w-full"},a))}):o.length?e.jsx("div",{className:"space-y-4",children:o.map(s=>{const a=E(s),i=oe(s);return e.jsxs("div",{className:"p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-medium",children:s.title}),e.jsxs(g,{variant:"outline",className:"flex items-center gap-1",children:[q(D(s)),D(s)]}),s.priority&&e.jsx(g,{variant:"outline",className:"text-xs capitalize",children:s.priority})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[h(new Date(le(s)),"EEEE, MMMM d 'at' h:mm a")," • ",ce(s)," min"]})]}),e.jsxs("div",{className:`text-right ${K(a)}`,children:[e.jsxs("p",{className:"text-2xl font-bold",children:[a,"%"]}),e.jsx("p",{className:"text-xs",children:"confidence"})]})]}),i.length>0&&e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Attendees:"}
1),e.jsxs("div",{className:"flex -space-x-2",children:[i.slice(0,4).map(m=>e.jsx(L,{className:`h-7 w-7 border-2 ${m.available?"border-green-500":"border-red-500"}`,children:e.jsx(_,{className:"text-xs",children:(m.name||"?").split(" ").map(R=>R?.[0]||"").join("").slice(0,2)||"?"})},m.id)),i.length>4&&e.jsxs("div",{className:"h-7 w-7 rounded-full bg-gray-100 flex items-center justify-center text-xs",children:["+",i.length-4]})]}),e.jsxs("span",{className:"text-xs text-muted-foreground ml-2",children:[i.filter(m=>m.available).length,"/",i.length," available"]})]}),e.jsxs("div",{className:"p-2 bg-blue-50 rounded text-sm text-blue-800 mb-3",children:[e.jsx(A,{className:"h-4 w-4 inline mr-1"}),de(s)]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>S.mutate(s.id),disabled:S.isPending,children:[e.jsx(ee,{className:"h-4 w-4 mr-1"}),"Reject"]}),e.jsxs(x,{size:"sm",onClick:()=>w.mutate(s.id),disabled:w.isPending,children:[e.jsx(se,{className:"h-4 w-4 mr-1"}),"Accept"]})]})]},s.id)})}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Y,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No pending suggestions"})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(r,{children:[e.jsx(l,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{className:"text-base",children:"Weekly Overview"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(x,{"aria-label":"Set Week Offset",variant:"ghost",size:"icon",onClick:()=>v(s=>s-1),children:e.jsx(te,{className:"h-4 w-4"})}),e.jsx(x,{"aria-label":"Set Week Offset",variant:"ghost",size:"icon",onClick:()=>v(s=>s+1),children:e.jsx(ae,{className:"h-4 w-4"})})]})]})}),e.jsx(d,{children:e.jsx("div",{className:"grid grid-cols-5 gap-1",children:$.map(s=>e.jsxs("button",{onClick:()=>O(s),className:`p-2 rounded text-center transition-colors ${j.toDateString()===s.toDateString()?"bg-primary text-primary-foreground":"hover:bg-muted"}`,children:[e.jsx("p",{className:"text-xs font-medium",children:h(s,"EEE")}),e.jsx("p",{className:"text-lg font-bold",children:h(s,"d")})]},s.toISOString()))})})]}),e.jsxs(r,{children:[e.jsx(l,{children:e.jsxs(c,{className:"text-base",children:["Time Slots - ",h(j,"MMM d")]})}),e.jsx(d,{children:e.jsx("div",{className:"space-y-1 max-h-[250px] overflow-y-auto",children:b?.map(s=>e.jsxs("div",{className:`flex items-center justify-between p-2 rounded text-sm ${s.available?"bg-green-50 text-green-800":"bg-gray-100 text-gray-500"}`,children:[e.jsx("span",{children:h(new Date(s.time),"h:mm a")}),s.available?e.jsx(g,{variant:"outline",className:"text-xs bg-green-100",children:"Available"}):e.jsx("span",{className:"text-xs",children:s.conflictReason||"Busy"})]},s.time))||Array.from({length:8}).map((s,a)=>e.jsx(k,{className:"h-8 w-full"},a))})})]}),e.jsxs(r,{children:[e.jsx(l,{children:e.jsx(c,{className:"text-base",children:"Resource Availability"})}),e.jsx(d,{children:e.jsx("div",{className:"space-y-3",children:y?.slice(0,4).map(s=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.type})]}),e.jsx("div",{className:"text-right",children:e.jsxs("p",{className:`text-sm font-medium ${s.availability>50?"text-green-600":"text-yellow-600"}`,children:[s.availability,"%"]})})]},s.id))})})]})]})]})]})}export{fe 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.