diff options
author | Sebastian <sebasjm@gmail.com> | 2024-08-27 19:01:57 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-08-27 19:01:57 -0300 |
commit | ca4bccc5de2d92333267ced69535d4400c394fb9 (patch) | |
tree | 4c53d12734aabc4863f57d9820b482052d63c127 /packages/aml-backoffice-ui/src/hooks/decisions.ts | |
parent | 94cb658024a17084da5de310bc5104cff6fd8337 (diff) |
refresh decisions history when the auditor makes decision
Diffstat (limited to 'packages/aml-backoffice-ui/src/hooks/decisions.ts')
-rw-r--r-- | packages/aml-backoffice-ui/src/hooks/decisions.ts | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/packages/aml-backoffice-ui/src/hooks/decisions.ts b/packages/aml-backoffice-ui/src/hooks/decisions.ts index de8f1637e..eb861ae14 100644 --- a/packages/aml-backoffice-ui/src/hooks/decisions.ts +++ b/packages/aml-backoffice-ui/src/hooks/decisions.ts @@ -20,10 +20,10 @@ import { OfficerAccount, OperationOk, TalerExchangeResultByMethod, - TalerHttpError + TalerHttpError, } from "@gnu-taler/taler-util"; import { useExchangeApiContext } from "@gnu-taler/web-util/browser"; -import _useSWR, { SWRHook } from "swr"; +import _useSWR, { SWRHook, mutate } from "swr"; import { useOfficer } from "./officer.js"; const useSWR = _useSWR as unknown as SWRHook; @@ -49,7 +49,7 @@ export function useCurrentDecisions(filtered?: boolean) { async function fetcher([officer, offset, investigation]: [ OfficerAccount, string | undefined, - boolean | undefined + boolean | undefined, ]) { return await api.getAmlDecisions(officer, { order: "dec", @@ -64,7 +64,9 @@ export function useCurrentDecisions(filtered?: boolean) { TalerExchangeResultByMethod<"getAmlDecisions">, TalerHttpError >( - !session ? undefined : [session, offset, filtered ? true : filtered, "getAmlDecisions"], + !session + ? undefined + : [session, offset, filtered ? true : filtered, "getAmlDecisions"], fetcher, ); @@ -77,6 +79,13 @@ export function useCurrentDecisions(filtered?: boolean) { ); } +export function revalidateAccountDecisions() { + return mutate( + (key) => Array.isArray(key) && key[key.length - 1] === "getAmlDecisions", + undefined, + { revalidate: true }, + ); +} /** * @param account * @param args |