Merge branch 'develop' of https://gitlab.com/witel3/loan-facilities-expert into feature/show_profile

This commit is contained in:
Yasiu1376
2023-07-12 12:19:54 +03:30
8 changed files with 35 additions and 48 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,13 @@
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
//user data
export const GET_USER_ROUTE = BASE_URL + "/dashboard/profile/info";
//user data

View File

@@ -51,27 +51,7 @@ export const UserProvider = ({ children }) => {
dispatch({ type: "CHANGE_USER", user });
}, []);
const changeUserLanguage = useCallback(
(language) => {
dispatch({ type: "CHANGE_USER_LANGUAGE", language });
axios
.post(
SET_LANGUAGE,
{ language: language },
{
headers: {
authorization: `Bearer ${state.token}`,
},
}
)
.then(() => {
getUser((data) => {
changeUser(data);
});
});
},
[state.token]
);
const changeUserLanguage = useCallback(/* use in multi language app */);
const changeAuthState = useCallback((isAuth) => {
dispatch({ type: "CHANGE_AUTH_STATE", isAuth });

View File

@@ -10,7 +10,6 @@ const useUser = () => {
getUser,
clearUser,
changeUser,
changeUserLanguage,
changeAuthState,
changeLanguageState,
clearToken,
@@ -25,7 +24,6 @@ const useUser = () => {
getUser,
clearUser,
changeUser,
changeUserLanguage,
changeAuthState,
changeLanguageState,
clearToken,

View File

@@ -1,6 +1,6 @@
import DashboardChangePasswordComponent from "@/components/dashboard/change-password";
import TitlePage from "@/core/components/TitlePage";
import WithAuthMiddleware from "@/middlewares/WithoutAuth";
import WithAuthMiddleware from "@/middlewares/WithAuth";
import { parse } from "next-useragent";
export default function LoanFollowUp() {

View File

@@ -1,6 +1,6 @@
import DashboardFirstComponent from "@/components/dashboard/first";
import TitlePage from "@/core/components/TitlePage";
import WithAuthMiddleware from "@/middlewares/WithoutAuth";
import WithAuthMiddleware from "@/middlewares/WithAuth";
import { parse } from "next-useragent";
export default function Dashboard() {

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>
);