# Import Suggestions

> Bank statement lines with a suggested category and booking, confirmed in one step: tick the lines that are right, change a category where it is not, and book the selection with one button.

Component · Data · Pro kit · [Live page](https://ui.twentyfirst.media/pro/components/ImportSuggestions/)

Bank statement lines with a suggested category and booking, confirmed in one step: tick the lines that
are right, change a category where it is not, and book the selection with one button.

- `lines`: date, text, counterparty, signed `amount` and a `suggestion` (`category`, `booking`,
  `confidence` 0–1, `reason`). Lines with `state: "duplicate"` or `"booked"` stay visible but cannot be picked.
- Every new line with a suggestion starts selected; "Select all" and `selected` / `onSelectedChange` control it.
- `onConfirm(ids)` books the selection; return a Promise for the pending state (and reject with an
  Error to show its message).
- `categories` with `onCategoryChange` turn the category into a picker; `onEdit(id)` opens your own editor.
- Below 560px each line folds into two rows; the confirm button spans the width.

## Example

```tsx
import * as React from "react";
import { ImportSuggestions, Panel } from "@twentyfirstmedia/pro";
import type { ImportSuggestionLine } from "@twentyfirstmedia/pro";

const LINES: ImportSuggestionLine[] = [
  {
    id: "1",
    date: "2026-10-02",
    text: "AWS EMEA SARL 1002-4471",
    counterparty: "Amazon Web Services",
    amount: -412.3,
    suggestion: {
      category: "Hosting",
      booking: "4930 Hosting ← 1200 Bank",
      confidence: 0.96,
      reason: "Same vendor as last month",
    },
  },
  {
    id: "2",
    date: "2026-10-03",
    text: "STRIPE PAYOUT 1003",
    counterparty: "Stripe",
    amount: 2318.4,
    suggestion: { category: "Revenue", booking: "1200 Bank ← 1360 Clearing", confidence: 0.91 },
  },
  {
    id: "3",
    date: "2026-10-03",
    text: "STRIPE PAYOUT 1003",
    counterparty: "Stripe",
    amount: 2318.4,
    state: "duplicate",
  },
  {
    id: "4",
    date: "2026-10-05",
    text: "BUERO KONTOR 55821",
    counterparty: "Office Supply Co.",
    amount: -86.9,
    suggestion: {
      category: "Office supplies",
      booking: "4930 Office ← 1200 Bank",
      confidence: 0.72,
    },
  },
  { id: "5", date: "2026-10-06", text: "CARD 4411 COFFEE BAR", amount: -4.2 },
  {
    id: "6",
    date: "2026-10-01",
    text: "RENT OCT 2026",
    counterparty: "Harbour Offices",
    amount: -1850,
    state: "booked",
  },
];

export default function Preview() {
  const [lines, setLines] = React.useState(LINES);
  return (
    <Panel title="Import October">
      <ImportSuggestions
        lines={lines}
        categories={["Hosting", "Revenue", "Office supplies", "Travel", "Meals", "Rent"]}
        onCategoryChange={(id, category) =>
          setLines((l) =>
            l.map((x) =>
              x.id === id && x.suggestion ? { ...x, suggestion: { ...x.suggestion, category } } : x,
            ),
          )
        }
        onEdit={() => {}}
        onConfirm={(ids) =>
          new Promise<void>((r) =>
            setTimeout(() => {
              setLines((l) => l.map((x) => (ids.includes(x.id) ? { ...x, state: "booked" } : x)));
              r();
            }, 900),
          )
        }
      />
    </Panel>
  );
}
```

## Props

### ImportSuggestions

| Prop | Type | Notes |
| --- | --- | --- |
| `surface?` | `Surface` | `"glass"` for a translucent surface over a map, photo or video; `"solid"` opts out inside a glass provider. |
| `lines` | `ImportSuggestionLine[]` | Required |
| `selected?` | `string[]` | Default: every new line with a suggestion. |
| `defaultSelected?` | `string[]` |  |
| `onSelectedChange?` | `(ids: string[]) => void` |  |
| `onConfirm?` | `(ids: string[]) => void \| Promise<void>` | Books the picked lines in one step; a Promise shows the pending state, a rejection its message. |
| `categories?` | `string[]` | With `onCategoryChange`: a category picker per line. |
| `onCategoryChange?` | `(id: string, category: string) => void` |  |
| `onEdit?` | `(id: string) => void` |  |
| `currency?` | `string` |  |
| `title?` | `string` |  |
| `busy?` | `boolean` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### Panel

| Prop | Type | Notes |
| --- | --- | --- |
| `side?` | `boolean` |  |
| `title?` | `string` |  |
| `subtitle?` | `string` |  |
| `action?` | `ReactNode` |  |
| `children?` | `ReactNode` |  |
| `surface?` | `Surface` | `"glass"`: translucent glass over what is behind (maps, 3D, video, photos); `"solid"` opts out inside a glass `UIProvider`. |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |
