diff options
| author | Sebastian <sebasjm@gmail.com> | 2023-09-29 16:02:15 -0300 |
|---|---|---|
| committer | Sebastian <sebasjm@gmail.com> | 2023-09-29 16:02:15 -0300 |
| commit | 1708d49a2d5da1f325173a030695223e5a24e75c (patch) | |
| tree | 048995ac199c171e34fd7d99678c9699fe3321fc /packages/demobank-ui/src/pages/admin | |
| parent | c10f3f3aded637111176487f95403294b1164633 (diff) | |
more ui
Diffstat (limited to 'packages/demobank-ui/src/pages/admin')
| -rw-r--r-- | packages/demobank-ui/src/pages/admin/AccountForm.tsx | 8 | ||||
| -rw-r--r-- | packages/demobank-ui/src/pages/admin/Home.tsx | 2 | ||||
| -rw-r--r-- | packages/demobank-ui/src/pages/admin/RemoveAccount.tsx | 65 |
3 files changed, 13 insertions, 62 deletions
diff --git a/packages/demobank-ui/src/pages/admin/AccountForm.tsx b/packages/demobank-ui/src/pages/admin/AccountForm.tsx index 02df824a2..ed8bf610d 100644 --- a/packages/demobank-ui/src/pages/admin/AccountForm.tsx +++ b/packages/demobank-ui/src/pages/admin/AccountForm.tsx @@ -4,6 +4,7 @@ import { PartialButDefined, RecursivePartial, WithIntermediate, undefinedIfEmpty import { useEffect, useRef, useState } from "preact/hooks"; import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { buildPayto, parsePaytoUri } from "@gnu-taler/taler-util"; +import { doAutoFocus } from "../PaytoWireTransferForm.js"; const IBAN_REGEX = /^[A-Z][A-Z0-9]*$/; const EMAIL_REGEX = @@ -37,10 +38,6 @@ export function AccountForm({ RecursivePartial<typeof initial> | undefined >(undefined); const { i18n } = useTranslationContext(); - const ref = useRef<HTMLInputElement>(null); - useEffect(() => { - if (focus) ref.current?.focus(); - }, [focus]); function updateForm(newForm: typeof initial): void { @@ -97,7 +94,6 @@ export function AccountForm({ <div class="px-4 py-6 sm:p-8"> <div class="grid max-w-2xl grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6"> - <div class="sm:col-span-5"> <label class="block text-sm font-medium leading-6 text-gray-900" @@ -108,7 +104,7 @@ export function AccountForm({ </label> <div class="mt-2"> <input - ref={ref} + ref={focus ? doAutoFocus : undefined} type="text" class="block w-full disabled:bg-gray-100 rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 data-[error=true]:ring-red-500 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6" name="username" diff --git a/packages/demobank-ui/src/pages/admin/Home.tsx b/packages/demobank-ui/src/pages/admin/Home.tsx index ffa559097..d50ff14b4 100644 --- a/packages/demobank-ui/src/pages/admin/Home.tsx +++ b/packages/demobank-ui/src/pages/admin/Home.tsx @@ -10,6 +10,7 @@ import { AdminAccount } from "./Account.js"; import { AccountList } from "./AccountList.js"; import { CreateNewAccount } from "./CreateNewAccount.js"; import { RemoveAccount } from "./RemoveAccount.js"; +import { Transactions } from "../../components/Transactions/index.js"; /** * Query account information and show QR code if there is pending withdrawal @@ -141,6 +142,7 @@ export function AdminHome({ onRegister }: Props): VNode { <AdminAccount onRegister={onRegister} /> + <Transactions account="admin"/> </Fragment> ); }
\ No newline at end of file diff --git a/packages/demobank-ui/src/pages/admin/RemoveAccount.tsx b/packages/demobank-ui/src/pages/admin/RemoveAccount.tsx index 1e5370afc..b323b0d01 100644 --- a/packages/demobank-ui/src/pages/admin/RemoveAccount.tsx +++ b/packages/demobank-ui/src/pages/admin/RemoveAccount.tsx @@ -6,6 +6,8 @@ import { Amounts, HttpStatusCode, TranslatedString } from "@gnu-taler/taler-util import { buildRequestErrorMessage, undefinedIfEmpty } from "../../utils.js"; import { useEffect, useRef, useState } from "preact/hooks"; import { ShowInputErrorLabel } from "../../components/ShowInputErrorLabel.js"; +import { Attention } from "../../components/Attention.js"; +import { doAutoFocus } from "../PaytoWireTransferForm.js"; export function RemoveAccount({ account, @@ -36,47 +38,15 @@ export function RemoveAccount({ } return onLoadNotOk(result); } - const ref = useRef<HTMLInputElement>(null); - useEffect(() => { - if (focus) ref.current?.focus(); - }, [focus]); - const balance = Amounts.parse(result.data.balance.amount); if (!balance) { return <div>there was an error reading the balance</div>; } const isBalanceEmpty = Amounts.isZero(balance); if (!isBalanceEmpty) { - return <div> - <div class="rounded-md bg-yellow-50 p-4"> - <div class="flex"> - <div class="flex-shrink-0"> - <svg class="h-5 w-5 text-yellow-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"> - <path fill-rule="evenodd" d="M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd" /> - </svg> - </div> - <div class="ml-3"> - <h3 class="text-sm font-medium text-yellow-800"> - <i18n.Translate>Can't delete the account</i18n.Translate> - </h3> - <div class="mt-2 text-sm text-yellow-700"> - <p> - <i18n.Translate>The account can't be delete while still holding some balance. First make sure that the owner make a complete cashout.</i18n.Translate> - </p> - </div> - </div> - - </div> - </div> - <div class="mt-2 flex justify-end"> - <button type="button" class="rounded-md ring-1 ring-gray-400 bg-white px-3 py-2 text-sm font-semibold shadow-sm hover:bg-gray-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 " - onClick={() => { - onCancel() - }}> - <i18n.Translate>Go back</i18n.Translate> - </button> - </div> - </div> + return <Attention type="warning" title={i18n.str`Can't delete the account`} onClose={onCancel}> + <i18n.Translate>The account can't be delete while still holding some balance. First make sure that the owner make a complete cashout.</i18n.Translate> + </Attention> } async function doRemove() { @@ -117,26 +87,9 @@ export function RemoveAccount({ return ( <div> - <div class="rounded-md bg-yellow-50 p-4"> - <div class="flex"> - <div class="flex-shrink-0"> - <svg class="h-5 w-5 text-yellow-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"> - <path fill-rule="evenodd" d="M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd" /> - </svg> - </div> - <div class="ml-3"> - <h3 class="text-sm font-bold text-yellow-800"> - <i18n.Translate>You are going to remove the account</i18n.Translate> - </h3> - <div class="mt-2 text-sm text-yellow-700"> - <p> - <i18n.Translate>This step can't be undone.</i18n.Translate> - </p> - </div> - </div> - - </div> - </div> + <Attention type="warning" title={i18n.str`You are going to remove the account`}> + <i18n.Translate>This step can't be undone.</i18n.Translate> + </Attention> <div class="grid grid-cols-1 gap-x-8 gap-y-8 pt-10 md:grid-cols-3 bg-gray-100 my-4 px-4 pb-4 rounded-lg"> <div class="px-4 sm:px-0"> @@ -164,7 +117,7 @@ export function RemoveAccount({ </label> <div class="mt-2"> <input - ref={ref} + ref={focus ? doAutoFocus : undefined} type="text" class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 data-[error=true]:ring-red-500 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6" name="password" |
