Status Standardization Guide¶
Overview¶
This guide explains the status standardization initiative in the PRS system. The goal is to ensure consistent naming conventions for status values across all workflows.
Why Standardize Status Values?¶
- Consistency: Makes the codebase more consistent and easier to understand
- Maintainability: Reduces bugs caused by inconsistent status comparisons
- Type Safety: Using constants instead of raw strings provides better type checking
- Documentation: Makes it clear what status values are valid for each entity
- Refactoring: Makes it easier to refactor status-related code
Status Naming Convention¶
- Constant Keys: All constant keys will use UPPERCASE with underscores (SCREAMING_SNAKE_CASE)
- Constant Values: All constant values will use lowercase with underscores (snake_case)
- Constant Usage: All status comparisons will use constants, not raw strings
- Immutability: All constant objects will use
Object.freeze()to prevent modification
Example¶
| JavaScript | |
|---|---|
Standard Status Constants¶
Requisition Status¶
Canvass Status¶
| JavaScript | |
|---|---|
Purchase Order Status¶
| JavaScript | |
|---|---|
How to Standardize Your Code¶
- Find Raw Status Strings: Use the
find-raw-status-strings.jsscript to find raw status strings in your code - Import Constants: Import the appropriate constants at the top of your file
- Replace Raw Strings: Replace all raw strings with constant references
- Verify: Run the script again to verify all raw strings are replaced
- Test: Run tests to ensure everything still works correctly
Database Considerations¶
If your changes affect database records, you'll need to:
- Create a migration script to update existing records
- Test the migration script in a development environment
- Include the migration script in your PR
Frontend Considerations¶
If your changes affect the frontend, you'll need to:
- Update any status display components
- Update any status-based conditional rendering
- Update any API requests that filter by status