Browse Source

ran linter

pull/9/head
Nareshkumar Rao 3 years ago
parent
commit
16bdd75903
  1. 24
      src/i18n.js
  2. 2
      src/index.js
  3. 36
      src/screens/HomeScreen.js
  4. 6
      src/screens/LockoutScreen.js
  5. 22
      src/screens/LoginScreen.js
  6. 12
      src/screens/ScannerScreen.js
  7. 6
      src/screens/SuccessScreen.js
  8. 8
      src/screens/VerifyScreen.js

24
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 = { const resources = {
en: { en: {
@ -10,19 +10,17 @@ const resources = {
}, },
ms: { ms: {
common: msTranslation, common: msTranslation,
}
},
}; };
i18n
.use(initReactI18next)
.init({
i18n.use(initReactI18next).init({
resources, resources,
lng: "ms",
lng: 'ms',
defaultNS: 'common', defaultNS: 'common',
interpolation: { interpolation: {
escapeValue: false
escapeValue: false,
}, },
debug:true
});
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 { store } from './app/store';
import reportWebVitals from './reportWebVitals'; import reportWebVitals from './reportWebVitals';
import * as serviceWorker from './serviceWorker'; import * as serviceWorker from './serviceWorker';
import "./i18n"
import './i18n';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
require('dotenv').config(); require('dotenv').config();

36
src/screens/HomeScreen.js

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

6
src/screens/LockoutScreen.js

@ -20,7 +20,7 @@ function Lockout() {
useEffect(() => { useEffect(() => {
toast({ toast({
title: t("checkingLockoutToastTitle"),
title: t('checkingLockoutToastTitle'),
status: 'info', status: 'info',
duration: 10000, duration: 10000,
}); });
@ -46,7 +46,7 @@ function Lockout() {
history.push('/login'); history.push('/login');
} else { } else {
toast({ toast({
title: t("defaultErrorToastDescription"),
title: t('defaultErrorToastDescription'),
status: 'error', status: 'error',
duration: 10000, duration: 10000,
}); });
@ -74,7 +74,7 @@ function Lockout() {
rounded={6} rounded={6}
id="contentFlex" id="contentFlex"
> >
<Heading>{t("Lockout")}</Heading>
<Heading>{t('Lockout')}</Heading>
<Trans i18nKey="lockoutExplanation"> <Trans i18nKey="lockoutExplanation">
<Text> <Text>
You have reported that you have been tested <b>POSITIVE</b> with You have reported that you have been tested <b>POSITIVE</b> with

22
src/screens/LoginScreen.js

@ -19,8 +19,8 @@ function Login() {
const handleTelegramResponse = response => { const handleTelegramResponse = response => {
toast({ toast({
title: t("loggingInToastTitle"),
description: t("loggingInToastDescription"),
title: t('loggingInToastTitle'),
description: t('loggingInToastDescription'),
status: 'info', status: 'info',
duration: 10000, duration: 10000,
isClosable: false, isClosable: false,
@ -48,7 +48,7 @@ function Login() {
toast.closeAll(); toast.closeAll();
dispatch(authLogout()); dispatch(authLogout());
toast({ toast({
title: t("defaultErrorToastDescription"),
title: t('defaultErrorToastDescription'),
description: response.data.message, description: response.data.message,
status: 'error', status: 'error',
duration: 9000, duration: 9000,
@ -62,8 +62,8 @@ function Login() {
if (err.response.status === 401) { if (err.response.status === 401) {
dispatch(authLogout()); dispatch(authLogout());
toast({ toast({
title: t("failedLoginToastTitle"),
description: t("failedLoginToastDescription"),
title: t('failedLoginToastTitle'),
description: t('failedLoginToastDescription'),
status: 'error', status: 'error',
duration: 9000, duration: 9000,
isClosable: true, isClosable: true,
@ -71,8 +71,8 @@ function Login() {
} }
} else { } else {
toast({ toast({
title: t("errorToastTitle"),
description: t("defaultErrorToastDescription"),
title: t('errorToastTitle'),
description: t('defaultErrorToastDescription'),
status: 'error', status: 'error',
duration: 9000, duration: 9000,
isClosable: true, isClosable: true,
@ -98,10 +98,10 @@ function Login() {
id="contentFlex" id="contentFlex"
> >
<Heading size="xl" mb={6}> <Heading size="xl" mb={6}>
{t("appTitle")}
{t('appTitle')}
</Heading> </Heading>
<Heading size="lg" mb={4}> <Heading size="lg" mb={4}>
{t("login")}
{t('login')}
</Heading> </Heading>
<TelegramLoginButton <TelegramLoginButton
dataOnauth={handleTelegramResponse} dataOnauth={handleTelegramResponse}
@ -114,8 +114,8 @@ function Login() {
Telegram Login allows us to verify your identity, without collecting Telegram Login allows us to verify your identity, without collecting
any of your data. Telegram does NOT give us your phone number. The 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, 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.
this is an internal ID Number Telegram uses that is SEPARATE from
your Telegram Username.
<br /> <br />
<br /> <br />
All the code for this project is{' '} All the code for this project is{' '}

12
src/screens/ScannerScreen.js

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

6
src/screens/SuccessScreen.js

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

8
src/screens/VerifyScreen.js

@ -34,12 +34,8 @@ function Verify(props) {
}); });
}, [verifyError, history, verifyID]); }, [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 ( return (
<Flex <Flex

Loading…
Cancel
Save