aboutsummaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui/src/hooks/index.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-01-03 01:57:39 -0300
committerSebastian <sebasjm@gmail.com>2023-01-03 01:58:18 -0300
commita2668c22f0d18386fc988f27299172145d9fa15d (patch)
tree38f06046ce4d71ee3af64ede931754bfae6dc954 /packages/merchant-backoffice-ui/src/hooks/index.ts
parentd1aa79eae817b1cf4c23f800308ecad101692ac7 (diff)
downloadwallet-core-a2668c22f0d18386fc988f27299172145d9fa15d.tar.xz
refactor better QA
removed axios, use fetch removed jest, added mocha and chai moved the default request handler to runtime dependency (so it can be replaced for testing) refactored ALL the test to the standard web-utils all hooks now use ONE request handler moved the tests from test folder to src
Diffstat (limited to 'packages/merchant-backoffice-ui/src/hooks/index.ts')
-rw-r--r--packages/merchant-backoffice-ui/src/hooks/index.ts15
1 files changed, 14 insertions, 1 deletions
diff --git a/packages/merchant-backoffice-ui/src/hooks/index.ts b/packages/merchant-backoffice-ui/src/hooks/index.ts
index 0581d9938..bb210c9ba 100644
--- a/packages/merchant-backoffice-ui/src/hooks/index.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/index.ts
@@ -59,6 +59,7 @@ export function useBackendDefaultToken(
export function useBackendInstanceToken(
id: string,
): [string | undefined, StateUpdater<string | undefined>] {
+ const [random, setRandom] = useState(0);
const [token, setToken] = useLocalStorage(`backend-token-${id}`);
const [defaultToken, defaultSetToken] = useBackendDefaultToken();
@@ -66,8 +67,20 @@ export function useBackendInstanceToken(
if (id === "default") {
return [defaultToken, defaultSetToken];
}
+ function updateToken(
+ value:
+ | (string | undefined)
+ | ((s: string | undefined) => string | undefined),
+ ): void {
+ setToken((p) => {
+ const toStore = value instanceof Function ? value(p) : value;
+ // setToken(value)
+ setRandom(new Date().getTime());
+ return toStore;
+ });
+ }
- return [token, setToken];
+ return [token, updateToken];
}
export function useLang(initial?: string): [string, StateUpdater<string>] {