feat(client): API client layer (PMC-2) #26
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/pmc-2-api-client-layer"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Lands the API-client layer story (PMC-2) in five commits, one per remaining valid sub-task. The stale
PMC-3(api_client scaffold) and OIDC-obsoletedPMC-4/PMC-5were already closed against main;PMC-9(portal wire) is blocked on the server's/api/v1/portal/*501 surface and was closed with a follow-up note.PMC-10: typedApiErrorenum +_typedget/post/put/delete wrappers that decode the server'sErrorResponseenvelope, plus a globalToastsurface mounted once inAppLayoutso any page can push viapush_toast/push_api_error. Existing string-returning helpers stay so live callers (companies, calendar, system_version) compile unchanged.PMC-11: drivesTableLoading/TableEmptyoff theuse_resourcesnapshot on companies, establishing the loading/empty pattern that the rest of the PR follows.PMC-6:TicketListPagefetches/ticketsand renders live rows; demo rows stay behind aDemosource for envs without a live backend. Detail/create/add-note are tracked separately under PMC-28/PMC-27/PMC-25.PMC-7:ContactListPagefetches/contacts. Companies was wired earlier; both list views in the contacts module now ride the same pattern.PMC-8:TenantManagementPage(multi-tenant only) fetches/tenants. Tenant switcher itself remains on Bunyip per the SSO migration; this surface is a super_admin read-only roster.Test plan
cargo check --features webcleancargo check --features web,multi-tenantcleancrate::hooks::toast::push_toast(AlertType::Error, "test")renders bottom-right and dismissesYouTrack
PMC-6, PMC-7, PMC-8, PMC-9, PMC-10, PMC-11 closed by this branch. PMC-2 parent story moves to Done with the final commit chain.
🤖 Generated with Claude Code
Adds an `ApiError` enum (`Network`, `Status { code, message }`, `Decode`) alongside the existing string-returning fetch helpers, plus `_typed` variants of get_authed/post_authed/put_authed/delete_authed that decode the server's `ErrorResponse` envelope so callers can react to 401/403/404/422/etc. without re-parsing strings. `ApiError::user_message` produces the copy that gets dropped straight into a toast. The toast surface is a `GlobalSignal<Vec<Toast>>` driven by `push_toast`/`push_toast_with_title` plus a `push_api_error` convenience that maps an `ApiError` to an Error-variant toast. `ToastRoot` mounts once inside `AppLayout` so every authed page is already wired; no per-page plumbing needed. The existing `Result<T, String>` helpers stay so live callers (companies, calendar, system version) keep compiling. New call sites should prefer the typed variants going forward. #PMC-10 State DonePull request closed