diff options
author | 2025-08-08 23:26:59 +0100 | |
---|---|---|
committer | 2025-08-08 23:26:59 +0100 | |
commit | ada271cfc6b569d115322536555e936f5aa98aee (patch) | |
tree | 0dc1d4448c961143e92104c67a9f7ed33fed70fe | |
parent | Update FormPage to show PrecheckData (diff) |
Pass precheck data down tree for submission
-rw-r--r-- | src/components/OAuth2Button.tsx | 5 | ||||
-rw-r--r-- | src/pages/FormPage/Navigation.tsx | 17 |
2 files changed, 10 insertions, 12 deletions
diff --git a/src/components/OAuth2Button.tsx b/src/components/OAuth2Button.tsx index 5e980b7..1658d42 100644 --- a/src/components/OAuth2Button.tsx +++ b/src/components/OAuth2Button.tsx @@ -11,7 +11,8 @@ import { selectable } from "../commonStyles"; interface OAuth2ButtonProps { scopes?: OAuthScopes[], - rerender?: () => void + rerender?: () => void, + disabled: boolean, } const iconStyles = css` @@ -68,7 +69,7 @@ async function login(props: OAuth2ButtonProps, errorDialog: React.RefObject<HTML } function OAuth2Button(props: OAuth2ButtonProps): JSX.Element { - const [disabled, setDisabled] = useState<boolean>(false); + const [disabled, setDisabled] = useState<boolean>(props.disabled); const errorDialog: React.RefObject<HTMLDivElement> = React.useRef(null); return <span> diff --git a/src/pages/FormPage/Navigation.tsx b/src/pages/FormPage/Navigation.tsx index 20c7dce..c5dfa4a 100644 --- a/src/pages/FormPage/Navigation.tsx +++ b/src/pages/FormPage/Navigation.tsx @@ -9,7 +9,7 @@ import OAuth2Button from "../../components/OAuth2Button"; interface NavigationProps { - form_state: boolean, // Whether the form is open or not + can_submit: boolean, scopes: OAuthScopes[] } @@ -18,16 +18,13 @@ export default function Navigation(props: NavigationProps): JSX.Element { props.scopes.includes(OAuthScopes.Identify) && !checkScopes(props.scopes) )); - let submit = null; - if (props.form_state) { - let innerElement; - if (!authorized) { - innerElement = <OAuth2Button rerender={() => setAuth(true)} scopes={props.scopes}/>; - } else { - innerElement = <button form="form" type="submit">Submit</button>; - } - submit = <div css={styles.actionButtonStyles}>{innerElement}</div>; + let innerElement; + if (!authorized) { + innerElement = <OAuth2Button disabled={!props.can_submit} rerender={() => setAuth(true)} scopes={props.scopes}/>; + } else { + innerElement = <button disabled={!props.can_submit} form="form" type="submit">Submit</button>; } + let submit = <div css={styles.actionButtonStyles}>{innerElement}</div>; return ( <div css={[styles.unselectable, styles.mainTextStyles]}> |