1. Marketing Layout: speed up rendering by retrieving user session from cookies instead of using server side request 2. Use "redirecting" state when signing in to keep displaying a loading state while Next.js redirects to home page 3. Use "useCallback" to prevent double tracking when switching pages 4. Add links pre-fetching in marketing navigation 5. Add new pending state to MFA verification form 6. Pre-fetch sign-in/sign-up pages 7. Fix i18n when using regional languages 8. currency formatter should default to the region if it exists 9. Update packages
24 lines
544 B
TypeScript
24 lines
544 B
TypeScript
/**
|
|
* Check if the code is running in a browser environment.
|
|
*/
|
|
export function isBrowser() {
|
|
return typeof window !== 'undefined';
|
|
}
|
|
|
|
/**
|
|
* @name formatCurrency
|
|
* @description Format the currency based on the currency code
|
|
*/
|
|
export function formatCurrency(params: {
|
|
currencyCode: string;
|
|
locale: string;
|
|
value: string | number;
|
|
}) {
|
|
const [lang, region] = params.locale.split('-');
|
|
|
|
return new Intl.NumberFormat(region ?? lang, {
|
|
style: 'currency',
|
|
currency: params.currencyCode,
|
|
}).format(Number(params.value));
|
|
}
|