Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INJIVER-149] Redirect to offline page when the internet is available and user tries to verify #19

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {useActiveStepContext, useAlertMessages} from "../../../pages/Home";
import {SetScanResultFunction} from "../../../types/function-types";
import {QrScanResult, ScanStatus} from "../../../types/data-types";
import {AlertMessages, VerificationSteps} from "../../../utils/config";
import {useNavigate} from "react-router-dom";

const ScanQrCode = ({setScanResult}: {
setScanResult: SetScanResultFunction
Expand All @@ -17,6 +18,8 @@ const ScanQrCode = ({setScanResult}: {
const {setAlertInfo} = useAlertMessages();
const [scanStatus, setScanStatus] = useState("NotScanned" as ScanStatus);

const navigate = useNavigate();

function checkScanResult(scanResult: QrScanResult) {
let alertInfo = !!scanResult.data ? AlertMessages.qrUploadSuccess: AlertMessages.qrNotDetected;
setAlertInfo({
Expand Down Expand Up @@ -72,7 +75,17 @@ const ScanQrCode = ({setScanResult}: {
<Grid item xs={12} order={scanStatus === "Failed" ? 3 : 2}>
<StyledButton
icon={<TabScanIcon/>}
style={{margin: "6px 0", width: "350px", textAlign: 'center'}} fill onClick={() => setActiveStep(VerificationSteps.ActivateCamera)}>
style={{margin: "6px 0", width: "350px", textAlign: 'center'}}
fill
onClick={() => {
if (!window.navigator.onLine) {
navigate('/offline');
}
else {
setActiveStep(VerificationSteps.ActivateCamera)
}
}}
>
Scan the QR Code
</StyledButton>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import {SetScanResultFunction} from "../../../types/function-types";
import {useActiveStepContext, useAlertMessages} from "../../../pages/Home";
import {AlertMessages, UploadFileSizeLimits, VerificationSteps} from "../../../utils/config";
import {ReactComponent as UploadIcon} from "../../../assets/upload-icon.svg";
import {useNavigate} from "react-router-dom";

function UploadButton({ displayMessage }: {displayMessage: string}) {
const navigate = useNavigate();
return (
<label
style={{
Expand All @@ -20,6 +22,12 @@ function UploadButton({ displayMessage }: {displayMessage: string}) {
textAlign: 'center'
}}
htmlFor={"upload-qr"}
onClick={(event) => {
if (!window.navigator.onLine) {
event.preventDefault();
navigate('/offline');
}
}}
>
<span style={{
margin: "auto",
Expand Down
Loading