diff --git a/src/components/login-expert/index.jsx b/src/components/login-expert/index.jsx index 65b1e1c..bcc3b1a 100644 --- a/src/components/login-expert/index.jsx +++ b/src/components/login-expert/index.jsx @@ -2,7 +2,7 @@ import LinkRouting from "@/core/components/LinkRouting"; // import Notifications from "@/core/components/notifications"; import PasswordField from "@/core/components/PasswordField"; import StyledForm from "@/core/components/StyledForm"; -// import { GET_USER_TOKEN } from "@/core/data/apiRoutes"; +import { GET_USER_TOKEN } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useDirection from "@/lib/app/hooks/useDirection"; @@ -17,7 +17,7 @@ import { TextField, Typography, } from "@mui/material"; -// import axios from "axios"; +import axios from "axios"; import { Field, Formik } from "formik"; import { useTranslations } from "next-intl"; import Image from "next/image"; @@ -33,21 +33,23 @@ const LoginComponent = () => { const searchParams = useSearchParams(); const backUrlDecodedPath = searchParams.get("back_url"); - // formik properties - // const handleSubmit = async (values, props) => { - // await axios - // .post(GET_USER_TOKEN, { - // username: values.username, - // password: values.password, - // }) - // .then(function (response) { - // setToken(response.data.token); - // }) - // .catch(function (error) { - // Notifications(directionApp, error.response, t); - // props.setSubmitting(false); - // }); - // }; + //formik properties + const handleSubmit = async (values, props) => { + await axios + .post(GET_USER_TOKEN, { + username: values.username, + password: values.password, + }) + .then(function (response) { + console.log(response); + setToken(response.data.token); + }) + .catch(function (error) { + // Notifications(directionApp, error.response, t); + console.log(error); + props.setSubmitting(false); + }); + }; const initialValues = { username: "", password: "", @@ -64,7 +66,7 @@ const LoginComponent = () => { {(props) => ( diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index 0877232..7e05eec 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -1,6 +1,9 @@ const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL; +//login +export const GET_USER_TOKEN = BASE_URL + "/dashboard/login"; +//end login + //change password -export const CHANGE_PASSWORD = - BASE_URL + "/dashboard/profile/change_password"; -//end change password \ No newline at end of file +export const CHANGE_PASSWORD = BASE_URL + "/dashboard/profile/change_password"; +//end change password diff --git a/src/pages/dashboard/loan-follow-up/index.jsx b/src/pages/dashboard/loan-follow-up/index.jsx index fc299c4..6bab35f 100644 --- a/src/pages/dashboard/loan-follow-up/index.jsx +++ b/src/pages/dashboard/loan-follow-up/index.jsx @@ -6,7 +6,7 @@ import { parse } from "next-useragent"; export default function LoanFollowUp() { return ( - + ); diff --git a/src/pages/dashboard/loan-request/index.jsx b/src/pages/dashboard/loan-request/index.jsx index b76f172..ad64ce8 100644 --- a/src/pages/dashboard/loan-request/index.jsx +++ b/src/pages/dashboard/loan-request/index.jsx @@ -6,7 +6,7 @@ import { parse } from "next-useragent"; export default function LoanRequest() { return ( - + );