From b09d9c7859f3e91ba42a526c219f19a2ca9613db Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Mon, 30 Oct 2023 14:57:54 +0330 Subject: [PATCH 1/3] LFFE-3 improvement of change password --- .../change-password-form/index.jsx | 140 +++++++++++++++++ .../dashboard/change-password/index.jsx | 141 +----------------- 2 files changed, 143 insertions(+), 138 deletions(-) create mode 100644 src/components/dashboard/change-password/change-password-form/index.jsx diff --git a/src/components/dashboard/change-password/change-password-form/index.jsx b/src/components/dashboard/change-password/change-password-form/index.jsx new file mode 100644 index 0000000..e94801d --- /dev/null +++ b/src/components/dashboard/change-password/change-password-form/index.jsx @@ -0,0 +1,140 @@ +import {Formik} from "formik"; +import {useTranslations} from "next-intl"; +import useRequest from "@/lib/app/hooks/useRequest"; +import {SET_USER_PASSWORD} from "@/core/data/apiRoutes"; +import {Button, Paper, Stack, Typography} from "@mui/material"; +import * as Yup from "yup"; +import StyledForm from "@/core/components/StyledForm"; +import PasswordField from "@/core/components/PasswordField"; + +const ChangePasswordForm = ({onSubmit}) => { + const t = useTranslations(); + const requestServer = useRequest({auth: true}) + + const handleSubmit = (values, {setSubmitting, resetForm}) => { + requestServer(SET_USER_PASSWORD, 'post', { + data: { + current_password: values.current_password, + new_password: values.new_password, + new_password_confirmation: values.new_password_confirmation, + }, + }).then((response) => { + resetForm(); + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }; + const initialValues = { + current_password: "", + new_password: "", + new_password_confirmation: "", + }; + const validationSchema = Yup.object().shape({ + current_password: Yup.string().required( + t("ChangePassword.error_message_current_password") + ), + new_password: Yup.string() + .required(t("ExpertMangement.error_message_new_password")) + .matches( + /^(?=.*[a-zA-Z])(?=.*\d).{8,}$/, + t("ExpertMangement.error_message_new_password_regex") + ), + new_password_confirmation: Yup.string() + .required(t("ChangePassword.error_message_confirm_password")) + .test( + t("ChangePassword.error_message_password_match"), + t("ChangePassword.error_message_password_not_match"), + function (value) { + return this.parent.new_password === value; + } + ), + }); + + return ( + + {(props) => ( + { + e.preventDefault(); + props.handleSubmit(); + }} + > + + + + {t("ChangePassword.typography_change_password")} + + + + + + + + + + + + + + + )} + + ); +}; + +export default ChangePasswordForm; \ No newline at end of file diff --git a/src/components/dashboard/change-password/index.jsx b/src/components/dashboard/change-password/index.jsx index cd2b9fd..b6337d4 100644 --- a/src/components/dashboard/change-password/index.jsx +++ b/src/components/dashboard/change-password/index.jsx @@ -1,149 +1,14 @@ import CenterLayout from "@/layouts/CenterLayout"; import DashboardLayouts from "@/layouts/dashboardLayouts"; -import {Button, Container, Paper, Stack, Typography,} from "@mui/material"; -import {Formik} from "formik"; -import * as Yup from "yup"; -import {useTranslations} from "next-intl"; -import PasswordField from "@/core/components/PasswordField"; -import StyledForm from "@/core/components/StyledForm"; -import {SET_USER_PASSWORD} from "@/core/data/apiRoutes"; -import SvgChangePassword from "@/core/components/svgs/SvgChangePassword"; -import useRequest from "@/lib/app/hooks/useRequest"; +import {Container} from "@mui/material"; +import ChangePasswordForm from "@/components/dashboard/change-password/change-password-form"; const DashboardChangePasswordComponent = () => { - const t = useTranslations(); - const requestServer = useRequest({auth: true}) - - const handleSubmit = (values, {setSubmitting, resetForm}) => { - requestServer(SET_USER_PASSWORD, 'post', { - data: { - current_password: values.current_password, - new_password: values.new_password, - new_password_confirmation: values.new_password_confirmation, - }, - }).then((response) => { - resetForm(); - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }; - const initialValues = { - current_password: "", - new_password: "", - new_password_confirmation: "", - }; - const validationSchema = Yup.object().shape({ - current_password: Yup.string().required( - t("ChangePassword.error_message_current_password") - ), - new_password: Yup.string() - .required(t("ExpertMangement.error_message_new_password")) - .matches( - /^(?=.*[a-zA-Z])(?=.*\d).{8,}$/, - t("ExpertMangement.error_message_new_password_regex") - ), - new_password_confirmation: Yup.string() - .required(t("ChangePassword.error_message_confirm_password")) - .test( - t("ChangePassword.error_message_password_match"), - t("ChangePassword.error_message_password_not_match"), - function (value) { - return this.parent.new_password === value; - } - ), - }); - return ( - - {(props) => ( - { - e.preventDefault(); - props.handleSubmit(); - }} - > - - - - - {t("ChangePassword.typography_change_password")} - - - - - - - - - - - - - - - )} - + From d4e5812d181b460006a0a95d11c4fd7fcf6f1004 Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Mon, 30 Oct 2023 15:16:33 +0330 Subject: [PATCH 2/3] implementation of ecosystem.config.js --- .gitignore | 33 +++++++++++++++++++++++++++++++-- ecosystem.config.js.example | 18 ++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 ecosystem.config.js.example diff --git a/.gitignore b/.gitignore index 78b977c..1e62a6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,34 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory node_modules +cypress/videos +cypress/screenshots .next -.env.local +.env* +.env .idea -package-lock.json \ No newline at end of file +package-lock.json +ecosystem.config.js \ No newline at end of file diff --git a/ecosystem.config.js.example b/ecosystem.config.js.example new file mode 100644 index 0000000..983fa1c --- /dev/null +++ b/ecosystem.config.js.example @@ -0,0 +1,18 @@ +module.exports = { + apps: [{ + name: "loan facilities expert", + script: 'node_modules/next/dist/bin/next', // cluster mode run with node only, not npm + args: 'start', + exec_mode: "cluster", // default fork + instances: "max", + kill_timeout: 4000, + wait_ready: true, + autorestart: true, + watch: false, + max_memory_restart: "1G", + log_date_format: "YYYY-MM-DD HH:mm Z", + env_prod: { + APP_ENV: 'prod' // APP_ENV=prod + } + }], +}; \ No newline at end of file From f020c60537fd0650fc0d3a801fcf01cd2f22728c Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Mon, 30 Oct 2023 15:18:10 +0330 Subject: [PATCH 3/3] change version --- example.env.local | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example.env.local b/example.env.local index 24d5b8e..f102a46 100644 --- a/example.env.local +++ b/example.env.local @@ -1,5 +1,5 @@ NEXT_PUBLIC_API_NAME = "Loan Facilities Dashboard" -NEXT_PUBLIC_API_VERSION = "1.8.6" +NEXT_PUBLIC_API_VERSION = "1.8.10" NEXT_PUBLIC_DEFAULT_LANGUAGE = "fa" NEXT_PUBLIC_DEFAULT_DIRECTION = "rtl"