centered forms, show balance in accont info

This commit is contained in:
Sebastian 2023-03-06 15:12:43 -03:00
parent 8743db9e40
commit 8f32ad272d
No known key found for this signature in database
GPG Key ID: 173909D1A5F66069
2 changed files with 257 additions and 225 deletions

View File

@ -99,6 +99,11 @@ type Amount = string;
type UUID = string; type UUID = string;
type Integer = number; type Integer = number;
interface Balance {
amount: Amount;
credit_debit_indicator: "credit" | "debit";
}
namespace SandboxBackend { namespace SandboxBackend {
export interface Config { export interface Config {
// Name of this API, always "circuit". // Name of this API, always "circuit".
@ -161,10 +166,7 @@ namespace SandboxBackend {
interface BankAccountBalanceResponse { interface BankAccountBalanceResponse {
// Available balance on the account. // Available balance on the account.
balance: { balance: Balance;
amount: Amount;
credit_debit_indicator: "credit" | "debit";
};
// payto://-URI of the account. (New) // payto://-URI of the account. (New)
paytoUri: string; paytoUri: string;
} }
@ -304,6 +306,9 @@ namespace SandboxBackend {
// Legal subject owning the account. // Legal subject owning the account.
name: string; name: string;
// current balance of the account
balance: Balance;
} }
interface CircuitAccountData { interface CircuitAccountData {

View File

@ -230,7 +230,10 @@ export function AdminPage({ onLoadNotOk }: Props): VNode {
</div> </div>
</p> </p>
<section id="main"> <section
id="main"
style={{ width: 600, marginLeft: "auto", marginRight: "auto" }}
>
{!customers.length ? ( {!customers.length ? (
<div></div> <div></div>
) : ( ) : (
@ -242,12 +245,18 @@ export function AdminPage({ onLoadNotOk }: Props): VNode {
<tr> <tr>
<th>{i18n.str`Username`}</th> <th>{i18n.str`Username`}</th>
<th>{i18n.str`Name`}</th> <th>{i18n.str`Name`}</th>
<th></th> <th>{i18n.str`Balance`}</th>
<th></th> <th>{i18n.str`Actions`}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{customers.map((item, idx) => { {customers.map((item, idx) => {
const balance = !item.balance
? undefined
: Amounts.parse(item.balance.amount);
const balanceIsDebit =
item.balance &&
item.balance.credit_debit_indicator == "debit";
return ( return (
<tr key={idx}> <tr key={idx}>
<td> <td>
@ -262,6 +271,20 @@ export function AdminPage({ onLoadNotOk }: Props): VNode {
</a> </a>
</td> </td>
<td>{item.name}</td> <td>{item.name}</td>
<td>
{!balance ? (
i18n.str`unknown`
) : (
<span class="amount">
{balanceIsDebit ? <b>-</b> : null}
<span class="value">{`${Amounts.stringifyValue(
balance,
)}`}</span>
&nbsp;
<span class="currency">{`${balance.currency}`}</span>
</span>
)}
</td>
<td> <td>
<a <a
href="#" href="#"
@ -272,8 +295,7 @@ export function AdminPage({ onLoadNotOk }: Props): VNode {
> >
change password change password
</a> </a>
</td> &nbsp;
<td>
<a <a
href="#" href="#"
onClick={(e) => { onClick={(e) => {
@ -283,8 +305,7 @@ export function AdminPage({ onLoadNotOk }: Props): VNode {
> >
cashouts cashouts
</a> </a>
</td> &nbsp;
<td>
<a <a
href="#" href="#"
onClick={(e) => { onClick={(e) => {
@ -384,6 +405,7 @@ export function UpdateAccountPassword({
<ErrorBannerFloat error={error} onClear={() => saveError(undefined)} /> <ErrorBannerFloat error={error} onClear={() => saveError(undefined)} />
)} )}
<div style={{ maxWidth: 600, overflowX: "hidden", margin: "auto" }}>
<form class="pure-form"> <form class="pure-form">
<fieldset> <fieldset>
<label>{i18n.str`Password`}</label> <label>{i18n.str`Password`}</label>
@ -461,6 +483,7 @@ export function UpdateAccountPassword({
</div> </div>
</p> </p>
</div> </div>
</div>
); );
} }
@ -488,6 +511,7 @@ function CreateNewAccount({
<ErrorBannerFloat error={error} onClear={() => saveError(undefined)} /> <ErrorBannerFloat error={error} onClear={() => saveError(undefined)} />
)} )}
<div style={{ maxWidth: 600, overflowX: "hidden", margin: "auto" }}>
<AccountForm <AccountForm
template={undefined} template={undefined}
purpose="create" purpose="create"
@ -564,6 +588,7 @@ function CreateNewAccount({
</div> </div>
</p> </p>
</div> </div>
</div>
); );
} }
@ -608,6 +633,7 @@ export function ShowAccountDetails({
{error && ( {error && (
<ErrorBannerFloat error={error} onClear={() => saveError(undefined)} /> <ErrorBannerFloat error={error} onClear={() => saveError(undefined)} />
)} )}
<div style={{ maxWidth: 600, overflowX: "hidden", margin: "auto" }}>
<AccountForm <AccountForm
template={result.data} template={result.data}
purpose={update ? "update" : "show"} purpose={update ? "update" : "show"}
@ -693,6 +719,7 @@ export function ShowAccountDetails({
</div> </div>
</p> </p>
</div> </div>
</div>
); );
} }