fix(tickets): use CompanyPicker on TicketNewPage so create works (MAPPS-122) #57

Merged
longjacksonle merged 1 commit from fix/mapps-122-ticket-new-company-picker into main 2026-06-05 03:49:06 +02:00

What

Fixes MAPPS-122: clicking Create Ticket on /tickets/new did nothing - no ticket, no error.

Root cause

TicketNewPage rendered the company field as a hardcoded Select with placeholder option ids "1" / "2" / "3". On submit the handler did Uuid::parse_str(&company_v).unwrap_or_else(|_| Uuid::nil()), so a selected "1" became the nil UUID 00000000-0000-0000-0000-000000000000. The POST carried a non-existent company_id, the server rejected it, and the failure was swallowed into web_sys::console::error_1 with no user-facing surface - so the form just looked inert. MAPPS-27 wired the POST + navigation but deliberately left this placeholder dropdown in place.

Change

src/pages/tickets.rs:

  • Replaces the hardcoded company Select with the existing CompanyPicker (src/components/company_picker.rs), which searches GET /contacts/companies and reports a real company UUID via onselect. The picker's docstring already named the ticket-new form as an intended consumer. Mirrors the contacts-form wiring: company_id + company_name signals and a picker_selected_id derivation.
  • Adds an error signal rendered above the form actions. Submitting with no company shows "Please pick a company first." and does not POST; a server-side create failure is surfaced in the form instead of only the browser console. On success the page still navigates to the created ticket's detail route.

Verification

just pre-commit green: cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo check --target wasm32-unknown-unknown, and cargo test --lib (47 passed). The fix is a UI-wiring change with no new tests (the page has no harness; the picker + fetch path are exercised by the contacts form that already ships them).

🤖 Generated with Claude Code

## What Fixes [MAPPS-122](https://niceguyit.myjetbrains.com/youtrack/issue/MAPPS-122): clicking **Create Ticket** on `/tickets/new` did nothing - no ticket, no error. ## Root cause `TicketNewPage` rendered the company field as a hardcoded `Select` with placeholder option ids `"1" / "2" / "3"`. On submit the handler did `Uuid::parse_str(&company_v).unwrap_or_else(|_| Uuid::nil())`, so a selected `"1"` became the nil UUID `00000000-0000-0000-0000-000000000000`. The POST carried a non-existent `company_id`, the server rejected it, and the failure was swallowed into `web_sys::console::error_1` with no user-facing surface - so the form just looked inert. MAPPS-27 wired the POST + navigation but deliberately left this placeholder dropdown in place. ## Change `src/pages/tickets.rs`: - Replaces the hardcoded company `Select` with the existing `CompanyPicker` (`src/components/company_picker.rs`), which searches `GET /contacts/companies` and reports a real company UUID via `onselect`. The picker's docstring already named the ticket-new form as an intended consumer. Mirrors the contacts-form wiring: `company_id` + `company_name` signals and a `picker_selected_id` derivation. - Adds an `error` signal rendered above the form actions. Submitting with no company shows "Please pick a company first." and does not POST; a server-side create failure is surfaced in the form instead of only the browser console. On success the page still navigates to the created ticket's detail route. ## Verification `just pre-commit` green: `cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`, `cargo check --target wasm32-unknown-unknown`, and `cargo test --lib` (47 passed). The fix is a UI-wiring change with no new tests (the page has no harness; the picker + fetch path are exercised by the contacts form that already ships them). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(tickets): use CompanyPicker on TicketNewPage so create works (MAPPS-122)
All checks were successful
Check / clippy + fmt + tests (pull_request) Successful in 31s
Create release / Create release from merged PR (pull_request) Has been skipped
3bce482349
The New Ticket form rendered the company field as a hardcoded Select with placeholder option ids "1"/"2"/"3". On submit the handler parsed the selected value as a Uuid and fell back to the nil UUID on failure, so every create POSTed a company_id that does not exist; the server rejected it and the error was swallowed into console.error, leaving the form looking like the button did nothing. MAPPS-27 wired the POST + navigation but left this placeholder dropdown in place.

Replace the Select with the existing CompanyPicker component (searches GET /contacts/companies, reports a real company UUID via onselect), mirroring the contacts-form wiring with company_id + company_name signals and a picker_selected_id derivation. Add an error signal rendered above the form actions: submitting with no company shows "Please pick a company first." without POSTing, and a server-side create failure is surfaced in the form instead of only the browser console. On success the page still navigates to the created ticket's detail route.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
longjacksonle deleted branch fix/mapps-122-ticket-new-company-picker 2026-06-05 03:49:06 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-apps!57
No description provided.