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

View File

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

View File

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