commit ca5689fd517f12e37bcd5af6a2e749be91f20cf0
parent 553063dbc81ba9b94cad194669b65662b9ddc4b1
Author: Sebastian <sebasjm@taler-systems.com>
Date: Mon, 20 Jul 2026 18:55:18 -0300
useForm was called conditionally, rules of hooks
Diffstat:
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/packages/challenger-webui/src/pages/AskChallenge.tsx b/packages/challenger-webui/src/pages/AskChallenge.tsx
@@ -37,7 +37,6 @@ import {
useTranslationContext,
} from "@gnu-taler/web-util/browser";
import { Fragment, h, VNode } from "preact";
-import { useState } from "preact/hooks";
import { useChallengeSession } from "../hooks/challenge.js";
import { SessionId, useSessionState } from "../hooks/session.js";
import { getAddressDescriptionFromAddrType } from "./AnswerChallenge.js";
@@ -49,19 +48,9 @@ type Props = {
focus?: boolean;
};
-export function AskChallenge({
- onSendSuccesful,
- routeSolveChallenge,
- session,
- focus,
-}: Props): VNode {
- const { sent, completed } = useSessionState();
- const { lib, config } = useChallengerApiContext();
-
+export function AskChallenge(props: Props): VNode {
const { i18n } = useTranslationContext();
- const { actionHandler, showError } = useNotificationContext();
-
- const result = useChallengeSession(session);
+ const result = useChallengeSession(props.session);
if (!result) {
return (
@@ -132,8 +121,21 @@ export function AskChallenge({
}
}
}
+ return <AskChallengeInternal {...props} lastStatus={result.body}/>
+}
- const lastStatus = result.body;
+function AskChallengeInternal({
+ onSendSuccesful,
+ routeSolveChallenge,
+ session,
+ focus,
+ lastStatus,
+}: Props & {lastStatus: ChallengerApi.ChallengeStatus}): VNode {
+ const { sent, completed } = useSessionState();
+ const { lib, config } = useChallengerApiContext();
+
+ const { i18n } = useTranslationContext();
+ const { actionHandler, showError } = useNotificationContext();
const initial = lastStatus.last_address ?? {};
if (config.address_type === "postal-ch") {