Skip to content

Commit ada271c

Browse files
committed
Pass precheck data down tree for submission
1 parent 99ecb4e commit ada271c

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/components/OAuth2Button.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import { selectable } from "../commonStyles";
1111

1212
interface OAuth2ButtonProps {
1313
scopes?: OAuthScopes[],
14-
rerender?: () => void
14+
rerender?: () => void,
15+
disabled: boolean,
1516
}
1617

1718
const iconStyles = css`
@@ -68,7 +69,7 @@ async function login(props: OAuth2ButtonProps, errorDialog: React.RefObject<HTML
6869
}
6970

7071
function OAuth2Button(props: OAuth2ButtonProps): JSX.Element {
71-
const [disabled, setDisabled] = useState<boolean>(false);
72+
const [disabled, setDisabled] = useState<boolean>(props.disabled);
7273
const errorDialog: React.RefObject<HTMLDivElement> = React.useRef(null);
7374

7475
return <span>

src/pages/FormPage/Navigation.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import OAuth2Button from "../../components/OAuth2Button";
99

1010

1111
interface NavigationProps {
12-
form_state: boolean, // Whether the form is open or not
12+
can_submit: boolean,
1313
scopes: OAuthScopes[]
1414
}
1515

@@ -18,16 +18,13 @@ export default function Navigation(props: NavigationProps): JSX.Element {
1818
props.scopes.includes(OAuthScopes.Identify) && !checkScopes(props.scopes)
1919
));
2020

21-
let submit = null;
22-
if (props.form_state) {
23-
let innerElement;
24-
if (!authorized) {
25-
innerElement = <OAuth2Button rerender={() => setAuth(true)} scopes={props.scopes}/>;
26-
} else {
27-
innerElement = <button form="form" type="submit">Submit</button>;
28-
}
29-
submit = <div css={styles.actionButtonStyles}>{innerElement}</div>;
21+
let innerElement;
22+
if (!authorized) {
23+
innerElement = <OAuth2Button disabled={!props.can_submit} rerender={() => setAuth(true)} scopes={props.scopes}/>;
24+
} else {
25+
innerElement = <button disabled={!props.can_submit} form="form" type="submit">Submit</button>;
3026
}
27+
let submit = <div css={styles.actionButtonStyles}>{innerElement}</div>;
3128

3229
return (
3330
<div css={[styles.unselectable, styles.mainTextStyles]}>

0 commit comments

Comments
 (0)