mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 09:14:08 +00:00
Finalize Typescript restructure
This commit is contained in:
@@ -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',
|
||||
|
||||
5
resources/scripts-v2/utils/generate-client-id.ts
Normal file
5
resources/scripts-v2/utils/generate-client-id.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import Guid from 'guid'
|
||||
|
||||
export function generateClientId(): string {
|
||||
return Guid.raw()
|
||||
}
|
||||
@@ -27,3 +27,5 @@ export {
|
||||
getErrorTranslationKey,
|
||||
} from './error-handling'
|
||||
export type { NormalizedApiError } from './error-handling'
|
||||
|
||||
export { generateClientId } from './generate-client-id'
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user