diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..7b24015 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,17 @@ +//!@ Author: Nguyễn Tiến Tài. +//! Description: Setting Vs Code +//!@ Created_At : 19-03-2023. + +{ + "recommendations": [ + "dbaeumer.vscode-eslint", + "editorconfig.editorconfig", + "xabikos.javascriptsnippets", + "stylelint.vscode-stylelint", + "fabiospampinato.vscode-highlight", + "dsznajder.es7-react-js-snippets", + "esbenp.prettier-vscode", + "ms-vscode.vscode-typescript-tslint-plugin", + "adpyke.vscode-sql-formatter" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 0e5fcd0..103d981 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,19 +1,43 @@ -//"editor.formatOnSave": true sẽ kích hoạt chức năng tự động định dạng (format) mã nguồn khi lưu file. -//"editor.defaultFormatter": "esbenp.prettier-vscode" chỉ định sử dụng thư viện esbenp.prettier-vscode để định dạng mã nguồn. -//"editor.codeActionsOnSave": { "source.fixAll": true } sẽ kích hoạt chức năng tự động sửa lỗi khi lưu file. -//"files.eol": "\n" sẽ chỉ định ký tự kết thúc dòng là dấu xuống dòng (new line) +//!@ Author: Nguyễn Tiến Tài. +//! Description: Setting Vs Code +//!@ Created_At : 20-12-2022. +//!@ Update_At: 13-02-2023 19-03-2023 + { + // Auto Format code "editor.formatOnSave": true, + + // Used Prettier format code "editor.defaultFormatter": "esbenp.prettier-vscode", + + // Update module import path when moving files. "javascript.updateImportsOnFileMove.enabled": "always", + + // Highlight brackets when the cursor is inside them "editor.guides.bracketPairs": "active", + + // Check syntax errors and errors in code with ESLint for JS and TS files. + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact" + ], + + // Automatically correct errors reported in the code when saving the file. "editor.codeActionsOnSave": { "source.fixAll": true }, + + // Set the newline character for files to be a newline (LF). "files.eol": "\n", + + // Use Extendtion SQL as default code format for SQL files. "[sql]": { "editor.defaultFormatter": "adpyke.vscode-sql-formatter" }, + + // cSpell spell check list of words to skip. "cSpell.words": [ "argothim", "Localstorage", diff --git a/frontend-manager-cms/nginx/default.conf b/frontend-manager-cms/nginx/default.conf index ccfb2f5..fb78073 100644 --- a/frontend-manager-cms/nginx/default.conf +++ b/frontend-manager-cms/nginx/default.conf @@ -1,5 +1,5 @@ server{ - listen 3000; + listen 3001; location / { root /usr/share/nginx/html; diff --git a/frontend-manager-student/src/App.css b/frontend-manager-student/src/App.css deleted file mode 100644 index e69de29..0000000 diff --git a/frontend-manager-student/src/api/api_user.js b/frontend-manager-student/src/api/api_user.js index a638bd3..efa3233 100644 --- a/frontend-manager-student/src/api/api_user.js +++ b/frontend-manager-student/src/api/api_user.js @@ -40,14 +40,14 @@ const API_STUDENT = { * @created_at 10/03/2023 * @descriptionKey API GET ALL BOOK */ - GET_ALL_BOOK_STUDENT: '/student/v1/user/private/book/all', + GET_ALL_BOOK_STUDENT: '/student/v1/user/book/all', /** * @author Châu Gia Bảo * @created_at 10/03/2023 * @descriptionKey API GET DETAIL BOOK */ - GET_DETAIL_BOOK_STUDENT: '/student/v1/user/private/book/detail', + GET_DETAIL_BOOK_STUDENT: '/student/v1/user/book/detail', /** * @author Châu Gia Bảo diff --git a/frontend-manager-student/src/components/BookCard.jsx b/frontend-manager-student/src/components/BookCard.jsx index 55652fd..9ced6d9 100644 --- a/frontend-manager-student/src/components/BookCard.jsx +++ b/frontend-manager-student/src/components/BookCard.jsx @@ -1,5 +1,8 @@ +//! LIBRARY import React from 'react'; import { Link } from 'react-router-dom'; + +//! COMPONENTS import Button from './Button'; const BookCard = (props) => { diff --git a/frontend-manager-student/src/components/Button.jsx b/frontend-manager-student/src/components/Button.jsx index e456aa3..348ba44 100644 --- a/frontend-manager-student/src/components/Button.jsx +++ b/frontend-manager-student/src/components/Button.jsx @@ -1,3 +1,4 @@ +//! LIBRARY import React from 'react'; import PropTypes from 'prop-types'; diff --git a/frontend-manager-student/src/components/CategoryCard.jsx b/frontend-manager-student/src/components/CategoryCard.jsx index c8579aa..41b90f3 100644 --- a/frontend-manager-student/src/components/CategoryCard.jsx +++ b/frontend-manager-student/src/components/CategoryCard.jsx @@ -1,3 +1,4 @@ +//! LIBRARY import React from 'react'; import PropTypes from 'prop-types'; diff --git a/frontend-manager-student/src/components/Dropdown.jsx b/frontend-manager-student/src/components/Dropdown.jsx index 200e3f3..d18d111 100644 --- a/frontend-manager-student/src/components/Dropdown.jsx +++ b/frontend-manager-student/src/components/Dropdown.jsx @@ -1,3 +1,4 @@ +//! LIBRARY import React, { useState } from 'react'; import { Form } from 'react-bootstrap'; diff --git a/frontend-manager-student/src/components/Filter.jsx b/frontend-manager-student/src/components/Filter.jsx index a38afd3..d75d02e 100644 --- a/frontend-manager-student/src/components/Filter.jsx +++ b/frontend-manager-student/src/components/Filter.jsx @@ -1,3 +1,4 @@ +//! LIBRARY import React from 'react'; const Filter = () => { diff --git a/frontend-manager-student/src/components/Footer.jsx b/frontend-manager-student/src/components/Footer.jsx index a698c5c..66074d7 100644 --- a/frontend-manager-student/src/components/Footer.jsx +++ b/frontend-manager-student/src/components/Footer.jsx @@ -1,6 +1,11 @@ +//! LIBRARY import React from 'react'; -import { FB_LOGO, SCHOOL_LOGO, YTB_LOGO, ZL_LOGO } from '../imports/home_import/index'; import { Link } from 'react-router-dom'; + +//! IMPORT +import { FB_LOGO, SCHOOL_LOGO, YTB_LOGO, ZL_LOGO } from '../imports/home_import/index'; + +//! COMPONENTS import Grid from './Grid'; const Footer = () => { diff --git a/frontend-manager-student/src/components/Grid.jsx b/frontend-manager-student/src/components/Grid.jsx index eab8188..c3288fe 100644 --- a/frontend-manager-student/src/components/Grid.jsx +++ b/frontend-manager-student/src/components/Grid.jsx @@ -1,3 +1,4 @@ +//! LIBRARY import React from 'react'; import propTypes from 'prop-types'; diff --git a/frontend-manager-student/src/components/Helmet.jsx b/frontend-manager-student/src/components/Helmet.jsx index a82a3a9..27f9d6c 100644 --- a/frontend-manager-student/src/components/Helmet.jsx +++ b/frontend-manager-student/src/components/Helmet.jsx @@ -1,3 +1,4 @@ +//! LIBRARY import React, { useEffect } from 'react'; import propTypes from 'prop-types'; diff --git a/frontend-manager-student/src/components/Layout.jsx b/frontend-manager-student/src/components/Layout.jsx index 1173f8b..1555fab 100644 --- a/frontend-manager-student/src/components/Layout.jsx +++ b/frontend-manager-student/src/components/Layout.jsx @@ -1,8 +1,13 @@ -import Header from 'components/Header'; -import Login from 'pages/Auth/Login'; +//! LIBRARY import React, { useState } from 'react'; + +//! PAGE +import Login from 'pages/Auth/Login'; import Footer from './Footer'; +//! COMPONENTS +import Header from 'components/Header'; + const Layout = (props) => { const [showLogin, setShowLogin] = useState(false); diff --git a/frontend-manager-student/src/components/Loading.jsx b/frontend-manager-student/src/components/Loading.jsx index 073f635..3c1829f 100644 --- a/frontend-manager-student/src/components/Loading.jsx +++ b/frontend-manager-student/src/components/Loading.jsx @@ -1,7 +1,14 @@ +//! LIBRARY import React from 'react'; +//! STYLE +import 'styles/components/_loading.scss'; const Loading = () => { - return
Loading....
; + return ( + <> + + + ); }; export default Loading; diff --git a/frontend-manager-student/src/components/NewsCard.jsx b/frontend-manager-student/src/components/NewsCard.jsx index db74d1c..aa42e7d 100644 --- a/frontend-manager-student/src/components/NewsCard.jsx +++ b/frontend-manager-student/src/components/NewsCard.jsx @@ -1,3 +1,4 @@ +//! LIBRARY import React from 'react'; import PropTypes from 'prop-types'; diff --git a/frontend-manager-student/src/components/Section.jsx b/frontend-manager-student/src/components/Section.jsx index 5140ab7..c0757fa 100644 --- a/frontend-manager-student/src/components/Section.jsx +++ b/frontend-manager-student/src/components/Section.jsx @@ -1,3 +1,4 @@ +//! LIBRARY import React from 'react'; import { Link } from 'react-router-dom'; diff --git a/frontend-manager-student/src/configs/constants.js b/frontend-manager-student/src/configs/constants.js index 6ab0723..3fe14a3 100644 --- a/frontend-manager-student/src/configs/constants.js +++ b/frontend-manager-student/src/configs/constants.js @@ -91,5 +91,17 @@ const CONSTANTS = { PNG: 'image/png', FILE: 'file', }, + /** + * @author Nguyễn Tiến Tài + * @created_at 15/03/2023 + * @descriptionKey STATUS CODE + * @return {string} + */ + STATUS: { + _OK: 200, + _BAD_REQUEST: 400, + _UNAUTHORIZED: 401, + _NOT_FOUND: 404, + }, }; export default CONSTANTS; diff --git a/frontend-manager-student/src/configs/text_notification.js b/frontend-manager-student/src/configs/text_notification.js index 2d6ba23..7860f26 100644 --- a/frontend-manager-student/src/configs/text_notification.js +++ b/frontend-manager-student/src/configs/text_notification.js @@ -3,15 +3,34 @@ const TEXT_NOTIFICATION = { * @author Nguyễn Tiến Tài,Châu Gia Bảo * @created_at 04/03/2023 * @updated_at 15/03/2023,16/03/2023 - * @description LOgin success + * @description Text title web */ NOTIFICATION_LOGIN_SUCCESS: 'Đăng nhập thành công', + NOTIFICATION_LOGOUT_SUCCESS: 'Đăng xuất thành công', + NOTIFICATION_CHANGE_PASSWORD_SUCCESS: 'Đổi mật khẩu thành công', + NOTIFICATION_SEND_MAIL_SUCCESS: 'Gửi mail thành công', - NOTIFICATION_RESET_PASSWORD_SUCCESS: 'Reset password thành công', + + NOTIFICATION_RESET: { + PASSWORD_SUCCESS_TITLE: 'Reset password thành công', + PASSWORD_SUCCESS_TEXT: 'Hãy quay về trang chủ để đăng nhập', + }, + NOTIFICATION_FORGET_PASSWORD_SUCCESS: 'Đã gửi link reset password đến ${email}. Vui lòng vào email của bạn để tiếp tục', NOTIFICATION_LOGIN_SESSION_EXPIRE: 'Phiên đăng nhập của bạn đã hết hạn', + /** + * @author Nguyễn Tiến Tài,Châu Gia Bảo + * @created_at 19/03/2023 + * @description Text input + */ + NOTIFICATION_INPUT_INVALID: { + _EMAIL: 'Email Không được bỏ trống !!!', + _PHONE: 'Phone Không được bỏ trống !!!', + _FULL_NAME: 'Full Name Không được bỏ trống !!!', + _MSSV: 'MSSV Không được bỏ trống !!!', + }, }; export default TEXT_NOTIFICATION; diff --git a/frontend-manager-student/src/custom_hook/useNavigate/Navigate.jsx b/frontend-manager-student/src/custom_hook/useNavigate/Navigate.jsx new file mode 100644 index 0000000..6198507 --- /dev/null +++ b/frontend-manager-student/src/custom_hook/useNavigate/Navigate.jsx @@ -0,0 +1,16 @@ +//! LIBRARY +import { useNavigate } from 'react-router-dom'; + +const Navigate = () => { + //Create navigate + const navigate = useNavigate(); + + // Handle change page + const navigateChangePage = (link) => { + navigate(link); + }; + + return { navigateChangePage }; +}; + +export default Navigate; diff --git a/frontend-manager-student/src/custom_hook/uploadMediaCloud.jsx b/frontend-manager-student/src/custom_hook/useUpload/uploadMediaCloud.jsx similarity index 100% rename from frontend-manager-student/src/custom_hook/uploadMediaCloud.jsx rename to frontend-manager-student/src/custom_hook/useUpload/uploadMediaCloud.jsx diff --git a/frontend-manager-student/src/imports/auth_import/index.js b/frontend-manager-student/src/imports/auth_import/index.js index e9dad78..c38c8ed 100644 --- a/frontend-manager-student/src/imports/auth_import/index.js +++ b/frontend-manager-student/src/imports/auth_import/index.js @@ -1,9 +1,11 @@ -//Change Password +// Change Password export { default as TabChangePassword } from 'pages/Auth/ChangePassword/component/TabChangePassword'; -//Login +// Login export { default as TabLogin } from 'pages/Auth/Login/components/TabLogin'; -//Forget +// Forget export { default as TabForgetPassword } from 'pages/Auth/Login/components/TabForgetPassword'; +// Reset +export { default as TabResetPassword } from 'pages/Auth/ResetPassword/components/TabResetPassword'; diff --git a/frontend-manager-student/src/index.js b/frontend-manager-student/src/index.js index ca4858e..9a084ef 100644 --- a/frontend-manager-student/src/index.js +++ b/frontend-manager-student/src/index.js @@ -22,7 +22,7 @@ import App from './App'; import reportWebVitals from './reportWebVitals'; //! COMPONENT -import RouterNprogress from 'components/Nprogress/RouterNprogress'; +import RouterNprogress from 'plugins/Nprogress/RouterNprogress'; ReactDOM.render( diff --git a/frontend-manager-student/src/pages/Auth/Login/components/TabForgetPassword.jsx b/frontend-manager-student/src/pages/Auth/Login/components/TabForgetPassword.jsx index 536a0d8..587c884 100644 --- a/frontend-manager-student/src/pages/Auth/Login/components/TabForgetPassword.jsx +++ b/frontend-manager-student/src/pages/Auth/Login/components/TabForgetPassword.jsx @@ -5,6 +5,7 @@ import { useDispatch, useSelector } from 'react-redux'; //! SHARE import HELPERS from 'utils/helper'; import NOTIFICATION from 'utils/notification'; +import TEXT_NOTIFICATION from 'configs/text_notification'; //!REDUX THUNK import { Forget_Password_Initial } from 'redux/student/authentication_slice/auth_thunk'; @@ -21,17 +22,22 @@ const TabForgetPassword = ({ setShowLogin, setForgetPage }) => { })); const handleForgetStudent = (e) => { + // PreventDefault Enter reload form e.preventDefault(); + // Take data form const values = HELPERS.formDataGeneral(e.target); - //Check input + // Check input if (!values.email) { - return NOTIFICATION.notifyError('Email Không được bỏ trống !!!'); + return NOTIFICATION.notifyError(TEXT_NOTIFICATION.NOTIFICATION_INPUT_INVALID._EMAIL); } // Action Login dispatch(Forget_Password_Initial(values)); + + // Clear form + HELPERS.delInputSuccess(e); }; return ( diff --git a/frontend-manager-student/src/pages/Auth/ResetPassword/components/TabResetPassword.jsx b/frontend-manager-student/src/pages/Auth/ResetPassword/components/TabResetPassword.jsx new file mode 100644 index 0000000..45fefdd --- /dev/null +++ b/frontend-manager-student/src/pages/Auth/ResetPassword/components/TabResetPassword.jsx @@ -0,0 +1,114 @@ +//! LIBRARY +import { useForm } from 'react-hook-form'; +import { useDispatch, useSelector } from 'react-redux'; +import { useParams } from 'react-router-dom'; + +//! COMPONENTS +import Section, { SectionBody, SectionTitle } from 'components/Section'; + +//! IMPORT +import { Loading } from 'imports/loading_import'; + +//! SHARE +import CONSTANTS from 'configs/constants'; + +//! REDUX +import { Reset_Password_Initial } from 'redux/student/authentication_slice/auth_thunk'; +import Navigate from 'custom_hook/useNavigate/Navigate'; + +const TabResetPassword = () => { + // Param id + const { id } = useParams(); + + //create dispatch action event + const dispatch = useDispatch(); + + const { + register, + handleSubmit, + formState: { errors }, + } = useForm(); + + // Take profile account in store + const { loading_reset_password } = useSelector((state) => ({ + ...state.auth_student, + })); + const { navigateChangePage } = Navigate(); + + const handleChangePasswordStudent = (data, e) => { + // Action Change Password + dispatch(Reset_Password_Initial({ id, ...data, e })).then((response) => { + if (response.payload.status === CONSTANTS.STATUS._OK) { + setTimeout(() => { + navigateChangePage('/'); + }, CONSTANTS._2_SECOND); + } + }); + }; + + return ( +
+
+ Reset mật khẩu + +
+
+ +
+
+ + + + +
+
+
+ {errors?.password?.type === 'required' ? 'Mời bạn nhập mật khẩu mới' : ''} +
+ + +
+
+ + + + +
+
+
+ {errors?.confirmPassword?.type === 'required' ? 'Mời bạn xác nhận mật khẩu mới' : ''} +
+ {loading_reset_password ? ( + + ) : ( + + )} +
+
+
+
+
+ ); +}; + +export default TabResetPassword; diff --git a/frontend-manager-student/src/pages/Auth/ResetPassword/index.jsx b/frontend-manager-student/src/pages/Auth/ResetPassword/index.jsx index 26b6b5d..5c33f83 100644 --- a/frontend-manager-student/src/pages/Auth/ResetPassword/index.jsx +++ b/frontend-manager-student/src/pages/Auth/ResetPassword/index.jsx @@ -1,106 +1,19 @@ //! LIBRARY import React from 'react'; -import { useForm } from 'react-hook-form'; -import { useDispatch, useSelector } from 'react-redux'; -//! COMPONENTS -import Section, { SectionBody, SectionTitle } from 'components/Section'; - -//! SHARE - -//! REDUX THUNK +//! IMPORT +import { TabResetPassword } from 'imports/auth_import'; -//!IMPORT -import { Loading } from 'imports/loading_import'; +//! COMPONENTS import Helmet from 'components/Helmet'; -import { useParams } from 'react-router-dom'; -import { Reset_Password_Initial } from 'redux/student/authentication_slice/auth_thunk'; const ResetPassword = () => { - const { id } = useParams(); - const dispatch = useDispatch(); - const { - register, - handleSubmit, - formState: { errors }, - } = useForm(); - - // Take profile account in store - const { loading_change_password } = useSelector((state) => ({ - ...state.auth_student, - })); - - const handleChangePasswordStudent = (data) => { - console.log(data); - - // Action Change Password - dispatch(Reset_Password_Initial({ id, ...data })); - }; - return ( - -
-
- Reset mật khẩu - -
-
- -
-
- - - - -
-
-
- {errors?.password?.type === 'required' ? 'Mời bạn nhập mật khẩu mới' : ''} -
- - -
-
- - - - -
-
-
- {errors?.confirmPassword?.type === 'required' ? 'Mời bạn xác nhận mật khẩu mới' : ''} -
- {loading_change_password ? ( - - ) : ( - - )} -
-
-
-
-
-
+ + + + + ); }; diff --git a/frontend-manager-student/src/pages/UserProfile/UserInfo.jsx b/frontend-manager-student/src/pages/UserProfile/UserInfo.jsx index 7a42752..2f01aee 100644 --- a/frontend-manager-student/src/pages/UserProfile/UserInfo.jsx +++ b/frontend-manager-student/src/pages/UserProfile/UserInfo.jsx @@ -5,7 +5,7 @@ import { DayPicker, MonthPicker, YearPicker } from 'react-dropdown-date'; import { useSelector } from 'react-redux'; //! CUSTOMER HOOK -import useUploadCloud from 'custom_hook/uploadMediaCloud'; +import useUploadCloud from 'custom_hook/useUpload/uploadMediaCloud'; //!IMPORT import { Loading } from 'imports/loading_import'; diff --git a/frontend-manager-student/src/components/Nprogress/RouterNprogress.jsx b/frontend-manager-student/src/plugins/Nprogress/RouterNprogress.jsx similarity index 100% rename from frontend-manager-student/src/components/Nprogress/RouterNprogress.jsx rename to frontend-manager-student/src/plugins/Nprogress/RouterNprogress.jsx diff --git a/frontend-manager-student/src/redux/media/upload_remove_media/media_thunk.js b/frontend-manager-student/src/redux/media/upload_remove_media/media_thunk.js index be7ee3f..f2f82f4 100644 --- a/frontend-manager-student/src/redux/media/upload_remove_media/media_thunk.js +++ b/frontend-manager-student/src/redux/media/upload_remove_media/media_thunk.js @@ -1,6 +1,5 @@ //! LIBRARY import { createAsyncThunk } from '@reduxjs/toolkit'; -import axios from 'axios'; //! NOTIFICATION import NOTIFICATION from 'utils/notification'; @@ -10,6 +9,7 @@ import API_MEDIA from 'api/api_media'; //! SHARE import HELPERS from 'utils/helper'; +import REQUEST from 'utils/request'; /** * @author Nguyễn Tiến Tài @@ -21,7 +21,7 @@ import HELPERS from 'utils/helper'; export const Upload_Media_Initial = createAsyncThunk('media/upload', async ({ formData }, { rejectWithValue }) => { try { //Call Api axios - const response = await axios.post(`${API_MEDIA.UPLOAD_MEDIA}`, formData, { + const response = await REQUEST.post(`${API_MEDIA.UPLOAD_MEDIA}`, formData, { headers: HELPERS.headerBrowserMedia(), }); diff --git a/frontend-manager-student/src/redux/student/authentication_slice/auth_slice.js b/frontend-manager-student/src/redux/student/authentication_slice/auth_slice.js index f5e6521..827fd62 100644 --- a/frontend-manager-student/src/redux/student/authentication_slice/auth_slice.js +++ b/frontend-manager-student/src/redux/student/authentication_slice/auth_slice.js @@ -8,13 +8,15 @@ import { Profile_Student_Initial, Renew_Token_Student_Initial, Change_Password_Initial, - Forget_Password_Initial + Forget_Password_Initial, + Reset_Password_Initial, } from './auth_thunk'; const initialState = { loading_login: false, loading_change_password: false, loading_forget_password: false, + loading_reset_password: false, loading: false, error: null, token_student: null, @@ -113,6 +115,17 @@ const Authentication = createSlice({ state.loading_forget_password = false; state.error = action.payload; }, + //* FORGET PASSWORD + [Reset_Password_Initial.pending]: (state, action) => { + state.loading_reset_password = true; + }, + [Reset_Password_Initial.fulfilled]: (state, action) => { + state.loading_reset_password = false; + }, + [Reset_Password_Initial.rejected]: (state, action) => { + state.loading_reset_password = false; + state.error = action.payload; + }, }, }); const AuthenticationSlice = Authentication.reducer; diff --git a/frontend-manager-student/src/redux/student/authentication_slice/auth_thunk.js b/frontend-manager-student/src/redux/student/authentication_slice/auth_thunk.js index eb600d4..a2026fd 100644 --- a/frontend-manager-student/src/redux/student/authentication_slice/auth_thunk.js +++ b/frontend-manager-student/src/redux/student/authentication_slice/auth_thunk.js @@ -1,6 +1,5 @@ //! LIBRARY import { createAsyncThunk } from '@reduxjs/toolkit'; -import axios from 'axios'; //! NOTIFICATION import NOTIFICATION from 'utils/notification'; @@ -13,6 +12,7 @@ import CONSTANTS from 'configs/constants'; import TEXT_NOTIFICATION from 'configs/text_notification'; import { setToken, clearToken } from 'utils/auth'; import HELPERS from 'utils/helper'; +import REQUEST from 'utils/request'; /** * @author Nguyễn Tiến Tài @@ -24,7 +24,8 @@ import HELPERS from 'utils/helper'; export const Login_Mssv_Initial = createAsyncThunk('student/mssv', async ({ mssv, password }, { rejectWithValue }) => { try { //Call Api axios - const response = await axios.post( + + const response = await REQUEST.post( `${API_STUDENT.LOGIN_STUDENT}`, { input: { @@ -85,7 +86,7 @@ export const Login_Mssv_Initial = createAsyncThunk('student/mssv', async ({ mssv export const Profile_Student_Initial = createAsyncThunk('student/profile', async (_, { rejectWithValue }) => { try { //Call Api axios - const response = await axios.get(`${API_STUDENT.PROFILE_STUDENT}`, { + const response = await REQUEST.get(`${API_STUDENT.PROFILE_STUDENT}`, { headers: HELPERS.headerBrowser(), withCredentials: true, }); @@ -132,7 +133,7 @@ export const Send_Mail_Student_Initial = createAsyncThunk( async ({ email }, { rejectWithValue }) => { try { //Call Api axios - const response = await axios.post( + const response = await REQUEST.post( `${API_STUDENT.EMAIL_FORGET_PASSWORD}`, { input: { @@ -178,7 +179,7 @@ export const Send_Mail_Student_Initial = createAsyncThunk( export const Logout_Student_Initial = createAsyncThunk('student/logout', async (_, { rejectWithValue }) => { try { //Call Api axios - const response = await axios.get(`${API_STUDENT.LOGOUT_STUDENT}`, { + const response = await REQUEST.get(`${API_STUDENT.LOGOUT_STUDENT}`, { headers: HELPERS.headerBrowser(), withCredentials: true, }); @@ -230,7 +231,7 @@ export const Logout_Student_Initial = createAsyncThunk('student/logout', async ( export const Renew_Token_Student_Initial = createAsyncThunk('student/new/token', async (_, { rejectWithValue }) => { try { //Call Api axios - const response = await axios.get(`${API_STUDENT.RE_NEW_TOKEN_STUDENT}`, { + const response = await REQUEST.get(`${API_STUDENT.RE_NEW_TOKEN_STUDENT}`, { headers: HELPERS.headerBrowser(), withCredentials: true, }); @@ -281,7 +282,7 @@ export const Change_Password_Initial = createAsyncThunk( async ({ oldPassword, password, confirmPassword }, { rejectWithValue }) => { try { //Call Api axios - const response = await axios.post( + const response = await REQUEST.post( `${API_STUDENT.CHANGE_PASSWORD_STUDENT}`, { input: { @@ -353,7 +354,7 @@ export const Forget_Password_Initial = createAsyncThunk( async ({ email }, { rejectWithValue }) => { try { //Call Api axios - const response = await axios.post( + const response = await REQUEST.post( `${API_STUDENT.FORGET_PASSWORD_STUDENT}`, { input: { @@ -413,10 +414,10 @@ export const Forget_Password_Initial = createAsyncThunk( */ export const Reset_Password_Initial = createAsyncThunk( 'student/resetPassword', - async ({ id, password, confirmPassword }, { rejectWithValue }) => { + async ({ id, password, confirmPassword, e }, { rejectWithValue }) => { try { //Call Api axios - const response = await axios.post( + const response = await REQUEST.post( `${API_STUDENT.RESET_FORGET_PASSWORD}/${id}`, { input: { @@ -438,11 +439,16 @@ export const Reset_Password_Initial = createAsyncThunk( if (successData) { // return result data const result_data = HELPERS.takeDataResponse(successData); + + // Info reset success NOTIFICATION.swalSuccess( - TEXT_NOTIFICATION.NOTIFICATION_RESET_PASSWORD_SUCCESS, - 'Hãy quay về trang chủ để đăng nhập', + TEXT_NOTIFICATION.NOTIFICATION_RESET.PASSWORD_SUCCESS_TITLE, + TEXT_NOTIFICATION.NOTIFICATION_RESET.PASSWORD_SUCCESS_TEXT, ); + //Del input + HELPERS.delInputSuccess(e); + // return result data return result_data; } diff --git a/frontend-manager-student/src/redux/student/book_slice/book_thunk.js b/frontend-manager-student/src/redux/student/book_slice/book_thunk.js index b3a4c0c..b6a9a06 100644 --- a/frontend-manager-student/src/redux/student/book_slice/book_thunk.js +++ b/frontend-manager-student/src/redux/student/book_slice/book_thunk.js @@ -1,6 +1,5 @@ //! LIBRARY import { createAsyncThunk } from '@reduxjs/toolkit'; -import axios from 'axios'; //! NOTIFICATION @@ -9,6 +8,7 @@ import API_USER from 'api/api_user'; //! SHARE import HELPERS from 'utils/helper'; +import REQUEST from 'utils/request'; /** * @author Châu Gia Bảo @@ -20,13 +20,14 @@ import HELPERS from 'utils/helper'; export const Get_All_Book_Student_Initial = createAsyncThunk('customer/book/all', async (_, { rejectWithValue }) => { try { //Call Api axios - const response = await axios.get(`${API_USER.GET_ALL_BOOK_STUDENT}`, { + const response = await REQUEST.get(`${API_USER.GET_ALL_BOOK_STUDENT}`, { headers: HELPERS.headerBrowser(), withCredentials: true, }); //Take response Success const successData = response.data; + console.log(response, '--'); //Check data if (successData) { @@ -56,7 +57,7 @@ export const Get_Detail_Book_Student_Initial = createAsyncThunk( async ({ id }, { rejectWithValue }) => { try { //Call Api axios - const response = await axios.get(`${API_USER.GET_DETAIL_BOOK_STUDENT}/${id}`, { + const response = await REQUEST.get(`${API_USER.GET_DETAIL_BOOK_STUDENT}/${id}`, { headers: HELPERS.headerBrowser(), withCredentials: true, }); @@ -93,7 +94,7 @@ export const Borrow_Book_Student_Initial = createAsyncThunk( async ({ book_id }, { rejectWithValue }) => { try { //Call Api axios - const response = await axios.post( + const response = await REQUEST.post( `${API_USER.BORROW_BOOK_STUDENT}`, { input: { diff --git a/frontend-manager-student/src/routers/index.js b/frontend-manager-student/src/routers/index.js index dbdec87..d2be368 100644 --- a/frontend-manager-student/src/routers/index.js +++ b/frontend-manager-student/src/routers/index.js @@ -1,4 +1,4 @@ -import Layout from 'components/Layout'; +//! PAGES import ChangePassword from 'pages/Auth/ChangePassword'; import ResetPassword from 'pages/Auth/ResetPassword'; import AllBook from 'pages/Book/AllBooks'; @@ -8,6 +8,9 @@ import BookBorrowInfo from 'pages/UserProfile/BookBorrowInfo'; import UserProfile from 'pages/UserProfile/ProfileLayout'; import UserInfo from 'pages/UserProfile/UserInfo'; +//! COMPONENT +import Layout from 'components/Layout'; + const RouteDataMain = [ { path: '/', diff --git a/frontend-manager-student/src/styles/components/_loading.scss b/frontend-manager-student/src/styles/components/_loading.scss new file mode 100644 index 0000000..9f4d50b --- /dev/null +++ b/frontend-manager-student/src/styles/components/_loading.scss @@ -0,0 +1,35 @@ +.loader { + position: relative; + width: 48px; + height: 48px; + background: #de3500; + transform: rotateX(65deg) rotate(45deg); + color: #fff; + animation: layers1 1s linear infinite alternate; + text-align: center; +} +.loader:after { + content: ''; + position: absolute; + inset: 0; + background: rgba(255, 255, 255, 0.7); + animation: layerTr 1s linear infinite alternate; +} + +@keyframes layers1 { + 0% { + box-shadow: 0px 0px 0 0px; + } + 90%, + 100% { + box-shadow: 20px 20px 0 -4px; + } +} +@keyframes layerTr { + 0% { + transform: translate(0, 0) scale(1); + } + 100% { + transform: translate(-25px, -25px) scale(1); + } +} diff --git a/frontend-manager-student/src/utils/helper.js b/frontend-manager-student/src/utils/helper.js index 4cf81db..29004b6 100644 --- a/frontend-manager-student/src/utils/helper.js +++ b/frontend-manager-student/src/utils/helper.js @@ -120,6 +120,17 @@ const HELPERS = { getURIFromTemplate(template, data) { return template.replace(REGEX.REGEX_IS_STRING_PARAM, (_, key) => data[key]); }, + + /** + * @author Nguyễn Tiến Tài + * @created_at 19/03/2023 + * @description Del input + * @param {e} + */ + delInputSuccess(e) { + // Del input + return e.target.reset(); + }, }; export default HELPERS; diff --git a/frontend-manager-student/src/utils/request.js b/frontend-manager-student/src/utils/request.js new file mode 100644 index 0000000..578aff6 --- /dev/null +++ b/frontend-manager-student/src/utils/request.js @@ -0,0 +1,25 @@ +//! LIBRARY +import axios from 'axios'; + +const REQUEST = { + /** + * @author Nguyễn Tiến Tài + * @created_at 19/03/2023 + * @descriptionKey setup axios + * @function get,post + * @return {Object} + */ + + //!POST + post: async (url, body, header) => { + const response = await axios.post(url, body, header); + return response; + }, + + //! GET + get: async (url, header) => { + const response = await axios.get(url, header); + return response; + }, +}; +export default REQUEST;