notification handling for register and login in navy and welfare
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// import Notifications from "@/core/components/notifications";
|
||||
import Notifications from "@/core/components/notifications";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import { LOGIN } from "@/core/data/apiRoutes";
|
||||
import CenterLayout from "@/layouts/CenterLayout";
|
||||
@@ -38,12 +38,14 @@ const SendToken = ({ PhoneNumber }) => {
|
||||
});
|
||||
|
||||
const handleSubmit = async (values, props) => {
|
||||
Notifications(directionApp, t, undefined);
|
||||
await axios
|
||||
.post(LOGIN, {
|
||||
phone_number: values.phone_number,
|
||||
verification_code: values.verification_code,
|
||||
})
|
||||
.then(function (response) {
|
||||
Notifications(directionApp, t, response);
|
||||
setToken(response.data.token);
|
||||
})
|
||||
.catch(function (error) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// import Notifications from "@/core/components/notifications";
|
||||
import Notifications from "@/core/components/notifications";
|
||||
import LinkRouting from "@/core/components/LinkRouting";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import { LOGIN_SEND_OTP_TOKEN } from "@/core/data/apiRoutes";
|
||||
@@ -39,16 +39,18 @@ const SendUserData = ({ setOtpToken, setPhoneNumber }) => {
|
||||
});
|
||||
|
||||
const handleSubmit = async (values, props) => {
|
||||
Notifications(directionApp, t, undefined);
|
||||
await axios
|
||||
.post(LOGIN_SEND_OTP_TOKEN, {
|
||||
phone_number: values.phone_number,
|
||||
})
|
||||
.then(function (response) {
|
||||
Notifications(directionApp, t, response);
|
||||
setPhoneNumber(values.phone_number);
|
||||
setOtpToken(true);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// Notifications(directionApp, error.response, t);
|
||||
Notifications(directionApp, error.response, t);
|
||||
props.setSubmitting(false);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -38,12 +38,14 @@ const SendToken = ({ PhoneNumber }) => {
|
||||
});
|
||||
|
||||
const handleSubmit = async (values, props) => {
|
||||
Notifications(directionApp, t, undefined);
|
||||
await axios
|
||||
.post(LOGIN, {
|
||||
phone_number: values.phone_number,
|
||||
verification_code: values.verification_code,
|
||||
})
|
||||
.then(function (response) {
|
||||
Notifications(directionApp, t, response);
|
||||
setToken(response.data.token);
|
||||
})
|
||||
.catch(function (error) {
|
||||
|
||||
@@ -37,6 +37,7 @@ const SendToken = ({ PhoneNumber, nationalId, navganId, typeId }) => {
|
||||
});
|
||||
|
||||
const handleSubmit = async (values, props) => {
|
||||
Notifications(directionApp, t, undefined);
|
||||
await axios
|
||||
.post(REGISTER, {
|
||||
phone_number: values.phone_number,
|
||||
@@ -46,10 +47,11 @@ const SendToken = ({ PhoneNumber, nationalId, navganId, typeId }) => {
|
||||
verification_code: values.verification_code,
|
||||
})
|
||||
.then(function (response) {
|
||||
Notifications(directionApp, t, response);
|
||||
setToken(response.data.token);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// Notifications(directionApp, error.response, t);
|
||||
Notifications(directionApp, error.response, t);
|
||||
props.setSubmitting(false);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import LinkRouting from "@/core/components/LinkRouting";
|
||||
import Notifications from "@/core/components/notifications";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import { REGISTER_SEND_OTP_TOKEN } from "@/core/data/apiRoutes";
|
||||
import CenterLayout from "@/layouts/CenterLayout";
|
||||
@@ -26,6 +27,7 @@ const SendUserData = ({
|
||||
setTypeId,
|
||||
}) => {
|
||||
const t = useTranslations();
|
||||
const { directionApp } = useDirection();
|
||||
|
||||
const searchParams = useSearchParams();
|
||||
const backUrlDecodedPath = searchParams.get("back_url");
|
||||
@@ -47,6 +49,7 @@ const SendUserData = ({
|
||||
});
|
||||
|
||||
const handleSubmit = async (values, props) => {
|
||||
Notifications(directionApp, t, undefined);
|
||||
await axios
|
||||
.post(REGISTER_SEND_OTP_TOKEN, {
|
||||
type_id: values.type_id,
|
||||
@@ -55,6 +58,7 @@ const SendUserData = ({
|
||||
phone_number: values.phone_number,
|
||||
})
|
||||
.then(function (response) {
|
||||
Notifications(directionApp, t, response);
|
||||
setPhoneNumber(values.phone_number);
|
||||
setNationalId(values.national_id);
|
||||
setNavganId(values.navgan_id);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import LinkRouting from "@/core/components/LinkRouting";
|
||||
import Notifications from "@/core/components/notifications";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import { REGISTER_SEND_OTP_TOKEN } from "@/core/data/apiRoutes";
|
||||
import CenterLayout from "@/layouts/CenterLayout";
|
||||
import FullPageLayout from "@/layouts/FullPageLayout";
|
||||
import useDirection from "@/lib/app/hooks/useDirection";
|
||||
import FingerprintIcon from "@mui/icons-material/Fingerprint";
|
||||
import {
|
||||
Box,
|
||||
@@ -27,6 +29,7 @@ const SendUserData = ({
|
||||
setTypeId,
|
||||
}) => {
|
||||
const t = useTranslations();
|
||||
const { directionApp } = useDirection();
|
||||
|
||||
const searchParams = useSearchParams();
|
||||
const backUrlDecodedPath = searchParams.get("back_url");
|
||||
@@ -46,6 +49,7 @@ const SendUserData = ({
|
||||
});
|
||||
|
||||
const handleSubmit = async (values, props) => {
|
||||
Notifications(directionApp, t, undefined);
|
||||
await axios
|
||||
.post(REGISTER_SEND_OTP_TOKEN, {
|
||||
type_id: values.type_id,
|
||||
@@ -53,6 +57,7 @@ const SendUserData = ({
|
||||
phone_number: values.phone_number,
|
||||
})
|
||||
.then(function (response) {
|
||||
Notifications(directionApp, t, response);
|
||||
setPhoneNumber(values.phone_number);
|
||||
setNationalId(values.national_id);
|
||||
setTypeId(values.type_id);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import Notifications from "@/core/components/notifications";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import { REGISTER } from "@/core/data/apiRoutes";
|
||||
import CenterLayout from "@/layouts/CenterLayout";
|
||||
import FullPageLayout from "@/layouts/FullPageLayout";
|
||||
// import useDirection from "@/lib/app/hooks/useDirection";
|
||||
import useDirection from "@/lib/app/hooks/useDirection";
|
||||
import useUser from "@/lib/app/hooks/useUser";
|
||||
import LoginIcon from "@mui/icons-material/Login";
|
||||
import {
|
||||
@@ -22,7 +23,7 @@ import * as Yup from "yup";
|
||||
|
||||
const SendToken = ({ PhoneNumber, nationalId, typeId }) => {
|
||||
const t = useTranslations();
|
||||
// const { directionApp } = useDirection();
|
||||
const { directionApp } = useDirection();
|
||||
const { setToken } = useUser();
|
||||
|
||||
const initialValues = {
|
||||
@@ -38,6 +39,7 @@ const SendToken = ({ PhoneNumber, nationalId, typeId }) => {
|
||||
});
|
||||
|
||||
const handleSubmit = async (values, props) => {
|
||||
Notifications(directionApp, t, undefined);
|
||||
await axios
|
||||
.post(REGISTER, {
|
||||
phone_number: values.phone_number,
|
||||
@@ -46,10 +48,11 @@ const SendToken = ({ PhoneNumber, nationalId, typeId }) => {
|
||||
verification_code: values.verification_code,
|
||||
})
|
||||
.then(function (response) {
|
||||
Notifications(directionApp, t, response);
|
||||
setToken(response.data.token);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// Notifications(directionApp, error.response, t);
|
||||
Notifications(directionApp, error.response, t);
|
||||
props.setSubmitting(false);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user