Skip to content

Commit

Permalink
Merge pull request #72 from fdhhhdjd/release-frontend-#4
Browse files Browse the repository at this point in the history
#4 auth register-forget-reset
  • Loading branch information
fdhhhdjd committed Oct 14, 2022
2 parents 5901110 + 2e21a8b commit 2dc339f
Show file tree
Hide file tree
Showing 14 changed files with 504 additions and 6 deletions.
Binary file modified dump.rdb
Binary file not shown.
13 changes: 12 additions & 1 deletion frontend/src/v1/configs/Apis/User_Api/Api_Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@ const API_USERS = {
LOGIN_GOOGLE: "/api/user/login/google",
LOGIN_FACEBOOK: "/api/user/login/facebook",

//* Register
REGISTER_USERS: "/api/user/register",

//* Forget
FORGET_PASSWORD_USERS: "/api/user/forget",

//* Forget
RESET_PASSWORD_USERS: "/api/user/password/reset",

//* New Accept Token
NEW_ACCESS_TOKEN: "api/user/new/accessToken",
NEW_ACCESS_TOKEN: "/api/user/new/accessToken",

//* Logout
LOGOUT_USERS: "/api/user/logout",

//* Profile
GET_PROFILE_USER: "/api/user/profile",
};
Expand Down
70 changes: 70 additions & 0 deletions frontend/src/v1/redux/authentication_slice/Api_Redux_Thunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createAsyncThunk } from "@reduxjs/toolkit";
import axios from "axios";
import API_USERS from "../../configs/Apis/User_Api/Api_Users";
import STORAGES from "../../utils/storage";

export const Login_Email_Phone_Initial = createAsyncThunk(
"Users/Login/Email/Phone",
async ({ email, password, token }, { rejectWithValue }) => {
Expand All @@ -23,6 +24,7 @@ export const Login_Email_Phone_Initial = createAsyncThunk(
}
}
);

export const Login_Phone_Otp_Initial = createAsyncThunk(
"Users/Login/Mobile/Phone",
async (phone_number, { rejectWithValue }) => {
Expand All @@ -43,6 +45,7 @@ export const Login_Phone_Otp_Initial = createAsyncThunk(
}
}
);

export const Login_Google_Initial = createAsyncThunk(
"Users/Login/Google",
async (response_google, { rejectWithValue }) => {
Expand All @@ -63,6 +66,7 @@ export const Login_Google_Initial = createAsyncThunk(
}
}
);

export const Login_Facebook_Initial = createAsyncThunk(
"Users/Login/Facebook",
async (response_facebook, { rejectWithValue }) => {
Expand All @@ -84,6 +88,7 @@ export const Login_Facebook_Initial = createAsyncThunk(
}
}
);

export const New_Accept_Token_Initial = createAsyncThunk(
"Users/New/Accept/Token",
async (token, { rejectWithValue }) => {
Expand All @@ -102,6 +107,7 @@ export const New_Accept_Token_Initial = createAsyncThunk(
}
}
);

export const Logout_Users_Initial = createAsyncThunk(
"Users/Logout",
async (token, { rejectWithValue }) => {
Expand All @@ -119,6 +125,7 @@ export const Logout_Users_Initial = createAsyncThunk(
}
}
);

export const Profile_Users_Initial = createAsyncThunk(
"Users/Profile",
async (accessToken, { rejectWithValue }) => {
Expand All @@ -136,3 +143,66 @@ export const Profile_Users_Initial = createAsyncThunk(
}
}
);

export const Register_Users_Initial = createAsyncThunk(
"Users/Register",
async (
{ name, email, password, confirmPassword, date_of_birth, phone_number },
{ rejectWithValue }
) => {
try {
const response = await axios.post(`${API_USERS.REGISTER_USERS}`, {
name,
email,
password,
confirmPassword,
date_of_birth,
phone_number,
});
return response.data;
} catch (error) {
if (!error.response) {
throw error;
}
return rejectWithValue(error.response.data);
}
}
);

export const Forget_Users_Initial = createAsyncThunk(
"Users/Forget",
async ({ email }, { rejectWithValue }) => {
try {
const response = await axios.post(`${API_USERS.FORGET_PASSWORD_USERS}`, {
email,
});
return response.data;
} catch (error) {
if (!error.response) {
throw error;
}
return rejectWithValue(error.response.data);
}
}
);

export const Reset_Users_Initial = createAsyncThunk(
"Users/Reset/Password",
async ({ token, password, confirmPassword }, { rejectWithValue }) => {
try {
const response = await axios.post(
`${API_USERS.RESET_PASSWORD_USERS}/${token}`,
{
password,
confirmPassword,
}
);
return response.data;
} catch (error) {
if (!error.response) {
throw error;
}
return rejectWithValue(error.response.data);
}
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import {
Logout_Users_Initial,
New_Accept_Token_Initial,
Profile_Users_Initial,
Register_Users_Initial,
Forget_Users_Initial,
Reset_Users_Initial,
} from "../authentication_slice/Api_Redux_Thunk";
const initialState = {
loading: false,
error: null,
error_access: null,
auth: [],
accessToken: null,
profile: null,
Expand Down Expand Up @@ -65,6 +69,18 @@ const Authentication = createSlice({
state.loading = false;
state.error = action.payload;
},
//*Register
[Register_Users_Initial.pending]: (state, action) => {
state.loading = true;
},
[Register_Users_Initial.fulfilled]: (state, action) => {
state.loading = false;
state.auth = action.payload;
},
[Register_Users_Initial.rejected]: (state, action) => {
state.loading = false;
state.error = action.payload;
},
//* Login Facebook
[Login_Facebook_Initial.pending]: (state, action) => {
state.loading = true;
Expand All @@ -77,6 +93,30 @@ const Authentication = createSlice({
state.loading = false;
state.error = action.payload;
},
//* Forget Password
[Forget_Users_Initial.pending]: (state, action) => {
state.loading = true;
},
[Forget_Users_Initial.fulfilled]: (state, action) => {
state.loading = false;
state.auth = action.payload;
},
[Forget_Users_Initial.rejected]: (state, action) => {
state.loading = false;
state.error = action.payload;
},
//* Reset Password
[Reset_Users_Initial.pending]: (state, action) => {
state.loading = true;
},
[Reset_Users_Initial.fulfilled]: (state, action) => {
state.loading = false;
state.auth = action.payload;
},
[Reset_Users_Initial.rejected]: (state, action) => {
state.loading = false;
state.error = action.payload;
},
//* Logout Users
[Logout_Users_Initial.pending]: (state, action) => {
state.loading = true;
Expand All @@ -99,7 +139,7 @@ const Authentication = createSlice({
},
[New_Accept_Token_Initial.rejected]: (state, action) => {
state.loading = false;
state.error = action.payload;
state.error_access = action.payload;
},
//* New Accept Token
[Profile_Users_Initial.pending]: (state, action) => {
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/v1/router/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {
Login_Users,
Login_Mobile_Otp,
Register_Users,
Forget_Password_Users,
Reset_Password_Users,
} from "../user_ui/imports/Authen_Users_Import";
import { Home_Users } from "../user_ui/imports/Page_Layout_Main_Import";
import User_Private_Router from "../private/user_private_router/User_Private_Router";
Expand All @@ -17,6 +20,21 @@ const RoutesDataUser = [
private: <User_Private_Router />,
main: <Login_Mobile_Otp />,
},
{
path: "register",
private: <User_Private_Router />,
main: <Register_Users />,
},
{
path: "forget",
private: <User_Private_Router />,
main: <Forget_Password_Users />,
},
{
path: "user/password/reset/:token",
private: <User_Private_Router />,
main: <Reset_Password_Users />,
},
//* Home
{
path: "",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/v1/user_ui/components/Metadata/Metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const Metadata = ({ title }) => {
<React.Fragment>
<HelmetProvider>
<Helmet>
<title>{title}</title>
<title>{`Welcome-${title}`}</title>
</Helmet>
</HelmetProvider>
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import swal from "sweetalert";
const SwaleMessage = (title, icon) => {
return swal(title, {
icon: icon,
});
};

export default SwaleMessage;
11 changes: 9 additions & 2 deletions frontend/src/v1/user_ui/contexts/GlobalStateUser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { createContext, useContext, useEffect } from "react";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import CONFIGS from "../../configs/config";
import CONTAINS from "../../configs/contants";
import STORAGES from "../../utils/storage";
Expand All @@ -12,7 +12,9 @@ export const useContextUser = () => useContext(StoreContextUser);
export const DataProviderUser = ({ children }) => {
const dispatch = useDispatch();
const user_login = STORAGES.getLocalStorage("Login_Users");

const { error_access } = useSelector((state) => ({
...state.auth_user,
}));
useEffect(() => {
if (user_login) {
const refreshToken = async () => {
Expand All @@ -25,6 +27,11 @@ export const DataProviderUser = ({ children }) => {
refreshToken();
}
}, []);
useEffect(() => {
if (error_access) {
STORAGES.clearLocalStorage("Login_Users");
}
}, [error_access]);
const data = {
User_Api_Context: UserApi(user_login),
};
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/v1/user_ui/imports/Authen_Users_Import.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ export { default as Login_Users } from "../pages/Authentication_Users/Login_User
//* Login Phone Check OTP Firebase
export { default as Login_Mobile_Otp } from "../pages/Authentication_Users/Login_Mobile_Otp";

//* Register
export { default as Register_Users } from "../pages/Authentication_Users/Register_Users";

//* Forget
export { default as Forget_Password_Users } from "../pages/Authentication_Users/Forget_Password_Users";

//* Reset
export { default as Reset_Password_Users } from "../pages/Authentication_Users/Reset_Password_Users";

//* Login Social Google Facebook
export { default as Login_Google } from "../components/Social/Login_Google";
export { default as Login_Facebook } from "../components/Social/Login_Facebook";
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/v1/user_ui/imports/General_Global_Import.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export { default as Loading_Pages_Users } from "../components/General_Loading/Lo
//* Metadata Global
export { default as Metadata } from "../components/Metadata/Metadata";

//* SwaleMessage
export { default as SwaleMessage } from "../components/SwaleMessage/SwaleMessage";

// * Toast Notification_Spam
export { default as ToastNotification_Spam } from "../components/Notifications/Notification_Spam";

Expand Down
Loading

2 comments on commit 2dc339f

@vercel
Copy link

@vercel vercel bot commented on 2dc339f Oct 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

serversendemailshopshoes – ./server_send_email

serversendemailshopshoes-git-main-fdhhhdjd.vercel.app
serversendemailshopshoes-fdhhhdjd.vercel.app
full-stack-shop-shoes-bootstrap.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 2dc339f Oct 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.