This uses the `any` escape hatch a few more places, which should be tidied up later. Suggest upgrading redux usage to the latest version and start using slices to make a few things easier. Also the confetti component might be worth replacing Remove dead code from the old membership charge flow++
17 lines
499 B
TypeScript
17 lines
499 B
TypeScript
export function snakeToCamelCase(val: string): string {
|
|
return val.replace(/_([a-z])/g, (g) => g[1].toUpperCase());
|
|
}
|
|
|
|
export function fetchWithTimeout(url: string, options?: RequestInit, timeout = 10000) {
|
|
/** Wraps fetch to allow it to time out */
|
|
// FIXME: show timeout message in UI
|
|
return Promise.race([
|
|
fetch(url, options),
|
|
new Promise<Response>((_, reject) => {
|
|
setTimeout(() => {
|
|
reject(new Error('Fetch request timed out'));
|
|
}, timeout);
|
|
}),
|
|
]);
|
|
}
|