|
@ -50,64 +50,76 @@ function QRCode() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function ConfirmCOVIDPositiveAlertDialog() { |
|
|
function ConfirmCOVIDPositiveAlertDialog() { |
|
|
|
|
|
|
|
|
const [isOpen, setOpen] = useState(false); |
|
|
const [isOpen, setOpen] = useState(false); |
|
|
const toast = useToast(); |
|
|
const toast = useToast(); |
|
|
const history = useHistory(); |
|
|
const history = useHistory(); |
|
|
const dispatch = useDispatch(); |
|
|
const dispatch = useDispatch(); |
|
|
const onClose = () => { setOpen(false) } |
|
|
|
|
|
const showErrorToast = (errorMessage = "An error has occured.") => { |
|
|
|
|
|
|
|
|
const onClose = () => { |
|
|
|
|
|
setOpen(false); |
|
|
|
|
|
}; |
|
|
|
|
|
const showErrorToast = (errorMessage = 'An error has occured.') => { |
|
|
toast.closeAll(); |
|
|
toast.closeAll(); |
|
|
toast({ |
|
|
toast({ |
|
|
title: 'Error!', |
|
|
title: 'Error!', |
|
|
description: errorMessage, |
|
|
description: errorMessage, |
|
|
status: 'error', |
|
|
status: 'error', |
|
|
duration: 5000 |
|
|
|
|
|
|
|
|
duration: 5000, |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
}; |
|
|
const onConfirm = () => { |
|
|
const onConfirm = () => { |
|
|
toast({ |
|
|
toast({ |
|
|
title: 'Confirming', |
|
|
title: 'Confirming', |
|
|
description: 'Hold on while we confirm with our servers.', |
|
|
description: 'Hold on while we confirm with our servers.', |
|
|
status: 'info', |
|
|
status: 'info', |
|
|
duration: 10000 |
|
|
|
|
|
|
|
|
duration: 10000, |
|
|
}); |
|
|
}); |
|
|
axios.post(`${process.env.REACT_APP_API_URL}/covid`,{ |
|
|
|
|
|
|
|
|
axios |
|
|
|
|
|
.post( |
|
|
|
|
|
`${process.env.REACT_APP_API_URL}/covid`, |
|
|
|
|
|
{ |
|
|
setPositive: true, |
|
|
setPositive: true, |
|
|
},{withCredentials:true}) |
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
{ withCredentials: true } |
|
|
|
|
|
) |
|
|
.then(res => { |
|
|
.then(res => { |
|
|
if(res.data.covidPositive){ |
|
|
|
|
|
|
|
|
if (res.data.covidPositive) { |
|
|
dispatch(setCovidPositive()); |
|
|
dispatch(setCovidPositive()); |
|
|
toast.closeAll(); |
|
|
toast.closeAll(); |
|
|
toast({ |
|
|
toast({ |
|
|
title: "Confirmed!", |
|
|
|
|
|
|
|
|
title: 'Confirmed!', |
|
|
status: 'info', |
|
|
status: 'info', |
|
|
duration: 2000, |
|
|
duration: 2000, |
|
|
}); |
|
|
}); |
|
|
}else{ |
|
|
|
|
|
|
|
|
} else { |
|
|
showErrorToast(); |
|
|
showErrorToast(); |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
.catch(err => { |
|
|
.catch(err => { |
|
|
console.log(err); |
|
|
console.log(err); |
|
|
try{ |
|
|
|
|
|
if(err.response.status === 401){ |
|
|
|
|
|
showErrorToast("You are not logged in!"); |
|
|
|
|
|
history.push("/login"); |
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
if (err.response.status === 401) { |
|
|
|
|
|
showErrorToast('You are not logged in!'); |
|
|
|
|
|
history.push('/login'); |
|
|
|
|
|
} else { |
|
|
showErrorToast(); |
|
|
showErrorToast(); |
|
|
} |
|
|
} |
|
|
}catch(e){ |
|
|
|
|
|
|
|
|
} catch (e) { |
|
|
showErrorToast(); |
|
|
showErrorToast(); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
setOpen(false); |
|
|
setOpen(false); |
|
|
} |
|
|
|
|
|
|
|
|
}; |
|
|
const cancelRef = useRef(); |
|
|
const cancelRef = useRef(); |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<> |
|
|
<> |
|
|
<Button colorScheme="red" mb={6} onClick={() => { setOpen(true); }}> |
|
|
|
|
|
|
|
|
<Button |
|
|
|
|
|
colorScheme="red" |
|
|
|
|
|
mb={6} |
|
|
|
|
|
onClick={() => { |
|
|
|
|
|
setOpen(true); |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
Report Positive COVID19 |
|
|
Report Positive COVID19 |
|
|
</Button> |
|
|
</Button> |
|
|
<AlertDialog |
|
|
<AlertDialog |
|
@ -121,13 +133,17 @@ function ConfirmCOVIDPositiveAlertDialog() { |
|
|
Confirm Tested COVID19 Positive |
|
|
Confirm Tested COVID19 Positive |
|
|
</AlertDialogHeader> |
|
|
</AlertDialogHeader> |
|
|
<AlertDialogBody> |
|
|
<AlertDialogBody> |
|
|
Please confirm that you have been tested POSITIVE with |
|
|
|
|
|
COVID19. Upon confirmation, this app will inform the people |
|
|
|
|
|
you have come in contact with in the last 7 days. |
|
|
|
|
|
|
|
|
Please confirm that you have been tested POSITIVE with COVID19. |
|
|
|
|
|
Upon confirmation, this app will inform the people you have come |
|
|
|
|
|
in contact with in the last 7 days. |
|
|
</AlertDialogBody> |
|
|
</AlertDialogBody> |
|
|
<AlertDialogFooter> |
|
|
<AlertDialogFooter> |
|
|
<Button ref={cancelRef} onClick={onClose}>Cancel</Button> |
|
|
|
|
|
<Button colorScheme="red" onClick={onConfirm} ml={3}>Confirm</Button> |
|
|
|
|
|
|
|
|
<Button ref={cancelRef} onClick={onClose}> |
|
|
|
|
|
Cancel |
|
|
|
|
|
</Button> |
|
|
|
|
|
<Button colorScheme="red" onClick={onConfirm} ml={3}> |
|
|
|
|
|
Confirm |
|
|
|
|
|
</Button> |
|
|
</AlertDialogFooter> |
|
|
</AlertDialogFooter> |
|
|
</AlertDialogContent> |
|
|
</AlertDialogContent> |
|
|
</AlertDialogOverlay> |
|
|
</AlertDialogOverlay> |
|
@ -147,21 +163,26 @@ function Home() { |
|
|
|
|
|
|
|
|
const isAuthenticated = useSelector(state => state.auth.isAuthenticated); |
|
|
const isAuthenticated = useSelector(state => state.auth.isAuthenticated); |
|
|
const isCovidPositive = useSelector(state => state.covid.isCovidPositive); |
|
|
const isCovidPositive = useSelector(state => state.covid.isCovidPositive); |
|
|
useEffect( ()=>{ |
|
|
|
|
|
axios.post(`${process.env.REACT_APP_API_URL}/covid`,{},{withCredentials:true}) |
|
|
|
|
|
.then(res=>{ |
|
|
|
|
|
if(res.data.covidPositive){ |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
axios |
|
|
|
|
|
.post( |
|
|
|
|
|
`${process.env.REACT_APP_API_URL}/covid`, |
|
|
|
|
|
{}, |
|
|
|
|
|
{ withCredentials: true } |
|
|
|
|
|
) |
|
|
|
|
|
.then(res => { |
|
|
|
|
|
if (res.data.covidPositive) { |
|
|
dispatch(setCovidPositive()); |
|
|
dispatch(setCovidPositive()); |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
.catch(err=>{}); |
|
|
|
|
|
}, [dispatch]); |
|
|
|
|
|
|
|
|
.catch(err => {}); |
|
|
|
|
|
}, [dispatch]); |
|
|
if (!isAuthenticated) return <Redirect to="/login" />; |
|
|
if (!isAuthenticated) return <Redirect to="/login" />; |
|
|
if (isCovidPositive) return <Redirect to="/lockout" />; |
|
|
if (isCovidPositive) return <Redirect to="/lockout" />; |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<Flex |
|
|
<Flex |
|
|
height="100vh" |
|
|
|
|
|
|
|
|
minHeight="100vh" |
|
|
background="teal.100" |
|
|
background="teal.100" |
|
|
alignItems="center" |
|
|
alignItems="center" |
|
|
justifyContent="center" |
|
|
justifyContent="center" |
|
@ -170,6 +191,8 @@ function Home() { |
|
|
direction="column" |
|
|
direction="column" |
|
|
background="white" |
|
|
background="white" |
|
|
p={12} |
|
|
p={12} |
|
|
|
|
|
mt={5} |
|
|
|
|
|
mb={5} |
|
|
rounded={6} |
|
|
rounded={6} |
|
|
id="QRFlex" |
|
|
id="QRFlex" |
|
|
> |
|
|
> |
|
|