diff --git a/src/components/root/Login.js b/src/components/root/Login.js
index f47a52d6..452b841f 100644
--- a/src/components/root/Login.js
+++ b/src/components/root/Login.js
@@ -37,8 +37,11 @@ const Login = () => {
const [btnDisabled, setBtnDisabled] = useState(true);
const [isProcessing, setIsProcessing] = useState(false);
const [isCompleted, setIsCompleted] = useState(false);
- const [verifyLink, setVerifyLink] = useState('');
- const [isLogin, setIsLogin] = useState(false);
+
+ const [isCreateWithLink, setIsCreateWithLink] = useState(false);
+ const [isCreateWithoutLink, setIsCreateWithoutLink] = useState(false);
+ const [isAccountNotVerified, setIsAccountNotVerified] = useState(false);
+ const [isEmailResent, setIsEmailResent] = useState(false);
const [isOpen, setIsOpen] = useRecoilState(isLoginOpenState);
@@ -84,9 +87,8 @@ const Login = () => {
setIsUserLogged(true);
handleClose();
} else {
- setIsLogin(true);
if (data.message !== 'VERIFY_FAILED') {
- setVerifyLink(data.message);
+ setIsAccountNotVerified(true);
}
setIsCompleted(true);
setIsProcessing(false);
@@ -138,8 +140,10 @@ const Login = () => {
.then(async (res) => {
const data = await res.json();
if (res.status === 200) {
- if (data.message !== 'VERIFY_FAILED') {
- setVerifyLink(data.message);
+ if (data.message === 'VERIFY_FAILED') {
+ setIsCreateWithoutLink(true);
+ } else {
+ setIsCreateWithLink(true);
}
setIsCompleted(true);
setIsProcessing(false);
@@ -159,6 +163,47 @@ const Login = () => {
}
};
+ const resendVerification = async () => {
+ setIsCompleted(false);
+ setIsCreateWithLink(false);
+ setIsCreateWithoutLink(false);
+ setIsAccountNotVerified(false);
+ setIsProcessing(true);
+ const reqPayload = {
+ email: email,
+ password: password,
+ };
+
+ if (apiHost !== '') {
+ fetch(`${apiHost}api/resend-verification`, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(reqPayload),
+ })
+ .then(async (res) => {
+ const data = await res.json();
+ if (res.status === 200 && data.message === 'CHECK_EMAIL') {
+ setIsEmailResent(true);
+ setIsCompleted(true);
+ setIsProcessing(false);
+ } else {
+ setIsProcessing(false);
+ setAppMessage(data.message);
+ setAppSeverity('warning');
+ setAppSnackOpen(true);
+ }
+ })
+ .catch(() => {
+ setIsProcessing(false);
+ setAppMessage(t('login.createFailed'));
+ setAppSeverity('error');
+ setAppSnackOpen(true);
+ });
+ }
+ };
+
const handleTypeLoginCheck = (e) => {
setIsNewAccount(e.target.checked);
setPassword('');
@@ -297,40 +342,43 @@ const Login = () => {
<>
{isCompleted && (
<>
- {isLogin && (
+ {isEmailResent && (
+
+ {t('login.accountNewLink')}
+
+ )}
+
+ {isNewAccount && (
<>
- {verifyLink.length === 0 && (
+ {isCreateWithLink && (
- {t('login.accountNotVerifiedNoLink')}
+ {t('login.accountCreated')}
)}
- {verifyLink.length > 0 && (
-
- {t('login.accountNotVerified')}
-
- {t('login.accountActivate')}
-
- .
-
+ {isCreateWithoutLink && (
+ <>
+
+ {t('login.accountCreatedNoLink')}
+
+
+
+ {t('login.accountResendLink')}
+
+
+ >
)}
>
)}
- {!isLogin && (
+ {!isNewAccount && isAccountNotVerified && (
<>
- {verifyLink.length === 0 && (
-
- {t('login.accountCreateWithoutLink')}
-
- )}
- {verifyLink.length > 0 && (
-
- {t('login.accountCreateWithLink')}
-
- {t('login.accountActivate')}
-
- .
-
- )}
+
+ {t('login.accountNotVerified')}
+
+
+
+ {t('login.accountResendLink')}
+
+
>
)}
diff --git a/src/locales/e.json b/src/locales/e.json
index 3344769e..2e2bc9ce 100644
--- a/src/locales/e.json
+++ b/src/locales/e.json
@@ -116,14 +116,14 @@
"login.confirmPassword": "Confirm password",
"login.newAccount": "NEW ACCOUNT",
"login.createAccount": "Create",
- "login.accountCreateWithLink": "Account successfully created. Please visit this link to activate your account: ",
- "login.accountActivate": "Activate",
- "login.accountCreateWithoutLink": "Account successfully created. Please login again to activate your account.",
"login.accountNotFound": "The provided login does not exist yet.",
"login.accountDisabled": "The account that you are trying to access is currently disabled.",
- "login.accountNotVerified": "You are logged in, but you are account is not yet activated. Please visit this link to activate it: ",
- "login.accountNotVerifiedNoLink": "Please login again to activate your account",
"login.createFailed": "An error occured and your account could not be created",
+ "login.accountCreated": "Your account is created, but you have to check the verification email before using it.",
+ "login.accountCreatedNoLink": "Your account is created, but we failed to send the verification email",
+ "login.accountNotVerified": "This account is valid, but it is not yet verified. Please check your email address to verify it",
+ "login.accountResendLink": "Resend verification email",
+ "login.accountNewLink": "The verification email has been resent",
"administration.congConnectInfo": "CONNECTION INFORMATION",
"administration.swsPocketAccess": "ACCESS TO SWS POCKET",
diff --git a/src/locales/mg.json b/src/locales/mg.json
index a64ed72a..28f9d6a5 100644
--- a/src/locales/mg.json
+++ b/src/locales/mg.json
@@ -116,14 +116,14 @@
"login.confirmPassword": "Avereno ampidirina",
"login.newAccount": "KAONTY VAOVAO",
"login.createAccount": "Hamorona",
- "login.accountCreateWithLink": "Vita ny famoronana ny kaonty vaovao. Tsindrio ity rohy ity mba hampandehanana ny kaontinao: ",
- "login.accountActivate": "Hanamarina",
- "login.accountCreateWithoutLink": "Vita ny famoronana ny kaonty vaovao. Miverina miditra mba hampandehanana ny kaontinao.",
"login.accountNotFound": "Tsy mbola misy ireo fanazavana nampidirinao ireo.",
"login.accountDisabled": "Natsahatra io kaonty tianao hidirana io.",
- "login.accountNotVerified": "Tafiditra ianao fa saingy tsy mbola azo ampiasaina ny kaontinao. Tsindrio ity rohy ity mba hampandehanana ny kaontinao: ",
- "login.accountNotVerifiedNoLink": "Miverena miditra indray mba hampandehanana ny kaontinao",
"login.createFailed": "Nisy olana ka tsy afaka namboarina ny kaontinao",
+ "login.accountCreated": "Vita ny fanamboarana ny kaontinao. Alohan’ny hampiasana azy ity, dia hamarino aloha ny hafatra lasa any amin’ny adiresinao",
+ "login.accountCreatedNoLink": "Vita ny fanamboarana ny kaontinao. Nisy olana anefa ka tsy mbola lasa ny hafatra fanamarinana izany",
+ "login.accountNotVerified": "Azo ampiasaina io kaonty io saingy tsy mbola voamarina. Hamarino ny hafatra any amin’ny adiresinao hanamarinana azy ity",
+ "login.accountResendLink": "Hamerina handefa ny hafatra fanamarinana",
+ "login.accountNewLink": "Naverina nalefa ny hafatra fanamarinana ny kaontinao",
"administration.congConnectInfo": "FANAZAVANA AMIN’NY FAMPIASANA INTERNET",
"administration.swsPocketAccess": "AFAKA MAMPIASA SWS POCKET",
diff --git a/src/pages/Administration.js b/src/pages/Administration.js
index 12468ba6..7c2e4f39 100644
--- a/src/pages/Administration.js
+++ b/src/pages/Administration.js
@@ -1,7 +1,7 @@
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
-import Box from "@mui/material/Box";
+import Box from '@mui/material/Box';
import CircleIcon from '@mui/icons-material/Circle';
import CircularProgress from '@mui/material/CircularProgress';
import FlashAutoIcon from '@mui/icons-material/FlashAuto';
@@ -11,284 +11,325 @@ import SettingsBackupRestoreIcon from '@mui/icons-material/SettingsBackupRestore
import TextField from '@mui/material/TextField';
import Tooltip from '@mui/material/Tooltip';
import Typography from '@mui/material/Typography';
-import { apiHostState, isCongConnectedState, uidUserState } from '../appStates/appSettings';
-import { congIDState, congNameState, congNumberState, congPasswordState } from '../appStates/appCongregation';
-import { appMessageState, appSeverityState, appSnackOpenState } from '../appStates/appNotification';
+import {
+ apiHostState,
+ isCongConnectedState,
+ uidUserState,
+} from '../appStates/appSettings';
+import {
+ congIDState,
+ congNameState,
+ congNumberState,
+ congPasswordState,
+} from '../appStates/appCongregation';
+import {
+ appMessageState,
+ appSeverityState,
+ appSnackOpenState,
+} from '../appStates/appNotification';
import { dbUpdateAppSettings } from '../indexedDb/dbAppSettings';
const Administration = () => {
- const { t } = useTranslation();
+ const { t } = useTranslation();
- const [isNewID, setIsNewID] = useState(false);
- const [isFailedConnect, setIsFailedConnect] = useState(false);
- const [isIddle, setIsIddle] = useState(false);
- const [isGenerate, setIsGenerate] = useState(false);
+ const [isNewID, setIsNewID] = useState(false);
+ const [isFailedConnect, setIsFailedConnect] = useState(false);
+ const [isIddle, setIsIddle] = useState(false);
+ const [isGenerate, setIsGenerate] = useState(false);
- const [congID, setCongID] = useRecoilState(congIDState);
- const [congPassword, setCongPassword] = useRecoilState(congPasswordState);
- const [isConnected, setIsConnected] = useRecoilState(isCongConnectedState);
+ const [congID, setCongID] = useRecoilState(congIDState);
+ const [congPassword, setCongPassword] = useRecoilState(congPasswordState);
+ const [isConnected, setIsConnected] = useRecoilState(isCongConnectedState);
- const [congTempID, setCongTempID] = useState(congID);
- const [congTempPassword, setCongTempPassword] = useState(congPassword);
+ const [congTempID, setCongTempID] = useState(congID);
+ const [congTempPassword, setCongTempPassword] = useState(congPassword);
- const apiHost = useRecoilValue(apiHostState);
- const uidUser = useRecoilValue(uidUserState);
+ const apiHost = useRecoilValue(apiHostState);
+ const uidUser = useRecoilValue(uidUserState);
- const congName = useRecoilValue(congNameState);
- const congNumber = useRecoilValue(congNumberState);
+ const congName = useRecoilValue(congNameState);
+ const congNumber = useRecoilValue(congNumberState);
- const setAppSnackOpen = useSetRecoilState(appSnackOpenState);
- const setAppSeverity = useSetRecoilState(appSeverityState);
- const setAppMessage = useSetRecoilState(appMessageState);
+ const setAppSnackOpen = useSetRecoilState(appSnackOpenState);
+ const setAppSeverity = useSetRecoilState(appSeverityState);
+ const setAppMessage = useSetRecoilState(appMessageState);
- const handleChangeID = (e) => {
- setCongTempID(e.target.value);
- setIsNewID(false);
- }
+ const handleChangeID = (e) => {
+ setCongTempID(e.target.value);
+ setIsNewID(false);
+ };
- const handleGenerateCongPIN = () => {
- setIsGenerate(true);
- if (apiHost !== '') {
- fetch(`${apiHost}api/generate-congregation-id`, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- uid: uidUser,
- },
- })
- .then(async (res) => {
- const data = await res.json();
- if (res.status === 200) {
- setCongTempID(data.message);
- setIsNewID(true);
- } else {
- let warnMsg;
- if (data.message === 'FORBIDDEN') {
- warnMsg = t("administration.warnForbidden")
- } else {
- warnMsg = t("global.errorTryAgain");
- }
- setAppMessage(warnMsg);
- setAppSeverity('warning');
- setAppSnackOpen(true);
- }
- setIsGenerate(false);
- })
- .catch((err) => {
- setIsGenerate(false);
- setAppMessage(err.message);
- setAppSeverity('error');
- setAppSnackOpen(true);
- })
- }
- }
+ const handleGenerateCongPIN = () => {
+ setIsGenerate(true);
+ if (apiHost !== '') {
+ fetch(`${apiHost}api/generate-congregation-id`, {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ uid: uidUser,
+ },
+ })
+ .then(async (res) => {
+ const data = await res.json();
+ if (res.status === 200) {
+ setCongTempID(data.message);
+ setIsNewID(true);
+ } else {
+ let warnMsg;
+ if (data.message === 'FORBIDDEN') {
+ warnMsg = t('administration.warnForbidden');
+ } else {
+ warnMsg = t('global.errorTryAgain');
+ }
+ setAppMessage(warnMsg);
+ setAppSeverity('warning');
+ setAppSnackOpen(true);
+ }
+ setIsGenerate(false);
+ })
+ .catch((err) => {
+ setIsGenerate(false);
+ setAppMessage(err.message);
+ setAppSeverity('error');
+ setAppSnackOpen(true);
+ });
+ }
+ };
- const resetLoginInfo = () => {
- setCongTempID(congID);
- setCongTempPassword(congPassword);
- }
+ const resetLoginInfo = () => {
+ setCongTempID(congID);
+ setCongTempPassword(congPassword);
+ };
- const handleCreateCongAccount = async () => {
- setIsIddle(true);
- setIsConnected(false);
- setIsFailedConnect(false);
+ const handleCreateCongAccount = async () => {
+ setIsIddle(true);
+ setIsConnected(false);
+ setIsFailedConnect(false);
- const reqPayload = {
- cong_id: congTempID,
- cong_password: congTempPassword,
- cong_name: congName,
- cong_number: congNumber,
- }
+ const reqPayload = {
+ cong_id: congTempID,
+ cong_password: congTempPassword,
+ cong_name: congName,
+ cong_number: congNumber,
+ };
- if (apiHost !== '') {
- fetch(`${apiHost}api/create-congregation-account`, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- uid: uidUser,
- },
- body: JSON.stringify(reqPayload),
- })
- .then(async (res) => {
- const data = await res.json();
- if (res.status === 200) {
- await dbUpdateAppSettings({
- cong_id: congTempID,
- cong_password: congTempPassword,
- })
- setCongID(congTempID);
- setCongPassword(congTempPassword);
- setIsIddle(false);
- setIsConnected(true);
- } else {
- let warnMsg;
- if (data.message === 'FORBIDDEN') {
- warnMsg = t("administration.warnForbidden")
- } else {
- warnMsg = t("global.errorTryAgain");
- }
- setAppMessage(warnMsg);
- setAppSeverity('warning');
- setAppSnackOpen(true);
- setIsIddle(false);
- setIsFailedConnect(true);
- }
- })
- .catch((err) => {
- setIsIddle(false);
- setIsFailedConnect(true);
- setAppMessage(err.message);
- setAppSeverity('error');
- setAppSnackOpen(true);
- })
- }
- }
+ if (apiHost !== '') {
+ fetch(`${apiHost}api/create-congregation-account`, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ uid: uidUser,
+ },
+ body: JSON.stringify(reqPayload),
+ })
+ .then(async (res) => {
+ const data = await res.json();
+ if (res.status === 200) {
+ await dbUpdateAppSettings({
+ cong_id: congTempID,
+ cong_password: congTempPassword,
+ });
+ setCongID(congTempID);
+ setCongPassword(congTempPassword);
+ setIsIddle(false);
+ setIsConnected(true);
+ } else {
+ let warnMsg;
+ if (data.message === 'FORBIDDEN') {
+ warnMsg = t('administration.warnForbidden');
+ } else {
+ warnMsg = t('global.errorTryAgain');
+ }
+ setAppMessage(warnMsg);
+ setAppSeverity('warning');
+ setAppSnackOpen(true);
+ setIsIddle(false);
+ setIsFailedConnect(true);
+ }
+ })
+ .catch((err) => {
+ setIsIddle(false);
+ setIsFailedConnect(true);
+ setAppMessage(err.message);
+ setAppSeverity('error');
+ setAppSnackOpen(true);
+ });
+ }
+ };
- const handleSaveCongInfo = () => {
- console.log(isNewID);
- }
+ const handleSaveCongInfo = () => {
+ console.log(isNewID);
+ };
- return (
-
-
-
-
- {t("administration.congConnectInfo")}
-
-
-
-
-
-
-
-
-
- {isGenerate && (
-
- )}
- {!isGenerate && (
-
-
-
-
-
- )}
- setCongTempPassword(e.target.value)}
- />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {t("administration.swsPocketAccess")}
-
-
-
- );
-}
-
-export default Administration;
\ No newline at end of file
+ return (
+
+
+
+
+ {t('administration.congConnectInfo')}
+
+
+
+
+
+
+
+
+
+ {isGenerate && (
+
+ )}
+ {!isGenerate && (
+
+
+
+
+
+ )}
+ setCongTempPassword(e.target.value)}
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {t('administration.swsPocketAccess')}
+
+
+
+ );
+};
+
+export default Administration;
diff --git a/src/pages/Startup.js b/src/pages/Startup.js
index 3e58950a..ebea89c4 100644
--- a/src/pages/Startup.js
+++ b/src/pages/Startup.js
@@ -163,7 +163,7 @@ const Startup = () => {
setCongName(cong_name);
setClassCount(class_count);
setMeetingDay(meeting_day);
- setCongID(cong_ID);
+ setCongID(cong_ID || '');
setAppLang(app_lang);
setLiveClass(liveEventClass);