Docs menu

Code apps (npm)

In a Power Apps code app, or any React app, install @ninthforge/scheduler and render <Scheduler resources={…} bookings={…} />. You hold the data; the Scheduler shows it and tells you what the user changed. It’s the same component as the Power Apps control.

Install

npm i @ninthforge/scheduler@next

Until the launch on 27 January 2027, the package is a release candidate (1.0.0-rc.N). Install it with @next to keep getting each new release candidate. For now npm i @ninthforge/scheduler installs the same release candidate; from 27 January it installs 1.0.0.

It needs React 16.14 or later and has no other runtime dependencies. Styles come with the component, and it uses your app’s font.

Render it

import { useState } from 'react';
import { Scheduler, type CreateRequest, type SchedBooking, type SchedChange, type SchedResource } from '@ninthforge/scheduler';

const resources: SchedResource[] = [
  { id: 'r1', name: 'Aisha Khan', group: 'Customer Care', subtitle: 'Agent', capacityHours: 8 },
  { id: 'r2', name: 'Ben Walker', group: 'Customer Care', subtitle: 'Agent', capacityHours: 8 }
];

export function Roster({ licenseKey, tenantId }: { licenseKey?: string; tenantId?: string }) {
  const [bookings, setBookings] = useState<SchedBooking[]>([
    { id: 'b1', name: 'Morning shift', start: '2027-02-01T01:00:00Z', end: '2027-02-01T05:00:00Z', resourceId: 'r1', status: 'Confirmed' },
    { id: 'b2', name: 'Callback queue', start: '2027-02-01T02:00:00Z', end: '2027-02-01T03:00:00Z', resourceId: null, status: 'Tentative' }
  ]);

  // Save to your backend; throw (or reject) to put the booking back with a message.
  const onBookingChange = async (c: SchedChange) => {
    setBookings((list) =>
      list.map((b) =>
        b.id !== c.id
          ? b
          : { ...b, ...(c.start ? { start: c.start } : {}), ...(c.end ? { end: c.end } : {}), ...('resourceId' in c ? { resourceId: c.resourceId ?? null } : {}) }
      )
    );
  };
  const onCreate = (r: CreateRequest) =>
    setBookings((list) => [...list, { id: `new-${list.length + 1}`, name: 'New shift', start: r.start, end: r.end, resourceId: r.resourceId }]);

  return (
    <div style={{ height: 600 }}>
      <Scheduler
        preset="people"
        title="Team rosters"
        resources={resources}
        bookings={bookings}
        onBookingChange={onBookingChange}
        onCreate={onCreate}
        licenseKey={licenseKey}
        tenantId={tenantId}
      />
    </div>
  );
}

Data

  • Times are instants: UTC milliseconds, or ISO date-times with Z or an offset. Changes come back as ISO UTC strings.
  • resourceId: null means unassigned: the booking is listed in the Unassigned panel and can be dragged onto a row.
  • Unavailable time (leave, maintenance): kind: 'unavailable'. It’s hatched, counts against capacity, and blocks overlaps when overlaps are blocked.
  • Status drives the style: Confirmed, Booked and Scheduled show solid; Tentative and Proposed dashed; Done and Completed faded; Cancelled struck through. Other values get palette colours, or pass statusColors.
  • Resources: group (rows are grouped by it), subtitle, capacityHours, seats, workStart and workEnd (e.g. 8.5 or "08:30"), color and sort.
  • Bad data doesn’t break the board: bookings without a valid start are skipped, reversed times get a minimum length, and fields of the wrong type are treated as text.

Saving changes

onBookingChange gets every move, resize, reassignment and undo: { id, start?, end?, resourceId?, previous, source }, with only the fields that changed. Return a promise for an optimistic save: the board keeps the change while it’s pending, and puts it back with the error message if the promise rejects. Then pass the updated bookings back in.

Useful props

Prop What it does
preset people, rooms, vehicles, equipment, jobs (or custom): labels, default view, snapping, overlap rule, working hours.
onCreate(request) Drag across empty time: { resourceId, start, end }. Create the booking, then add it to bookings.
onOpen(booking) Enter or double-click on a booking.
onRangeChange({ start, end }) The dates on screen changed; load just that window.
timeZone The zone times are shown in. The default is the browser’s; use ianaZone('Europe/London') or fixedZone(minutes) to pin one.
view, defaultView day, week, twoWeeks, month or agenda. Below 600 px it starts in Agenda.
conflictMode allow, warn or block.
editable false turns editing off; { create: false } and so on switch single actions off. A booking with readOnly: true is locked.
groupBy, onGroupByChange Group rows by group (on by default when resources have groups).
loading Shows “Loading…” instead of an empty board while you fetch.
theme, accent, dir 'light' or 'dark', an accent colour, 'rtl'.

Licence

Pass your Plan key as licenseKey and your tenant ID as tenantId. See Licensing. The check is offline; the component makes no network calls.

Last updated