diff --git a/frontend/src/pages/Signup/Signup.jsx b/frontend/src/pages/Signup/Signup.jsx index 20f252f..1b1f347 100644 --- a/frontend/src/pages/Signup/Signup.jsx +++ b/frontend/src/pages/Signup/Signup.jsx @@ -7,6 +7,7 @@ import '../../css/Signup.css'; import {useAPI} from "../../providers/APIProvider/APIProvider.jsx"; import Toast from "../../Components/toast/Toast.jsx"; import {Helper} from "../../utils/Helper.js"; +import {useConfig} from "../../providers/config-provider/ConfigProvider.jsx"; const validatePhone = (phone) => { const PHONE_LENGTH = 11; @@ -40,6 +41,10 @@ const SignUpForm = ({onLoginClick}) => { createUserData, } = useAPI() + const { + setAccessTokenFromLocalStorage + } = useConfig() + const handleSignUp = useCallback(() => { const data = {} data.name = fullname @@ -77,13 +82,30 @@ const SignUpForm = ({onLoginClick}) => { } // TODO: add API call for sign up // TODO: route to my-account page - console.log('submit'); }; useEffect(() => { if (createUserData == null) return - setToastData(Helper.getToastDataFromResponse()) + const toastDataTemp = {} + switch (createUserData.status) { + case 200: + case 201: + toastDataTemp.message = "Account Created Successfully! Please Check Your Email." + toastDataTemp.alertType = "success" + break; + case 400: + toastDataTemp.message = "User with This Email Already Exists!" + toastDataTemp.alertType = "error" + break; + default: + toastDataTemp.message = "Unexpected Error! Please Try Again Later." + toastDataTemp.alertType = "error" + break + } + + setAccessTokenFromLocalStorage() + setToastData(toastDataTemp) setOpenToast(true) }, [createUserData]) diff --git a/frontend/src/providers/APIProvider/URL.js b/frontend/src/providers/APIProvider/URL.js index a11e418..19c10bd 100644 --- a/frontend/src/providers/APIProvider/URL.js +++ b/frontend/src/providers/APIProvider/URL.js @@ -18,7 +18,7 @@ const URL = { }, token: { default: "token/", - refresh: "token/refresh/", //TODO + refresh: "token/refresh/", }, payment: { default: "payment/",