# Android Tablet API (Lenovo M10)

Tablet-first workshop flow for shared Lenovo Tab M10 devices.

## Workshop session model

1. One device login creates a Sanctum bearer token.
2. The tablet selects who is doing the job from current team members.
3. Role-based `capabilities.ui` flags drive which buttons are shown.
4. Quick switch at the top changes the active worker without logging out.

Roles used on the tablet:

- `technician` — create/edit job cards and inspection drafts, submit for approval, no pricing, no approve
- `foreman` — same workshop write access plus inspection approval
- `admin` — full workshop controls including approval

## Auth + quick switch

### Login

`POST /api/v1/auth/login`

```json
{
  "email": "workshop@example.com",
  "password": "secret",
  "device_name": "lenovo-m10-bay-1"
}
```

Response includes:

- `access_token`
- `user` (device session owner)
- `active_worker` (defaults to the logged-in user)
- `capabilities` / `capabilities.ui` (button visibility)
- `team_members` (quick-switch list)

### Current session

`GET /api/v1/auth/me`

### Team members for the top switcher

`GET /api/v1/auth/team-members`

### Switch active worker

`POST /api/v1/auth/switch-worker`

```json
{ "user_id": 42 }
```

After switching, refetch lists if needed and rebuild the action bar from `capabilities.ui`:

- `show_create_job_card`
- `show_create_inspection_sheet`
- `show_submit_inspection`
- `show_approve_inspection`
- `show_billing_review`
- `show_prices`

## Job cards

Existing resource endpoints:

- `GET/POST /api/v1/job-cards`
- `GET/PUT/DELETE /api/v1/job-cards/{id}`

On create, if `user_id` is omitted the API attributes the job card to the **active worker**.

## Inspection sheets

- `GET /api/v1/inspection-sheets/form-options` — job cards, types, categories, marking codes, UI flags
- `GET /api/v1/inspection-sheets`
- `POST /api/v1/inspection-sheets`
- `GET /api/v1/inspection-sheets/{id}`
- `PUT /api/v1/inspection-sheets/{id}`
- `POST /api/v1/inspection-sheets/{id}/submit` — technician sign-off
- `POST /api/v1/inspection-sheets/{id}/approve` — foreman/admin approval

Create body:

```json
{
  "job_card_id": 10,
  "inspection_type_id": 1,
  "inspection_date": "2026-08-15",
  "sign_off": false,
  "items": [
    {
      "inspection_item_id": 100,
      "marking_code": 0,
      "is_dangerous": false,
      "remarks": null
    }
  ]
}
```

Responses include `actions` so the tablet can show only valid buttons for the current worker and sheet status.

## Lenovo M10 UI notes

- Target landscape workshop layout (~10" tablet).
- Keep a persistent top bar for active worker quick switch.
- Primary actions should be large touch targets driven by `capabilities.ui`.
- Hide approve for technicians; hide pricing for technicians.
- Prefer one task screen at a time: pick job → fill sheet → submit/approve.
