# Shifts

> Shift templates that generate shifts on weekdays, shifts planned in draft and published per team and location, assignments checked for overlap, approved leave, required qualifications and rest time, open shift requests, swaps between members, availability, a roster, planned hours against contract hours, and time entries from worked shifts.

- Category: People
- Module: `shifts`
- Modes: `managed`, `custom`
- Docs: https://bettersupabase.com/docs/blocks/shifts
- Page: https://bettersupabase.com/blocks/shifts

## Install

```bash
npx better-supabase add shifts
```

The command also installs `updated-at`, `memberships`, `permissions`, `teams`.

## Configure

Add the block to `better-supabase.config.ts`:

```ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  blocks: {
    // Required by shifts; add installs them too.
    "updated-at": {},
    memberships: {},
    permissions: {},
    teams: {},
    // Modes: "managed", "custom". The default is "managed".
    shifts: { mode: "managed" },
  },
});
```

## Client

The block has no React entry yet. Its server-side TypeScript is in `better-supabase/blocks/shifts`.

## Events

- `shift.cancelled`
- `shift.created`
- `shift.published`
- `shift_assignment.created`
- `shift_assignment.released`
- `shift_swap.decided`
- `shift_swap.requested`

## Related blocks

Requires: [memberships](https://bettersupabase.com/blocks/memberships.md), [permissions](https://bettersupabase.com/blocks/permissions.md), [teams](https://bettersupabase.com/blocks/teams.md)

Works with: [employees](https://bettersupabase.com/blocks/employees.md), [leave](https://bettersupabase.com/blocks/leave.md), [qualifications](https://bettersupabase.com/blocks/qualifications.md), [time-tracking](https://bettersupabase.com/blocks/time-tracking.md), [assets](https://bettersupabase.com/blocks/assets.md), [approvals](https://bettersupabase.com/blocks/approvals.md), [notifications](https://bettersupabase.com/blocks/notifications.md), [outbox](https://bettersupabase.com/blocks/outbox.md), [audit](https://bettersupabase.com/blocks/audit.md)

## Recipes

- [Roster board](https://bettersupabase.com/recipes/roster-board.md): This week's shifts in a column per day, with their status and how many places are filled.
