diff options
Diffstat (limited to 'packages/aml-backoffice-ui/src/utils/converter.ts')
-rw-r--r-- | packages/aml-backoffice-ui/src/utils/converter.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/packages/aml-backoffice-ui/src/utils/converter.ts b/packages/aml-backoffice-ui/src/utils/converter.ts new file mode 100644 index 000000000..d2f05ed84 --- /dev/null +++ b/packages/aml-backoffice-ui/src/utils/converter.ts @@ -0,0 +1,31 @@ +import { AmlExchangeBackend } from "./types.js"; + +export const amlStateConverter = { + toStringUI: stringifyAmlState, + fromStringUI: parseAmlState, +}; + +function stringifyAmlState(s: AmlExchangeBackend.AmlState | undefined): string { + if (s === undefined) return ""; + switch (s) { + case AmlExchangeBackend.AmlState.normal: + return "normal"; + case AmlExchangeBackend.AmlState.pending: + return "pending"; + case AmlExchangeBackend.AmlState.frozen: + return "frozen"; + } +} + +function parseAmlState(s: string | undefined): AmlExchangeBackend.AmlState { + switch (s) { + case "normal": + return AmlExchangeBackend.AmlState.normal; + case "pending": + return AmlExchangeBackend.AmlState.pending; + case "frozen": + return AmlExchangeBackend.AmlState.frozen; + default: + throw Error(`unknown AML state: ${s}`); + } +} |