BaaS_Driver_Android_App/utils/Common.ts

22 lines
598 B
TypeScript

import { router, type Href } from "expo-router";
import type { NavigationOptions } from "expo-router/build/global-state/routing";
export const displayValue = (value: any, formatter?: (val: any) => string) => {
if (value === null || value === undefined || value === "") {
return "--";
}
return formatter ? formatter(value) : value;
};
export const formatCurrency = (amount: number) => {
return `${amount.toLocaleString()}`;
};
export const clearStackAndRouteTo = (
link: Href,
options?: NavigationOptions
): void => {
router.dismissAll();
router.replace(link, options);
};