Apply strictNullChecks
to src/components/views/auth/*
(#10299
* Apply `strictNullChecks` to src/components/views/auth/* * Iterate PR
This commit is contained in:
parent
c79eff2292
commit
32aa18ff2e
16 changed files with 127 additions and 122 deletions
|
@ -44,15 +44,15 @@ interface IProps {
|
|||
|
||||
interface IState {
|
||||
shouldErase: boolean;
|
||||
errStr: string;
|
||||
errStr: string | null;
|
||||
authData: any; // for UIA
|
||||
authEnabled: boolean; // see usages for information
|
||||
|
||||
// A few strings that are passed to InteractiveAuth for design or are displayed
|
||||
// next to the InteractiveAuth component.
|
||||
bodyText: string;
|
||||
continueText: string;
|
||||
continueKind: string;
|
||||
bodyText?: string;
|
||||
continueText?: string;
|
||||
continueKind?: string;
|
||||
}
|
||||
|
||||
export default class DeactivateAccountDialog extends React.Component<IProps, IState> {
|
||||
|
@ -64,12 +64,6 @@ export default class DeactivateAccountDialog extends React.Component<IProps, ISt
|
|||
errStr: null,
|
||||
authData: null, // for UIA
|
||||
authEnabled: true, // see usages for information
|
||||
|
||||
// A few strings that are passed to InteractiveAuth for design or are displayed
|
||||
// next to the InteractiveAuth component.
|
||||
bodyText: null,
|
||||
continueText: null,
|
||||
continueKind: null,
|
||||
};
|
||||
|
||||
this.initAuth(/* shouldErase= */ false);
|
||||
|
@ -101,14 +95,16 @@ export default class DeactivateAccountDialog extends React.Component<IProps, ISt
|
|||
};
|
||||
|
||||
const aesthetics = DEACTIVATE_AESTHETICS[stage];
|
||||
let bodyText = null;
|
||||
let continueText = null;
|
||||
let continueKind = null;
|
||||
let bodyText: string | undefined;
|
||||
let continueText: string | undefined;
|
||||
let continueKind: string | undefined;
|
||||
if (aesthetics) {
|
||||
const phaseAesthetics = aesthetics[phase];
|
||||
if (phaseAesthetics?.body) bodyText = phaseAesthetics.body;
|
||||
if (phaseAesthetics?.continueText) continueText = phaseAesthetics.continueText;
|
||||
if (phaseAesthetics?.continueKind) continueKind = phaseAesthetics.continueKind;
|
||||
if (phaseAesthetics) {
|
||||
if (phaseAesthetics.body) bodyText = phaseAesthetics.body;
|
||||
if (phaseAesthetics.continueText) continueText = phaseAesthetics.continueText;
|
||||
if (phaseAesthetics.continueKind) continueKind = phaseAesthetics.continueKind;
|
||||
}
|
||||
}
|
||||
this.setState({ bodyText, continueText, continueKind });
|
||||
};
|
||||
|
@ -183,7 +179,7 @@ export default class DeactivateAccountDialog extends React.Component<IProps, ISt
|
|||
}
|
||||
|
||||
public render(): React.ReactNode {
|
||||
let error = null;
|
||||
let error: JSX.Element | undefined;
|
||||
if (this.state.errStr) {
|
||||
error = <div className="error">{this.state.errStr}</div>;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ export interface InteractiveAuthDialogProps {
|
|||
}
|
||||
|
||||
interface IState {
|
||||
authError: Error;
|
||||
authError: Error | null;
|
||||
|
||||
// See _onUpdateStagePhase()
|
||||
uiaStage: AuthType | null;
|
||||
|
@ -147,16 +147,22 @@ export default class InteractiveAuthDialog extends React.Component<InteractiveAu
|
|||
|
||||
let title = this.state.authError ? "Error" : this.props.title || _t("Authentication");
|
||||
let body = this.state.authError ? null : this.props.body;
|
||||
let continueText = null;
|
||||
let continueKind = null;
|
||||
let continueText: string | undefined;
|
||||
let continueKind: string | undefined;
|
||||
const dialogAesthetics = this.props.aestheticsForStagePhases || this.getDefaultDialogAesthetics();
|
||||
if (!this.state.authError && dialogAesthetics) {
|
||||
if (dialogAesthetics[this.state.uiaStage]) {
|
||||
const aesthetics = dialogAesthetics[this.state.uiaStage][this.state.uiaStagePhase];
|
||||
if (aesthetics?.title) title = aesthetics.title;
|
||||
if (aesthetics?.body) body = aesthetics.body;
|
||||
if (aesthetics?.continueText) continueText = aesthetics.continueText;
|
||||
if (aesthetics?.continueKind) continueKind = aesthetics.continueKind;
|
||||
if (
|
||||
this.state.uiaStage !== null &&
|
||||
this.state.uiaStagePhase !== null &&
|
||||
dialogAesthetics[this.state.uiaStage]
|
||||
) {
|
||||
const aesthetics = dialogAesthetics[this.state.uiaStage]![this.state.uiaStagePhase];
|
||||
if (aesthetics) {
|
||||
if (aesthetics.title) title = aesthetics.title;
|
||||
if (aesthetics.body) body = aesthetics.body;
|
||||
if (aesthetics.continueText) continueText = aesthetics.continueText;
|
||||
if (aesthetics.continueKind) continueKind = aesthetics.continueKind;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,8 @@ import DialogButtons from "../elements/DialogButtons";
|
|||
import EmailField from "../auth/EmailField";
|
||||
|
||||
interface IProps {
|
||||
onFinished(continued: boolean, email?: string): void;
|
||||
onFinished(continued: false, email?: undefined): void;
|
||||
onFinished(continued: true, email: string): void;
|
||||
}
|
||||
|
||||
const RegistrationEmailPromptDialog: React.FC<IProps> = ({ onFinished }) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue