freshyo/apps/user-ui/src/lib/string-manipulators.ts
2026-02-08 01:45:50 +05:30

27 lines
898 B
TypeScript

/**
* String manipulation utilities for the user UI
*
* This file contains helper functions for transforming and formatting
* strings throughout the application. These utilities ensure consistent
* display formatting across all components.
*/
/**
* Transforms delivery status for display.
*
* Why: The term "Pending" can be confusing for users as it implies
* uncertainty. "Confirmed" provides clearer communication that the
* order has been received and acknowledged by the system.
*
* @param status - The raw delivery status from API
* @returns User-friendly status label
* @example
* orderStatusManipulator('pending') // returns 'Confirmed'
* orderStatusManipulator('packaged') // returns 'packaged' (unchanged)
*/
export const orderStatusManipulator = (status: string): string => {
if (status.toLowerCase() === 'pending') {
return 'Confirmed';
}
return status;
};