diff options
Diffstat (limited to 'packages/demobank-ui/src/utils.ts')
-rw-r--r-- | packages/demobank-ui/src/utils.ts | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/packages/demobank-ui/src/utils.ts b/packages/demobank-ui/src/utils.ts index e1d35a2b5..0dc24e468 100644 --- a/packages/demobank-ui/src/utils.ts +++ b/packages/demobank-ui/src/utils.ts @@ -43,30 +43,42 @@ export function getIbanFromPayto(url: string): string { return iban; } -const maybeRootPath = "https://bank.demo.taler.net/demobanks/default/"; - -export function getBankBackendBaseUrl(): string { - const overrideUrl = localStorage.getItem("bank-base-url"); - return canonicalizeBaseUrl(overrideUrl ? overrideUrl : maybeRootPath); -} - export function undefinedIfEmpty<T extends object>(obj: T): T | undefined { return Object.keys(obj).some((k) => (obj as any)[k] !== undefined) ? obj : undefined; } +export type PartialButDefined<T> = { + [P in keyof T]: T[P] | undefined; +}; + +export type WithIntermediate<Type extends object> = { + [prop in keyof Type]: Type[prop] extends object ? WithIntermediate<Type[prop]> : (Type[prop] | undefined); +} + +// export function partialWithObjects<T extends object>(obj: T | undefined, () => complete): WithIntermediate<T> { +// const root = obj === undefined ? {} : obj; +// return Object.entries(root).([key, value]) => { + +// }) +// return undefined as any +// } + /** * Craft headers with Authorization and Content-Type. */ -export function prepareHeaders(username?: string, password?: string): Headers { - const headers = new Headers(); - if (username && password) { - headers.append( - "Authorization", - `Basic ${window.btoa(`${username}:${password}`)}`, - ); - } - headers.append("Content-Type", "application/json"); - return headers; -} +// export function prepareHeaders(username?: string, password?: string): Headers { +// const headers = new Headers(); +// if (username && password) { +// headers.append( +// "Authorization", +// `Basic ${window.btoa(`${username}:${password}`)}`, +// ); +// } +// headers.append("Content-Type", "application/json"); +// return headers; +// } + +export const PAGE_SIZE = 20; +export const MAX_RESULT_SIZE = PAGE_SIZE * 2 - 1; |