Browse Source

ran linter

pull/9/head
Nareshkumar Rao 3 years ago
parent
commit
16bdd75903
  1. 32
      src/i18n.js
  2. 2
      src/index.js
  3. 96
      src/locales/en/common.json
  4. 96
      src/locales/ms/common.json
  5. 36
      src/screens/HomeScreen.js
  6. 30
      src/screens/LockoutScreen.js
  7. 58
      src/screens/LoginScreen.js
  8. 12
      src/screens/ScannerScreen.js
  9. 6
      src/screens/SuccessScreen.js
  10. 8
      src/screens/VerifyScreen.js

32
src/i18n.js

@ -1,8 +1,8 @@
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import enTranslation from "./locales/en/common.json";
import msTranslation from "./locales/ms/common.json";
import enTranslation from './locales/en/common.json';
import msTranslation from './locales/ms/common.json';
const resources = {
en: {
@ -10,19 +10,17 @@ const resources = {
},
ms: {
common: msTranslation,
}
},
};
i18n
.use(initReactI18next)
.init({
resources,
lng: "ms",
defaultNS: 'common',
interpolation: {
escapeValue: false
},
debug:true
});
i18n.use(initReactI18next).init({
resources,
lng: 'ms',
defaultNS: 'common',
interpolation: {
escapeValue: false,
},
debug: true,
});
export default i18n;
export default i18n;

2
src/index.js

@ -6,7 +6,7 @@ import App from './App';
import { store } from './app/store';
import reportWebVitals from './reportWebVitals';
import * as serviceWorker from './serviceWorker';
import "./i18n"
import './i18n';
import { Provider } from 'react-redux';
require('dotenv').config();

96
src/locales/en/common.json

@ -1,49 +1,49 @@
{
"appTitle": "OurSejahtera Contact Tracing",
"homeExplanation": "This is your QR code. Show this to others to allow them to confirm a contact, or allow them to create an account!",
"scanButtonLabel": "Scan a QR Code",
"donateButtonLabel": "Donate!",
"donateButtonParagraph": "Servers require money to run, and apps require labor to develop and maintain. You can show your support by donating what you can. Every cent counts, buy me my next coffee, or help pay for a month of server usage!",
"logOutButtonLabel": "Log Out!",
"covidPositiveReportButton": "Report Positive COVID19",
"covidPositiveAlertHeader": "Confirm Tested COVID19 Positive",
"covidPositiveAlertBody": "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.",
"confirm": "Confirm",
"cancel": "Cancel",
"errorToastTitle": "Error!",
"defaultErrorToastDescription": "An error has occured.",
"confirmedToastTitle": "Confirmed!",
"confirmingToastTitle": "Confirming",
"confirmingToastDescription": "Hold on while we confirm with our servers.",
"notLoggedInToastDescription": "You are not logged in!",
"failedLoginToastTitle": "Login Failed",
"failedLoginToastDescription": "The wrong credentials were used",
"loggingInToastTitle": "Logging you in",
"loggingInToastDescription": "Hold on, we're logging you in.",
"checkingLockoutToastTitle": "Checking your lockout status...",
"badVerificationToastTitle": "Bad Verification",
"badQRCodeToastTitle": "Bad QR Code",
"contactLoggedToastTitle": "Contact Successfully Logged",
"checkingQRToastTitle": "Hold on, we're checking this QR code.",
"login": "Login",
"loginPrivacyNotice": "<0><0>Privacy notes:</0> <br/>Telegram Login allows us to verify your identity, without collecting any of your data. Telegram does NOT give us your phone number. The only piece of information stored on our server is your Telegram ID, this is an internal ID Number Telegram uses that is SEPARATE from your Telegram Username.<br/><br/>All the code for this project is <8>Open Source</8>, that means anyone, including you can audit and verify that your information is being handled securely.</0>",
"lockout": "Lockout",
"lockoutExplanation": "<0>You have reported that you have been tested <1>POSITIVE</1> with COVID19. This lockout is to remind you to quarantine yourself according to local COVID19 health policies. This lockout will automatically be lifted after 14 days.<br/><br/><5>Please avoid contact with other people for the duration of this lockout!</5></0>",
"showQRCode": "Show my QR Code",
"contactSavedParagraph": "We have succesfully saved your contact! Stay safe out there, and let others scan your QR code too!",
"returnHomeButtonLabel": "Return home",
"verifyingParagraph": "We are currently verifying you. Please wait.",
"verifyingErrorParagraph": "An error has occured verifying you. Please try scanning the QR code again?"
}
"appTitle": "OurSejahtera Contact Tracing",
"homeExplanation": "This is your QR code. Show this to others to allow them to confirm a contact, or allow them to create an account!",
"scanButtonLabel": "Scan a QR Code",
"donateButtonLabel": "Donate!",
"donateButtonParagraph": "Servers require money to run, and apps require labor to develop and maintain. You can show your support by donating what you can. Every cent counts, buy me my next coffee, or help pay for a month of server usage!",
"logOutButtonLabel": "Log Out!",
"covidPositiveReportButton": "Report Positive COVID19",
"covidPositiveAlertHeader": "Confirm Tested COVID19 Positive",
"covidPositiveAlertBody": "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.",
"confirm": "Confirm",
"cancel": "Cancel",
"errorToastTitle": "Error!",
"defaultErrorToastDescription": "An error has occured.",
"confirmedToastTitle": "Confirmed!",
"confirmingToastTitle": "Confirming",
"confirmingToastDescription": "Hold on while we confirm with our servers.",
"notLoggedInToastDescription": "You are not logged in!",
"failedLoginToastTitle": "Login Failed",
"failedLoginToastDescription": "The wrong credentials were used",
"loggingInToastTitle": "Logging you in",
"loggingInToastDescription": "Hold on, we're logging you in.",
"checkingLockoutToastTitle": "Checking your lockout status...",
"badVerificationToastTitle": "Bad Verification",
"badQRCodeToastTitle": "Bad QR Code",
"contactLoggedToastTitle": "Contact Successfully Logged",
"checkingQRToastTitle": "Hold on, we're checking this QR code.",
"login": "Login",
"loginPrivacyNotice": "<0><0>Privacy notes:</0> <br/>Telegram Login allows us to verify your identity, without collecting any of your data. Telegram does NOT give us your phone number. The only piece of information stored on our server is your Telegram ID, this is an internal ID Number Telegram uses that is SEPARATE from your Telegram Username.<br/><br/>All the code for this project is <8>Open Source</8>, that means anyone, including you can audit and verify that your information is being handled securely.</0>",
"lockout": "Lockout",
"lockoutExplanation": "<0>You have reported that you have been tested <1>POSITIVE</1> with COVID19. This lockout is to remind you to quarantine yourself according to local COVID19 health policies. This lockout will automatically be lifted after 14 days.<br/><br/><5>Please avoid contact with other people for the duration of this lockout!</5></0>",
"showQRCode": "Show my QR Code",
"contactSavedParagraph": "We have succesfully saved your contact! Stay safe out there, and let others scan your QR code too!",
"returnHomeButtonLabel": "Return home",
"verifyingParagraph": "We are currently verifying you. Please wait.",
"verifyingErrorParagraph": "An error has occured verifying you. Please try scanning the QR code again?"
}

96
src/locales/ms/common.json

@ -1,49 +1,49 @@
{
"appTitle": "OurSejahtera Contact Tracing",
"homeExplanation": "Inilah kod QR anda. Show this to others to allow them to confirm a contact!",
"scanButtonLabel": "Mengimbas kod QR",
"donateButtonLabel": "Menderma!",
"donateButtonParagraph": "Servers require money to run, and apps require labor to develop and maintain. You can show your support by donating what you can. Every cent counts, buy me my next coffee, or help pay for a month of server usage!",
"logOutButtonLabel": "Daftar keluar!",
"covidPositiveReportButton": "Lapor kes COVID19",
"covidPositiveAlertHeader": "Confirm Tested COVID19 Positive",
"covidPositiveAlertBody": "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.",
"confirm": "Confirm",
"cancel": "Cancel",
"errorToastTitle": "Error!",
"defaultErrorToastDescription": "An error has occured.",
"confirmedToastTitle": "Confirmed!",
"confirmingToastTitle": "Confirming",
"confirmingToastDescription": "Hold on while we confirm with our servers.",
"notLoggedInToastDescription": "You are not logged in!",
"failedLoginToastTitle": "Login Failed",
"failedLoginToastDescription": "The wrong credentials were used",
"loggingInToastTitle": "Logging you in",
"loggingInToastDescription": "Hold on, we're logging you in.",
"checkingLockoutToastTitle": "Checking your lockout status...",
"badVerificationToastTitle": "Bad Verification",
"badQRCodeToastTitle": "Bad QR Code",
"contactLoggedToastTitle": "Contact Successfully Logged",
"checkingQRToastTitle": "Hold on, we're checking this QR code.",
"login": "Login",
"loginPrivacyNotice": "<0><0>Privacy notes:</0> <br/>Telegram Login allows us to verify your identity, without collecting any of your data. Telegram does NOT give us your phone number. The only piece of information stored on our server is your Telegram ID, this is an internal ID Number Telegram uses that is SEPARATE from your Telegram Username.<br/><br/>All the code for this project is <8>Open Source</8>, that means anyone, including you can audit and verify that your information is being handled securely.</0>",
"lockout": "Lockout",
"lockoutExplanation": "<0>You have reported that you have been tested <1>POSITIVE</1> with COVID19. This lockout is to remind you to quarantine yourself according to local COVID19 health policies. This lockout will automatically be lifted after 14 days.<br/><br/><5>Please avoid contact with other people for the duration of this lockout!</5></0>",
"showQRCode": "Show my QR Code",
"contactSavedParagraph": "We have succesfully saved your contact! Stay safe out there, and let others scan your QR code too!",
"returnHomeButtonLabel": "Return home",
"verifyingParagraph": "We are currently verifying you. Please wait.",
"verifyingErrorParagraph": "An error has occured verifying you. Please try scanning the QR code again?"
}
"appTitle": "OurSejahtera Contact Tracing",
"homeExplanation": "Inilah kod QR anda. Show this to others to allow them to confirm a contact!",
"scanButtonLabel": "Mengimbas kod QR",
"donateButtonLabel": "Menderma!",
"donateButtonParagraph": "Servers require money to run, and apps require labor to develop and maintain. You can show your support by donating what you can. Every cent counts, buy me my next coffee, or help pay for a month of server usage!",
"logOutButtonLabel": "Daftar keluar!",
"covidPositiveReportButton": "Lapor kes COVID19",
"covidPositiveAlertHeader": "Confirm Tested COVID19 Positive",
"covidPositiveAlertBody": "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.",
"confirm": "Confirm",
"cancel": "Cancel",
"errorToastTitle": "Error!",
"defaultErrorToastDescription": "An error has occured.",
"confirmedToastTitle": "Confirmed!",
"confirmingToastTitle": "Confirming",
"confirmingToastDescription": "Hold on while we confirm with our servers.",
"notLoggedInToastDescription": "You are not logged in!",
"failedLoginToastTitle": "Login Failed",
"failedLoginToastDescription": "The wrong credentials were used",
"loggingInToastTitle": "Logging you in",
"loggingInToastDescription": "Hold on, we're logging you in.",
"checkingLockoutToastTitle": "Checking your lockout status...",
"badVerificationToastTitle": "Bad Verification",
"badQRCodeToastTitle": "Bad QR Code",
"contactLoggedToastTitle": "Contact Successfully Logged",
"checkingQRToastTitle": "Hold on, we're checking this QR code.",
"login": "Login",
"loginPrivacyNotice": "<0><0>Privacy notes:</0> <br/>Telegram Login allows us to verify your identity, without collecting any of your data. Telegram does NOT give us your phone number. The only piece of information stored on our server is your Telegram ID, this is an internal ID Number Telegram uses that is SEPARATE from your Telegram Username.<br/><br/>All the code for this project is <8>Open Source</8>, that means anyone, including you can audit and verify that your information is being handled securely.</0>",
"lockout": "Lockout",
"lockoutExplanation": "<0>You have reported that you have been tested <1>POSITIVE</1> with COVID19. This lockout is to remind you to quarantine yourself according to local COVID19 health policies. This lockout will automatically be lifted after 14 days.<br/><br/><5>Please avoid contact with other people for the duration of this lockout!</5></0>",
"showQRCode": "Show my QR Code",
"contactSavedParagraph": "We have succesfully saved your contact! Stay safe out there, and let others scan your QR code too!",
"returnHomeButtonLabel": "Return home",
"verifyingParagraph": "We are currently verifying you. Please wait.",
"verifyingErrorParagraph": "An error has occured verifying you. Please try scanning the QR code again?"
}

36
src/screens/HomeScreen.js

@ -59,10 +59,10 @@ function ConfirmCOVIDPositiveAlertDialog() {
const onClose = () => {
setOpen(false);
};
const showErrorToast = (errorMessage = t("defaultErrorToastDescription")) => {
const showErrorToast = (errorMessage = t('defaultErrorToastDescription')) => {
toast.closeAll();
toast({
title: t("errorToastTitle"),
title: t('errorToastTitle'),
description: errorMessage,
status: 'error',
duration: 5000,
@ -70,8 +70,8 @@ function ConfirmCOVIDPositiveAlertDialog() {
};
const onConfirm = () => {
toast({
title: t("confirmingToastTitle"),
description: t("confirmingToastDescription"),
title: t('confirmingToastTitle'),
description: t('confirmingToastDescription'),
status: 'info',
duration: 10000,
});
@ -88,7 +88,7 @@ function ConfirmCOVIDPositiveAlertDialog() {
dispatch(setCovidPositive());
toast.closeAll();
toast({
title: t("confirmedToastTitle"),
title: t('confirmedToastTitle'),
status: 'info',
duration: 2000,
});
@ -100,7 +100,7 @@ function ConfirmCOVIDPositiveAlertDialog() {
console.log(err);
try {
if (err.response.status === 401) {
showErrorToast(t("notLoggedInToastDescription"));
showErrorToast(t('notLoggedInToastDescription'));
history.push('/login');
} else {
showErrorToast();
@ -122,7 +122,7 @@ function ConfirmCOVIDPositiveAlertDialog() {
setOpen(true);
}}
>
{t("covidPositiveReportButton")}
{t('covidPositiveReportButton')}
</Button>
<AlertDialog
isOpen={isOpen}
@ -132,17 +132,15 @@ function ConfirmCOVIDPositiveAlertDialog() {
<AlertDialogOverlay>
<AlertDialogContent>
<AlertDialogHeader>
{t("covidPositiveAlertHeader")}
{t('covidPositiveAlertHeader')}
</AlertDialogHeader>
<AlertDialogBody>
{t("covidPositiveAlertBody")}
</AlertDialogBody>
<AlertDialogBody>{t('covidPositiveAlertBody')}</AlertDialogBody>
<AlertDialogFooter>
<Button ref={cancelRef} onClick={onClose}>
{t("cancel")}
{t('cancel')}
</Button>
<Button colorScheme="red" onClick={onConfirm} ml={3}>
{t("confirm")}
{t('confirm')}
</Button>
</AlertDialogFooter>
</AlertDialogContent>
@ -199,7 +197,7 @@ function Home() {
>
<QRCode />
<Text mb={6} align="center" fontSize="lg">
{t("homeExplanation")}
{t('homeExplanation')}
</Text>
<Divider mb={6} />
<Button
@ -208,26 +206,24 @@ function Home() {
history.push('/scanner');
}}
>
{t("scanButtonLabel")}
{t('scanButtonLabel')}
</Button>
{process.env.REACT_APP_DONATE_LINK && (
<Fragment>
<Divider mb={6} />
<Link href={process.env.REACT_APP_DONATE_LINK}>
<Button style={{ width: '100% ' }} mb={6} colorScheme="blue">
{t("donateButtonlabel")}
{t('donateButtonlabel')}
</Button>
</Link>
<Text mb={6}>
{t("donateButtonParagraph")}
</Text>
<Text mb={6}>{t('donateButtonParagraph')}</Text>
</Fragment>
)}
<Divider mb={6} />
<ConfirmCOVIDPositiveAlertDialog />
<Divider mb={6} />
<Button colorScheme="blackAlpha" mb={6} onClick={handleLogout}>
{t("logOutButtonLabel")}
{t('logOutButtonLabel')}
</Button>
</Flex>
</Flex>

30
src/screens/LockoutScreen.js

@ -20,7 +20,7 @@ function Lockout() {
useEffect(() => {
toast({
title: t("checkingLockoutToastTitle"),
title: t('checkingLockoutToastTitle'),
status: 'info',
duration: 10000,
});
@ -46,7 +46,7 @@ function Lockout() {
history.push('/login');
} else {
toast({
title: t("defaultErrorToastDescription"),
title: t('defaultErrorToastDescription'),
status: 'error',
duration: 10000,
});
@ -74,20 +74,20 @@ function Lockout() {
rounded={6}
id="contentFlex"
>
<Heading>{t("Lockout")}</Heading>
<Heading>{t('Lockout')}</Heading>
<Trans i18nKey="lockoutExplanation">
<Text>
You have reported that you have been tested <b>POSITIVE</b> with
COVID19. This lockout is to remind you to quarantine yourself
according to local COVID19 health policies. This lockout will
automatically be lifted after 14 days.
<br />
<br />
<b>
Please avoid contact with other people for the duration of this
lockout!
</b>
</Text>
<Text>
You have reported that you have been tested <b>POSITIVE</b> with
COVID19. This lockout is to remind you to quarantine yourself
according to local COVID19 health policies. This lockout will
automatically be lifted after 14 days.
<br />
<br />
<b>
Please avoid contact with other people for the duration of this
lockout!
</b>
</Text>
</Trans>
</Flex>
</Flex>

58
src/screens/LoginScreen.js

@ -19,8 +19,8 @@ function Login() {
const handleTelegramResponse = response => {
toast({
title: t("loggingInToastTitle"),
description: t("loggingInToastDescription"),
title: t('loggingInToastTitle'),
description: t('loggingInToastDescription'),
status: 'info',
duration: 10000,
isClosable: false,
@ -48,7 +48,7 @@ function Login() {
toast.closeAll();
dispatch(authLogout());
toast({
title: t("defaultErrorToastDescription"),
title: t('defaultErrorToastDescription'),
description: response.data.message,
status: 'error',
duration: 9000,
@ -62,8 +62,8 @@ function Login() {
if (err.response.status === 401) {
dispatch(authLogout());
toast({
title: t("failedLoginToastTitle"),
description: t("failedLoginToastDescription"),
title: t('failedLoginToastTitle'),
description: t('failedLoginToastDescription'),
status: 'error',
duration: 9000,
isClosable: true,
@ -71,8 +71,8 @@ function Login() {
}
} else {
toast({
title: t("errorToastTitle"),
description: t("defaultErrorToastDescription"),
title: t('errorToastTitle'),
description: t('defaultErrorToastDescription'),
status: 'error',
duration: 9000,
isClosable: true,
@ -98,10 +98,10 @@ function Login() {
id="contentFlex"
>
<Heading size="xl" mb={6}>
{t("appTitle")}
{t('appTitle')}
</Heading>
<Heading size="lg" mb={4}>
{t("login")}
{t('login')}
</Heading>
<TelegramLoginButton
dataOnauth={handleTelegramResponse}
@ -109,26 +109,26 @@ function Login() {
/>
<Divider mb={6} mt={6} />
<Trans i18nKey="loginPrivacyNotice">
<Text fontSize="sm">
<b>Privacy notes:</b> <br />
Telegram Login allows us to verify your identity, without collecting
any of your data. Telegram does NOT give us your phone number. The
only piece of information stored on our server is your Telegram ID,
this is an internal ID Number Telegram uses that is SEPARATE from your
Telegram Username.
<br />
<br />
All the code for this project is{' '}
<Link
color="teal.500"
href="https://github.com/naresh97/our-sejahtera"
isExternal
>
Open Source
</Link>
, that means anyone, including you can audit and verify that your
information is being handled securely.
</Text>
<Text fontSize="sm">
<b>Privacy notes:</b> <br />
Telegram Login allows us to verify your identity, without collecting
any of your data. Telegram does NOT give us your phone number. The
only piece of information stored on our server is your Telegram ID,
this is an internal ID Number Telegram uses that is SEPARATE from
your Telegram Username.
<br />
<br />
All the code for this project is{' '}
<Link
color="teal.500"
href="https://github.com/naresh97/our-sejahtera"
isExternal
>
Open Source
</Link>
, that means anyone, including you can audit and verify that your
information is being handled securely.
</Text>
</Trans>
</Flex>
</Flex>

12
src/screens/ScannerScreen.js

@ -34,7 +34,7 @@ function Scanner() {
const hash = re.exec(scanData);
if (hash) {
toast({
title: t("checkingQRToastTitle"),
title: t('checkingQRToastTitle'),
status: 'info',
duration: 10000,
isClosable: false,
@ -52,13 +52,13 @@ function Scanner() {
if (res.data.loggedIn) {
toast.closeAll();
toast({
title: t("contactLoggedToastTitle"),
title: t('contactLoggedToastTitle'),
status: 'info',
duration: 2000,
});
} else {
toast({
title: t("notLoggedInToastDescription"),
title: t('notLoggedInToastDescription'),
status: 'error',
duration: 2000,
});
@ -70,7 +70,7 @@ function Scanner() {
.catch(e => {
toast.closeAll();
toast({
title: t("badVerificationToastTitle"),
title: t('badVerificationToastTitle'),
status: 'error',
duration: 2000,
});
@ -78,7 +78,7 @@ function Scanner() {
} else {
toast.closeAll();
toast({
title: t("badQRCodeToastTitle"),
title: t('badQRCodeToastTitle'),
status: 'error',
duration: 3000,
isClosable: true,
@ -135,7 +135,7 @@ function Scanner() {
history.push('/home');
}}
>
{t("showQRCode")}
{t('showQRCode')}
</Button>
</Flex>
</Flex>

6
src/screens/SuccessScreen.js

@ -22,15 +22,13 @@ function Success() {
rounded={6}
>
<Heading>Success!</Heading>
<Text fontSize="lg">
{t("contactSavedParagraph")}
</Text>
<Text fontSize="lg">{t('contactSavedParagraph')}</Text>
<Button
onClick={() => {
history.push('/home');
}}
>
{t("returnHomeButtonLabel")}
{t('returnHomeButtonLabel')}
</Button>
</Flex>
</Flex>

8
src/screens/VerifyScreen.js

@ -34,12 +34,8 @@ function Verify(props) {
});
}, [verifyError, history, verifyID]);
const errorMessage = (
<Text>{t("verifyingErrorParagraph")}</Text>
);
const loadingMessage = (
<Text>{t("verifyingParagraph")}</Text>
);
const errorMessage = <Text>{t('verifyingErrorParagraph')}</Text>;
const loadingMessage = <Text>{t('verifyingParagraph')}</Text>;
return (
<Flex

Loading…
Cancel
Save