diff options
author | Sebastian <sebasjm@gmail.com> | 2024-06-19 10:17:19 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-06-19 10:17:19 -0300 |
commit | fdad16202750ef3bf5102870d66edb9b8383a8d4 (patch) | |
tree | 7793c1331e9a0f55a08dea190a86c39ed72e909e /packages/merchant-backoffice-ui/src | |
parent | 3418a2fcb4b73374b5433052d05978cf9212093c (diff) | |
download | wallet-core-fdad16202750ef3bf5102870d66edb9b8383a8d4.tar.xz |
parse x-taler-bank account when comparing
Diffstat (limited to 'packages/merchant-backoffice-ui/src')
-rw-r--r-- | packages/merchant-backoffice-ui/src/components/modal/index.tsx | 32 | ||||
-rw-r--r-- | packages/merchant-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx | 4 |
2 files changed, 31 insertions, 5 deletions
diff --git a/packages/merchant-backoffice-ui/src/components/modal/index.tsx b/packages/merchant-backoffice-ui/src/components/modal/index.tsx index ce0df75ca..ba32950b5 100644 --- a/packages/merchant-backoffice-ui/src/components/modal/index.tsx +++ b/packages/merchant-backoffice-ui/src/components/modal/index.tsx @@ -297,6 +297,28 @@ interface CompareAccountsModalProps { testPayto: PaytoUri; } +function getHostFromHostPath(s: string | undefined) { + if (!s) return undefined; + try { + const u = new URL(`https://${s}`); + const endpath = u.pathname.lastIndexOf("/"); + return u.origin + u.pathname.substring(0, endpath); + } catch (e) { + return undefined; + } +} + +function getAccountIdFromHostPath(s: string | undefined) { + if (!s) return undefined; + try { + const u = new URL(`https://${s}`); + const endpath = u.pathname.lastIndexOf("/"); + return u.pathname.substring(endpath + 1); + } catch (e) { + return undefined; + } +} + export function CompareAccountsModal({ onCancel, onConfirm, @@ -365,15 +387,17 @@ export function CompareAccountsModal({ <td> <i18n.Translate>Host</i18n.Translate> </td> - <td>{formPayto?.targetPath ?? "--"}</td> - <td>{testPayto.targetPath}</td> + <td>{getHostFromHostPath(formPayto?.targetPath) ?? "--"}</td> + <td>{getHostFromHostPath(testPayto.targetPath)}</td> </tr> <tr> <td> <i18n.Translate>Account id</i18n.Translate> </td> - <td>{formPayto?.targetPath ?? "--"}</td> - <td>{testPayto.targetPath}</td> + <td> + {getAccountIdFromHostPath(formPayto?.targetPath) ?? "--"} + </td> + <td>{getAccountIdFromHostPath(testPayto.targetPath)}</td> </tr> </Fragment> )} diff --git a/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx index 21be44a39..8684eb90d 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx @@ -21,6 +21,7 @@ import { HttpStatusCode, + PaytoString, PaytoUri, TalerError, TalerMerchantApi, @@ -62,6 +63,7 @@ export function CreatePage({ onCreate, onBack }: Props): VNode { const [importing, setImporting] = useState(false); const [revenuePayto, setRevenuePayto] = useState<PaytoUri | undefined>( + // parsePaytoUri("payto://x-taler-bank/asd.com:1010/asd/pepe"), undefined, ); const [state, setState] = useState<Partial<Entity>>({}); @@ -210,7 +212,7 @@ export function CreatePage({ onCreate, onBack }: Props): VNode { name="payto_uri" label={i18n.str`Account details`} /> - <div class="message-body" style={{marginBottom: 10}}> + <div class="message-body" style={{ marginBottom: 10 }}> <p> <i18n.Translate> If the bank supports Taler Revenue API then you can add the |