fix missing props

This commit is contained in:
Sebastian 2023-02-20 10:18:02 -03:00
parent aa20812fba
commit c191a2da86
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
3 changed files with 41 additions and 11 deletions

View File

@ -32,6 +32,7 @@ describe("Transaction states", () => {
const props: Props = { const props: Props = {
account: "123", account: "123",
onSelected: () => { null },
}; };
env.addRequestExpectation(TRANSACTION_API_EXAMPLE.LIST_FIRST_PAGE, { env.addRequestExpectation(TRANSACTION_API_EXAMPLE.LIST_FIRST_PAGE, {
@ -116,6 +117,7 @@ describe("Transaction states", () => {
const props: Props = { const props: Props = {
account: "123", account: "123",
onSelected: () => { null },
}; };
env.addRequestExpectation(TRANSACTION_API_EXAMPLE.LIST_NOT_FOUND, {}); env.addRequestExpectation(TRANSACTION_API_EXAMPLE.LIST_NOT_FOUND, {});
@ -149,6 +151,7 @@ describe("Transaction states", () => {
const props: Props = { const props: Props = {
account: "123", account: "123",
onSelected: () => { null },
}; };
env.addRequestExpectation(TRANSACTION_API_EXAMPLE.LIST_ERROR, {}); env.addRequestExpectation(TRANSACTION_API_EXAMPLE.LIST_ERROR, {});

View File

@ -40,6 +40,7 @@ import {
WithIntermediate, WithIntermediate,
} from "../utils.js"; } from "../utils.js";
import { ErrorBanner } from "./BankFrame.js"; import { ErrorBanner } from "./BankFrame.js";
import { ShowCashoutDetails } from "./BusinessAccount.js";
import { ShowInputErrorLabel } from "./ShowInputErrorLabel.js"; import { ShowInputErrorLabel } from "./ShowInputErrorLabel.js";
const charset = const charset =
@ -69,6 +70,9 @@ export function AdminPage({ onLoadNotOk }: Props): VNode {
const [showCashouts, setShowCashouts] = useState<string | undefined>(); const [showCashouts, setShowCashouts] = useState<string | undefined>();
const [updatePassword, setUpdatePassword] = useState<string | undefined>(); const [updatePassword, setUpdatePassword] = useState<string | undefined>();
const [removeAccount, setRemoveAccount] = useState<string | undefined>(); const [removeAccount, setRemoveAccount] = useState<string | undefined>();
const [showCashoutDetails, setShowCashoutDetails] = useState<
string | undefined
>();
const [createAccount, setCreateAccount] = useState(false); const [createAccount, setCreateAccount] = useState(false);
const { pageStateSetter } = usePageContext(); const { pageStateSetter } = usePageContext();
@ -90,10 +94,28 @@ export function AdminPage({ onLoadNotOk }: Props): VNode {
const { customers } = result.data; const { customers } = result.data;
if (showCashoutDetails) {
return (
<ShowCashoutDetails
id={showCashoutDetails}
onLoadNotOk={onLoadNotOk}
onCancel={() => {
setShowCashoutDetails(undefined);
}}
/>
);
}
if (showCashouts) { if (showCashouts) {
return ( return (
<div> <div>
<Cashouts account={showCashouts} /> <Cashouts
account={showCashouts}
onSelected={(id) => {
setShowCashouts(id);
setShowCashouts(undefined);
}}
/>
<input <input
class="pure-button" class="pure-button"
type="submit" type="submit"

View File

@ -32,11 +32,10 @@ import { ErrorMessage, usePageContext } from "../context/pageState.js";
import { useAccountDetails } from "../hooks/access.js"; import { useAccountDetails } from "../hooks/access.js";
import { import {
useCashoutDetails, useCashoutDetails,
useCashouts,
useCircuitAccountAPI, useCircuitAccountAPI,
useRatiosAndFeeConfig, useRatiosAndFeeConfig,
} from "../hooks/circuit.js"; } from "../hooks/circuit.js";
import { CashoutStatus, TanChannel, undefinedIfEmpty } from "../utils.js"; import { TanChannel, undefinedIfEmpty } from "../utils.js";
import { ShowAccountDetails, UpdateAccountPassword } from "./AdminPage.js"; import { ShowAccountDetails, UpdateAccountPassword } from "./AdminPage.js";
import { ErrorBanner } from "./BankFrame.js"; import { ErrorBanner } from "./BankFrame.js";
import { LoginForm } from "./LoginForm.js"; import { LoginForm } from "./LoginForm.js";
@ -57,7 +56,9 @@ export function BusinessAccount({
const backend = useBackendContext(); const backend = useBackendContext();
const [updatePassword, setUpdatePassword] = useState(false); const [updatePassword, setUpdatePassword] = useState(false);
const [newCashout, setNewcashout] = useState(false); const [newCashout, setNewcashout] = useState(false);
const [showCashout, setShowCashout] = useState<string | undefined>(); const [showCashoutDetails, setShowCashoutDetails] = useState<
string | undefined
>();
function showInfoMessage(info: TranslatedString): void { function showInfoMessage(info: TranslatedString): void {
pageStateSetter((prev) => ({ pageStateSetter((prev) => ({
...prev, ...prev,
@ -79,18 +80,18 @@ export function BusinessAccount({
}} }}
onComplete={(id) => { onComplete={(id) => {
setNewcashout(false); setNewcashout(false);
setShowCashout(id); setShowCashoutDetails(id);
}} }}
/> />
); );
} }
if (showCashout) { if (showCashoutDetails) {
return ( return (
<ShowCashout <ShowCashoutDetails
id={showCashout} id={showCashoutDetails}
onLoadNotOk={onLoadNotOk} onLoadNotOk={onLoadNotOk}
onCancel={() => { onCancel={() => {
setShowCashout(undefined); setShowCashoutDetails(undefined);
}} }}
/> />
); );
@ -129,7 +130,7 @@ export function BusinessAccount({
<Cashouts <Cashouts
account={backend.state.username} account={backend.state.username}
onSelected={(id) => { onSelected={(id) => {
setShowCashout(id); setShowCashoutDetails(id);
}} }}
/> />
</div> </div>
@ -593,7 +594,11 @@ interface ShowCashoutProps {
onCancel: () => void; onCancel: () => void;
onLoadNotOk: <T, E>(error: HttpResponsePaginated<T, E>) => VNode; onLoadNotOk: <T, E>(error: HttpResponsePaginated<T, E>) => VNode;
} }
function ShowCashout({ id, onCancel, onLoadNotOk }: ShowCashoutProps): VNode { export function ShowCashoutDetails({
id,
onCancel,
onLoadNotOk,
}: ShowCashoutProps): VNode {
const { i18n } = useTranslationContext(); const { i18n } = useTranslationContext();
const result = useCashoutDetails(id); const result = useCashoutDetails(id);
const { abortCashout, confirmCashout } = useCircuitAccountAPI(); const { abortCashout, confirmCashout } = useCircuitAccountAPI();