Finalize Typescript restructure

This commit is contained in:
Darko Gjorgjijoski
2026-04-06 17:59:15 +02:00
parent cab785172e
commit 74b4b2df4e
209 changed files with 12419 additions and 1745 deletions

View File

@@ -33,6 +33,7 @@ export interface NormalizedApiError {
*/
const ERROR_TRANSLATION_MAP: Record<string, string> = {
'These credentials do not match our records.': 'errors.login_invalid_credentials',
'The provided credentials are incorrect.': 'errors.login_invalid_credentials',
'invalid_key': 'errors.invalid_provider_key',
'This feature is available on Starter plan and onwards!': 'errors.starter_plan',
'taxes_attached': 'settings.tax_types.already_in_use',

View File

@@ -0,0 +1,5 @@
import Guid from 'guid'
export function generateClientId(): string {
return Guid.raw()
}

View File

@@ -27,3 +27,5 @@ export {
getErrorTranslationKey,
} from './error-handling'
export type { NormalizedApiError } from './error-handling'
export { generateClientId } from './generate-client-id'

View File

@@ -25,6 +25,26 @@ export function get<T>(key: string): T | null {
}
}
/**
* Retrieve a boolean from localStorage while tolerating legacy string values.
*
* @param key - The localStorage key
* @returns True only when the stored value represents a truthy boolean
*/
export function getBoolean(key: string): boolean {
const value = get<boolean | string>(key)
if (typeof value === 'boolean') {
return value
}
if (typeof value === 'string') {
return value.toLowerCase() === 'true'
}
return false
}
/**
* Store a value in localStorage as JSON.
*