fix(contracts): align contract dropdown values with backend CHECK constraints (MAPPS-190) #178
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/MAPPS-190-contract-dropdown-values"
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?
What
The contract create/edit form in
src/pages/contracts.rspopulated its Type, billing cycle, and line-item Type dropdowns withSelectOptionVALUES that did not match the mokosh-server backend CHECK constraints. The default Contract Type ("Managed Services") submittedmanaged, which the backend rejects with a 422, so creating a contract failed out of the box. The filter dropdown and the contract-type humanize/badge helpers used the same wrong tags, so listing/filtering and label rendering would break once any record stored a correct value.Change
Aligned all option VALUE strings to the authoritative backend set (labels kept human-readable):
managed->managed_services,time_materials->time_and_materials, addedwarranty(now: managed_services, block_hours, time_and_materials, fixed_price, warranty). Form default changedmanaged->managed_services.annual->annually(now: monthly, quarterly, annually, one_time).recurring->recurring_service, removed bogususage, addedretainerandproduct(now: recurring_service, block_hours, retainer, product, one_time). Both hardcoded item defaults (Add Item button and submit fallback) changedrecurring->recurring_service.humanize_contract_type/contract_type_varianthelpers to the same values so filtering and badges match stored data.Authoritative sources confirmed by grep:
mokosh-server/src/utils/validation.rs(CONTRACT_TYPES) andmokosh-server/migrations/009_contracts.sql(CHECK on billing_cycle and contract_line_items.item_type).Testing
In
ghcr.io/niceguyit/rust-builder-glibc:v1.0.1-rust1.94-trixie:cargo fmt --all --checkcleancargo clippy --all-targets -- -D warningsno warningscargo check --target wasm32-unknown-unknownpasses