Merge branch 'feature/login_implement' into 'develop'

Feature/login implement

See merge request witel3/loan-facilities-expert!14
This commit is contained in:
yasaman aliakbari
2023-07-12 06:48:07 +00:00
4 changed files with 28 additions and 23 deletions

View File

@@ -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 = () => {
<Paper elevation={0}>
<Formik
initialValues={initialValues}
// onSubmit={handleSubmit}
onSubmit={handleSubmit}
validationSchema={validationSchema}
>
{(props) => (

View File

@@ -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
export const CHANGE_PASSWORD = BASE_URL + "/dashboard/profile/change_password";
//end change password

View File

@@ -6,7 +6,7 @@ import { parse } from "next-useragent";
export default function LoanFollowUp() {
return (
<WithAuthMiddleware>
<TitlePage text="dashboard.dashboard_page" />
<TitlePage text="Dashboard.dashboard_page" />
<DashboardLoanFollowUpComponent />
</WithAuthMiddleware>
);

View File

@@ -6,7 +6,7 @@ import { parse } from "next-useragent";
export default function LoanRequest() {
return (
<WithAuthMiddleware>
<TitlePage text="dashboard.dashboard_page" />
<TitlePage text="Dashboard.dashboard_page" />
<DashboardLoanRequestComponent />
</WithAuthMiddleware>
);