# Cases

> Cases per organization: nonconformities, complaints, incidents, near misses, observations, improvements, change requests and audit findings of tenant-editable kinds, numbered per kind, each kind on its own pipeline, with a root cause, containment and corrective actions as work items, an effectiveness check, public intake through forms, and a close guard that refuses to close while a blocker remains.

- Category: Work management
- Module: `cases`
- Modes: `managed`, `custom`
- Docs: https://bettersupabase.com/docs/blocks/cases
- Page: https://bettersupabase.com/blocks/cases

## Install

```bash
npx better-supabase add cases
```

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

## Configure

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

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

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

## Client

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

## Events

- `case.cancelled`
- `case.closed`
- `case.created`
- `case.effectiveness_date_reached`
- `case.effectiveness_recorded`
- `case.reopened`
- `case.root_cause_recorded`
- `case.updated`
- `case_action.deleted`
- `case_kind.archived`
- `case_kind.created`
- `case_kind.updated`

## Related blocks

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

Works with: [tasks](https://bettersupabase.com/blocks/tasks.md), [numbering](https://bettersupabase.com/blocks/numbering.md), [forms](https://bettersupabase.com/blocks/forms.md), [relations](https://bettersupabase.com/blocks/relations.md), [drive](https://bettersupabase.com/blocks/drive.md), [approvals](https://bettersupabase.com/blocks/approvals.md), [versions](https://bettersupabase.com/blocks/versions.md), [notifications](https://bettersupabase.com/blocks/notifications.md), [outbox](https://bettersupabase.com/blocks/outbox.md), [audit](https://bettersupabase.com/blocks/audit.md), [pipelines](https://bettersupabase.com/blocks/pipelines.md), [subjects](https://bettersupabase.com/blocks/subjects.md)

## Recipes

- [Case board](https://bettersupabase.com/recipes/case-board.md): The open cases in stage columns, reported to verifying; dragging a card moves the case to that stage of its kind's pipeline.
- [Case detail](https://bettersupabase.com/recipes/case-detail.md): One case with its severity, root cause, what still blocks closing it and its actions, and a Close button once nothing blocks it.
