mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-03 21:39:08 +00:00
await and display errors
This commit is contained in:
@@ -33,6 +33,7 @@ export default function GSheetSetup(props: GSheetSetupProps) {
|
|||||||
const patchStepData = useSheetStore((state) => state.patchStepData);
|
const patchStepData = useSheetStore((state) => state.patchStepData);
|
||||||
const authenticationStatus = useSheetStore((state) => state.authenticationStatus);
|
const authenticationStatus = useSheetStore((state) => state.authenticationStatus);
|
||||||
const setAuthenticationStatus = useSheetStore((state) => state.setAuthenticationStatus);
|
const setAuthenticationStatus = useSheetStore((state) => state.setAuthenticationStatus);
|
||||||
|
const authenticationError = useSheetStore((state) => state.stepData.authenticate.error);
|
||||||
|
|
||||||
/** Check if we are authenticated */
|
/** Check if we are authenticated */
|
||||||
const getAuthStatus = async () => {
|
const getAuthStatus = async () => {
|
||||||
@@ -44,6 +45,7 @@ export default function GSheetSetup(props: GSheetSetupProps) {
|
|||||||
|
|
||||||
/** check if the current session has been authenticated */
|
/** check if the current session has been authenticated */
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
patchStepData({ authenticate: { available: false, error: '' } });
|
||||||
untilAuthenticated();
|
untilAuthenticated();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -150,7 +152,7 @@ export default function GSheetSetup(props: GSheetSetupProps) {
|
|||||||
</Panel.Title>
|
</Panel.Title>
|
||||||
<Panel.ListGroup>
|
<Panel.ListGroup>
|
||||||
<Panel.Description>Upload Client Secret provided by Google</Panel.Description>
|
<Panel.Description>Upload Client Secret provided by Google</Panel.Description>
|
||||||
<Panel.Error>{undefined}</Panel.Error>
|
<Panel.Error>{authenticationError}</Panel.Error>
|
||||||
<Input
|
<Input
|
||||||
type='file'
|
type='file'
|
||||||
onChange={handleClientSecret}
|
onChange={handleClientSecret}
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ export default function useGoogleSheet() {
|
|||||||
/** whether the current session has been authenticated */
|
/** whether the current session has been authenticated */
|
||||||
const verifyAuth = async (): Promise<{ authenticated: AuthenticationStatus; sheetId: string } | void> => {
|
const verifyAuth = async (): Promise<{ authenticated: AuthenticationStatus; sheetId: string } | void> => {
|
||||||
try {
|
try {
|
||||||
return verifyAuthenticationStatus();
|
return await verifyAuthenticationStatus();
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
/** we do not handle errors here */
|
patchStepData({ authenticate: { available: false, error: maybeAxiosError(error) } });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -37,18 +37,18 @@ export default function useGoogleSheet() {
|
|||||||
sheetId: string,
|
sheetId: string,
|
||||||
): Promise<{ verification_url: string; user_code: string } | void> => {
|
): Promise<{ verification_url: string; user_code: string } | void> => {
|
||||||
try {
|
try {
|
||||||
return requestConnection(file, sheetId);
|
return await requestConnection(file, sheetId);
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
/** we do not handle errors here */
|
patchStepData({ authenticate: { available: false, error: maybeAxiosError(error) } });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** requests the revoking of an existing authenticated session */
|
/** requests the revoking of an existing authenticated session */
|
||||||
const revoke = async (): Promise<{ authenticated: AuthenticationStatus } | void> => {
|
const revoke = async (): Promise<{ authenticated: AuthenticationStatus } | void> => {
|
||||||
try {
|
try {
|
||||||
return revokeAuthentication();
|
return await revokeAuthentication();
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
/** we do not handle errors here */
|
patchStepData({ authenticate: { available: false, error: maybeAxiosError(error) } });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user