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

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>

6
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,7 +74,7 @@ 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

22
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}
@ -114,8 +114,8 @@ function Login() {
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.
this is an internal ID Number Telegram uses that is SEPARATE from
your Telegram Username.
<br />
<br />
All the code for this project is{' '}

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