PageSourceSearch

https://app.heyjodie.com/build/assets/CalendarEvents-Dyh3F0VA.js

js heyjodie.com collected 2026-10-01 23:56:33 UTC 9,691 bytes, 1 lines download raw bytes

1import{l as m,k as e,U as b,e as I,t as y,i as me}from"./app-C23pyaid.js";import{D as le}from"./DashboardLayout-C7ZUhX3E.js";import{P as ce}from"./PageHeader-C_haTbyT.js";import{C as g,a as v}from"./card-BRGtWTV3.js";import{B as G}from"./button-BJDSJoXt.js";import{s as h}from"./index-FSFl0VXl.js";import{a as N}from"./utils-DvGlLt9s.js";import{m as de}from"./proxy-4aWI02cb.js";import{A as ue}from"./arrow-left-C4b2GcAr.js";import{C as pe}from"./calendar-range-B60aUecQ.js";import{C as xe}from"./calendar-days-D1F5UcY5.js";import{G as he}from"./globe-C00TqEM8.js";import{C as fe}from"./chevron-up-DwQ6dZaz.js";import{C as ye}from"./chevron-down-BNwpSXGF.js";import{C as ge}from"./calendar-plus-BtOxrVjj.js";import{L as H}from"./loader-circle-DPj1_t_3.js";import{R as we}from"./refresh-cw-CUw5NDGW.js";/* empty css            */import"./app-sidebar-IQ8kf7v7.js";import"./PremiumIndicator-CJKijEH_.js";import"./crown-BzO6vmj8.js";import"./createLucideIcon-DtkNhD0y.js";import"./input-4R0coVUt.js";import"./index-yCbMbx6L.js";import"./index-D5RZUrgt.js";import"./index-BFDhkdEZ.js";import"./x-DpaqY1h0.js";import"./intercom-7ryrOXJ7.js";import"./webCall-B8ioDy5-.js";import"./chevron-right-D7qsCfhd.js";import"./Logo--fg2BGnt.js";import"./useAppTheme-DhGyT_BZ.js";import"./hook-Ctp552oP.js";import"./check-Bcca0OH5.js";import"./phone-Cx-YTElW.js";import"./arrow-right-DmEoEHy2.js";import"./circle-alert-C_gfljDL.js";import"./mail-CxvMrt8f.js";import"./FacebookCookieManager-B-UAeGDV.js";import"./FacebookPixel-BCntTdvu.js";import"./triangle-alert-2vXudR_f.js";import"./info-auHup_nQ.js";import"./useCompanyNotifications-sZAYcoRP.js";import"./GoogleAnalytics-DI5OpeSs.js";import"./user-h93OoGTe.js";const Z=1440*60*1e3,K=21,P=n=>n.toISOString(),$=n=>[...n].sort((o,c)=>o.start_at.localeCompare(c.start_at)),z=n=>{const o=new Set,c=[];for(const l of n)o.has(l.id)||(o.add(l.id),c.push(l));return c},U=(n,o)=>$(z([...n,...o]));function ht(n){const{events:o,timezone:c,calendar_name:l,locale:f,calendar_connected:k,has_selected_calendar:C,range:D,has_earlier:O,has_more:W}=n,p=c||"Etc/UTC",x=f||"en-GB",[w,S]=m.useState(()=>$(z(o))),[E,q]=m.useState(D.start),[_,J]=m.useState(D.end),[Q,V]=m.useState(O),[X,ee]=m.useState(W),[T,M]=m.useState(!1),[B,R]=m.useState(!1),[A,L]=m.useState(!1),i=m.useMemo(()=>{const s=new Intl.DateTimeFormat("en-CA",{timeZone:p,year:"numeric",month:"2-digit",day:"2-digit"}),a=new Intl.DateTimeFormat(x,{timeZone:p,hour:"numeric",minute:"2-digit"}),t=new Intl.DateTimeFormat(x,{timeZone:p,weekday:"short"}),r=new Intl.DateTimeFormat(x,{timeZone:p,day:"numeric"}),d=new Intl.DateTimeFormat(x,{timeZone:p,month:"short"}),u=new Intl.DateTimeFormat(x,{timeZone:p,month:"long",year:"numeric"});return{dayKey:s,time:a,weekday:t,dayNumber:r,monthShort:d,monthYear:u}},[p,x]),te=m.useMemo(()=>i.dayKey.format(new Date),[i]),F=m.useMemo(()=>{const s=new Map,a=(t,r)=>{const d=s.get(t);d?d.push(r):s.set(t,[r])};for(const t of w){const r=i.dayKey.format(new Date(t.start_at));if(t.is_all_day){const d=i.dayKey.format(new Date(t.end_at)),u=new Date(`${r}T12:00:00Z`);let j=r;for(;j<d;)a(j,t),u.setUTCDate(u.getUTCDate()+1),j=i.dayKey.format(u);r>=d&&a(r,t);continue}a(r,t)}return Array.from(s.entries()).sort((t,r)=>t[0].localeCompare(r[0])).map(([t,r])=>({key:t,events:r}))},[w,i]),se=s=>{const a=new Date(`${s}T12:00:00Z`);return{weekday:i.weekday.format(a),dayNumber:i.dayNumber.format(a),monthShort:i.monthShort.format(a),isToday:s===te}},ae=s=>i.monthYear.format(new Date(`${s}T12:00:00Z`)),re=s=>{if(s.is_all_day)return"All day";const a=i.time.format(new Date(s.start_at)),t=i.time.format(new Date(s.end_at));return`${a} – ${t}`},ne=async()=>{if(T)return;M(!0);const s=E,a=P(new Date(new Date(E).getTime()-K*Z));try{const{data:t}=await I.get(h("bookings.calendar.events.list"),{params:{start:a,end:s}});S(r=>U(r,t.events)),q(a),V(t.has_earlier)}catch{y.error("Couldn't load earlier events. Please try again.")}finally{M(!1)}},oe=async()=>{if(B)return;R(!0);const s=_,a=P(new Date(new Date(_).getTime()+K*Z));try{const{data:t}=await I.get(h("bookings.calendar.events.list"),{params:{start:s,end:a}});S(r=>U(r,t.events)),J(a),ee(t.has_more)}catch{y.error("Couldn't load more events. Please try again.")}finally{R(!1)}},ie=()=>{A||(L(!0),me.post(h("bookings.calendar.events.refresh"),{},{preserveScroll:!0,onSuccess:()=>y.success("Syncing your calendar — check back in a few minutes."),onError:()=>y.error("Couldn't start a calendar sync. Please try again."),onFinish:()=>L(!1)}))};return e.jsx(le,{title:"Calendar Events",breadcrumbs:["Agent Setup","Bookings","Calendar","Events"],metaDescription:"Your upcoming synced calendar events",children:e.jsxs(de.div,{className:"w-full space-y-6 px-0 md:px-4 pb-20",initial:{opacity:0}
1,animate:{opacity:1},children:[e.jsxs(b,{href:h("bookings"),className:"inline-flex items-center gap-1.5 text-sm text-secondary-foreground/60 hover:text-secondary-foreground transition-colors",children:[e.jsx(ue,{className:"h-4 w-4"}),"Back to Bookings"]}),e.jsx(ce,{icon:pe,title:"Calendar Events",subtitle:"A schedule of your synced calendar events, shown in your booking calendar's timezone"}),k&&C&&l&&e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx(xe,{className:"h-4 w-4 shrink-0 text-primary"}),e.jsx("span",{className:"truncate font-medium text-secondary-foreground",children:l})]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(he,{className:"h-4 w-4 shrink-0"}),p]})]}),k?C?w.length===0?e.jsx(ve,{onResync:ie,resyncing:A}):e.jsxs("div",{className:"space-y-3",children:[Q&&e.jsx(Y,{onClick:ne,loading:T,icon:e.jsx(fe,{className:"h-4 w-4 mr-2"}),label:"Load earlier"}),e.jsx(g,{className:"overflow-hidden border",children:e.jsx("div",{className:"divide-y",children:F.map((s,a)=>{const t=se(s.key),r=s.key.slice(0,7),d=a===0||r!==F[a-1].key.slice(0,7);return e.jsxs(m.Fragment,{children:[d&&e.jsx("div",{className:"bg-muted/40 px-4 py-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:ae(s.key)}),e.jsxs("div",{className:N("flex flex-col sm:flex-row",t.isToday&&"bg-primary/[0.07]"),children:[e.jsxs("div",{className:"flex items-center gap-2 border-b bg-muted/30 px-4 py-2.5 sm:w-44 sm:shrink-0 sm:flex-col sm:items-start sm:gap-1 sm:border-b-0 sm:border-r sm:py-4",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t.weekday}),e.jsxs("span",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-lg font-semibold tabular-nums sm:text-2xl",children:t.dayNumber}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t.monthShort})]})]}),e.jsx("div",{className:"min-w-0 flex-1 divide-y",children:s.events.map(u=>e.jsx(je,{event:u,time:re(u)},u.id))})]})]},s.key)})})}),X&&e.jsx(Y,{onClick:oe,loading:B,icon:e.jsx(ye,{className:"h-4 w-4 mr-2"}),label:"Load more"})]}):e.jsx(be,{}):e.jsx(Ne,{})]})})}function Y({onClick:n,loading:o,icon:c,label:l}){return e.jsx("div",{className:"flex justify-center",children:e.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:n,disabled:o,className:"w-full sm:w-auto",children:[o?e.jsx(H,{className:"h-4 w-4 mr-2 animate-spin"}):c,l]})})}function je({event:n,time:o}){var f;const c=(f=n.title)!=null&&f.trim()?n.title:"(no title)",l="ml-auto inline-flex shrink-0 items-center rounded-full px-2 py-0.5 text-xs font-medium sm:order-4 sm:ml-0";return e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-3 transition-colors hover:bg-muted/40",children:[e.jsx("span",{className:"shrink-0 whitespace-nowrap text-sm font-medium tabular-nums text-secondary-foreground sm:order-1 sm:w-28",children:o}),n.is_busy?e.jsx("span",{className:N(l,"bg-warning/15 text-warning-foreground"),children:"Busy"}):e.jsx("span",{className:N(l,"border text-muted-foreground"),children:"Free"}),e.jsx("p",{className:"w-full min-w-0 break-words text-sm text-secondary-foreground line-clamp-2 sm:order-2 sm:w-auto sm:flex-1",children:c})]})}function Ne(){return e.jsx(g,{className:"border",children:e.jsx(v,{className:"p-6",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["No calendar is connected yet. Connect Gmail or Outlook on the"," ",e.jsx(b,{href:h("channels"),className:"text-primary underline underline-offset-4",children:"Channels"})," ","page to start syncing your events."]})})})}function be(){return e.jsx(g,{className:"border",children:e.jsx(v,{className:"p-6",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You haven't chosen a booking calendar yet. Pick one on the"," ",e.jsx(b,{href:h("bookings"),className:"text-primary underline underline-offset-4",children:"Bookings"})," ","page to see its events here."]})})})}function ve({onResync:n,resyncing:o}){return e.jsx(g,{className:"border",children:e.jsxs(v,{className:"flex flex-col items-center gap-4 px-6 py-12 text-center",children:[e.jsx("div",{className:"rounded-full bg-primary/10 p-3",children:e.jsx(ge,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-base font-semibold text-secondary-foreground",children:"Nothing here yet"}),e.jsx("p",{className:"mx-auto max-w-sm text-sm text-muted-foreground",children:"We haven't found any events on your selected calendar. Re-sync to pull in y
1our latest schedule."})]}),e.jsxs(G,{type:"button",onClick:n,disabled:o,className:"mt-1",children:[o?e.jsx(H,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(we,{className:"h-4 w-4 mr-2"}),"Re-sync calendar"]})]})})}export{ht 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.