Skip to content

fix(ui): onboarding error toast + JobForm draft floor + typed submit params (SC-112, SC-123, SC-124) - #334

Merged
thinkclay merged 1 commit into
mainfrom
fix/sc-112-123-124-ui-polish
Jun 9, 2026
Merged

thinkclay merged 1 commit into
mainfrom
fix/sc-112-123-124-ui-polish

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Summary

Bundles the three v1.9.0 UI polish tickets — all in-repo, no submodule.

SC-112 — onboarding submission error UX

apps/scaffald/app/(protected)/onboarding/index.tsx:99

  • The form-level catch in onSubmit only console.errors, so the mutation's onError toast is the only user-visible signal of failure.
  • Tightened it: title is "Couldn't save profile" (problem-first, not generic "Error"); the fallback message names connection and retry as the next action; duration bumped to 10s so the user has time to read it and tap Submit again.

SC-123 — JobForm "Save as Draft" disable predicate drift

packages/scf-core/features/office/components/JobForm.tsx:1304

  • Draft button enabled on truthy title / non-empty description / organization set — laxer than the server's createJobBodySchema (.min(3) / .max(100) title, .min(10) description from SC-122). Users could tap into a guaranteed 400.
  • New memoized meetsDraftMinimums mirrors the server floor (title.trim() >= 3, descriptionPlainText.trim() >= 10, org set). Both Save-as-Draft and Post/Schedule reuse it; Post additionally still requires location + a future scheduled_publish_at if set.

SC-124 — JobForm.handleSubmit unsafe Record cast

packages/scf-core/features/office/components/JobForm.tsx:482 (pre-refactor line)

  • handleSubmit built a Record<string, unknown> then double-cast (as unknown as Parameters<typeof createJob.mutate>[0]). A missing required field surfaced only at the server 400.
  • New buildJobParams(asDraft) returns a typed OfficeCreateJobParams literal. The mutation call sites are type-checked end-to-end — no unknown casts. Update path threads the same builder through OfficeUpdateJobParams.
  • The old for-loop copied every truthy form field into the payload, but the server route's Zod schema strips unknown keys, so the new typed builder is behaviorally equivalent for valid inputs. handleSubmit also re-checks meetsDraftMinimums and toasts a clear error if invoked while disabled (belt-and-suspenders).

Test plan

  • pnpm exec tsc -p packages/scf-core --noEmit clean.
  • pnpm exec tsc -p apps/scaffald --noEmit clean.
  • pnpm prepush (affected build + test) green.
  • pnpm web boots without runtime errors.
  • Reviewer sanity-check: logged-in employer creates a job — short title (≤2 chars) keeps the Save-as-Draft button disabled; bumping to 3 chars + 10-char description enables it; submit lands the job. Onboarding submission with the API down shows the new toast for ≥10s.

Closes SC-112, SC-123, SC-124.

🤖 Generated with Claude Code

…params (SC-112, SC-123, SC-124)

SC-112 — onboarding submission errors:

- `completeMutation.onError` was the only user-visible signal that the
  prerequisites form failed to save; the form-level `catch` only
  `console.error`s. The toast title was a generic "Error", the message
  was a 6-word "Please try again", and the duration was the default
  6000ms — easy to miss.
- Toast now leads with "Couldn't save profile" (the problem), the
  fallback message names connection + retry as the action, and the
  duration is bumped to 10000ms so the user can read it and tap Submit
  again.

SC-123 — JobForm "Save as Draft" disable predicate drift:

- The draft button enabled on `formData.title` truthy / description
  non-empty / organization set, which is laxer than the server's
  `createJobBodySchema` (title `.min(3).max(100)`, description
  `.min(10)`, per SC-122). Users could tap into a guaranteed-fail 400.
- Predicate now requires `title.trim().length >= 3`,
  `descriptionPlainText.trim().length >= 10`, and an `organization_id`
  — extracted as a memoized `meetsDraftMinimums`. The Post/Schedule
  button reuses the same floor plus its existing location + future-
  date requirements.

SC-124 — JobForm.handleSubmit unsafe Record cast:

- Submit data was built as `Record<string, unknown>` and double-cast
  (`as unknown as Parameters<typeof createJob.mutate>[0]`) into the
  typed mutation params. A missing required field was caught only by
  the server 400, not at compile time.
- New `buildJobParams(asDraft)` returns a typed `OfficeCreateJobParams`
  literal. The mutation calls are now type-checked end-to-end; no
  `unknown` casts. The update path threads through the same builder
  into `OfficeUpdateJobParams`. As a safety net, handleSubmit also
  re-checks `meetsDraftMinimums` and toasts a clear "missing required
  fields" message if somehow invoked while disabled.

The for-loop that previously copied every truthy form field into the
payload was dropping all of them server-side anyway (the route's Zod
schema strips unknown keys), so the new typed builder is behaviorally
equivalent for valid inputs.

Verified:
- `pnpm exec tsc -p packages/scf-core --noEmit` clean.
- `pnpm exec tsc -p apps/scaffald --noEmit` clean.
- Web app boots without runtime errors (`preview_start` + load `/`).
- End-to-end UI flows (logged-in employer creating a job; onboarding
  submission failure path) not exercised in this session — reviewer
  sanity-check welcome.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
thinkclay added a commit that referenced this pull request Jun 9, 2026
…shot)

Moves the three v1.9.0 UI polish tickets from Todo to In Github with
fix comments linking to PR #334.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Test Results

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ❌ ±0 

Results for commit 1dafe06. ± Comparison against base commit ced6591.

@thinkclay
thinkclay merged commit 5473d98 into main Jun 9, 2026
7 of 12 checks passed
@thinkclay
thinkclay deleted the fix/sc-112-123-124-ui-polish branch June 9, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant