ProSchedulerSign in

Timeline · Use cases

Time zone meeting planner

A distributed team, each row shaded with that person's 09:00–17:00 in their own zone and shown in yours. A meeting that sits inside every shaded band suits everyone.

Live demo

Switch the display zone · Move the Global sync until it fits Tokyo too

Fullscreen
import { useMemo, useState } from "react"
import { ProScheduler, toZonedTime } from "@andreisaac/pro-scheduler"
import { dataZone, globalMeetings, globalTeam, workingHours } from "./data/global"
import { Choice, Toolbar, useEvents } from "./kit"

/** The zones a viewer can pick: each member's, by city. */
const zones = globalTeam.map((m) => ({ zone: m.timezone, label: m.city }))

function ZonePicker({ value, onChange }: { value: string; onChange: (zone: string) => void }) {
  return (
    <Toolbar label="Display time zone">
      {zones.map((z) => (
        <Choice key={z.zone} active={value === z.zone} onClick={() => onChange(z.zone)}>
          {z.label}
        </Choice>
      ))}
    </Toolbar>
  )
}

export function MeetingPlannerDemo() {
  const { events, handlers } = useEvents(() => globalMeetings())
  const [zone, setZone] = useState("America/New_York")
  // Everyone's 09:00–17:00, in their own zone, shaded in the one shown.
  const colors = useMemo(() => workingHours(zone), [zone])
  return (
    <>
      <ZonePicker value={zone} onChange={setZone} />
      <ProScheduler
        data={events}
        resources={globalTeam}
        colors={colors}
        dataTimezone={dataZone}
        displayTimezone={zone}
        view={{ timeline: { type: "week", resolutionHorizontal: "hour" } }}
        styleConfig={{ unitWidthPx: 34, fitToWidth: false, resourceColWidth: 200 }}
        renderResource={(member) => (
          <div className="flex flex-col leading-tight">
            <span className="text-sm font-medium">{member.name}</span>
            <span className="text-xs text-muted-foreground">
              {String(member.city)} ·{" "}
              {toZonedTime(new Date(), String(member.timezone)).toLocaleTimeString([], {
                hour: "2-digit",
                minute: "2-digit",
              })}
            </span>
          </div>
        )}
        height={440}
        {...handlers}
      />
    </>
  )
}

About this demo

A distributed team, each row shaded with that person's 09:00–17:00 in their own zone and shown in yours. A meeting that sits inside every shaded band suits everyone.

Things to try

  • Switch the display zone
  • Move the Global sync until it fits Tokyo too

The props behind it are explained in Recurrence, time zones and order.

Use ProScheduler in your project