- Replace SignupWorkflowService and GetStartedWorkflowService with new coordinator services for improved modularity and clarity. - Update auth controller to utilize the new GetStartedCoordinator. - Refactor account status handling in the GetStartedForm component to leverage XState for state management. - Introduce new hooks for managing the get-started flow, enhancing the overall user experience. - Remove deprecated services and clean up related imports to maintain code hygiene.
25 lines
795 B
TypeScript
25 lines
795 B
TypeScript
/**
|
|
* WHMCS Coercion Utilities (domain-internal)
|
|
*/
|
|
|
|
/**
|
|
* Coerce boolean-like values from WHMCS into actual booleans.
|
|
*
|
|
* Handles all shapes that WHMCS returns for boolean fields:
|
|
* - boolean → pass-through
|
|
* - number → 1 is true, everything else false
|
|
* - string → "1", "true", "yes", "on" are true (case-insensitive)
|
|
* - null / undefined → false
|
|
*/
|
|
export function coerceBoolean(value: boolean | number | string | null | undefined): boolean {
|
|
if (typeof value === "boolean") return value;
|
|
if (typeof value === "number") return value === 1;
|
|
if (typeof value === "string") {
|
|
const normalized = value.trim().toLowerCase();
|
|
return (
|
|
normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on"
|
|
);
|
|
}
|
|
return false;
|
|
}
|