From a364269547b6f85c70c7595e5bfa3df60599f2cc Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Tue, 17 Dec 2024 13:56:00 +0100 Subject: [PATCH] signup api added --- src/component/auth/Signup2.jsx | 120 ++++++++++++++++++++------------- src/services/services.js | 8 +++ 2 files changed, 81 insertions(+), 47 deletions(-) diff --git a/src/component/auth/Signup2.jsx b/src/component/auth/Signup2.jsx index 72b747e..0f35034 100644 --- a/src/component/auth/Signup2.jsx +++ b/src/component/auth/Signup2.jsx @@ -6,6 +6,8 @@ import LoginImg from '../../assets/bg/login.svg' import { Link, useNavigate } from 'react-router-dom' import siteLinks from '../../links/siteLinks' +import { useMutation } from '@tanstack/react-query'; +import { signUpUser } from '../../services/services'; const validationSchema = Yup.object().shape({ email: Yup.string() @@ -35,9 +37,22 @@ export default function Signup2() { const navigate = useNavigate() - const signUp = (values, helpers) => { + const [successBox, setSuccessBox] = useState(false) + + const mutation = useMutation({ + mutationFn: (fields) => { + return signUpUser(fields) + }, + onSuccess: (res) => { + console.log('res', res) + setSuccessBox(true) + } + }) + + const signUp = (values) => { // helpers.resetForm() - console.log('values', values, helpers) + // console.log('values', values, helpers) + mutation.mutate(values) } return ( @@ -61,57 +76,68 @@ export default function Signup2() { return (
- <> -
-
- - + {!mutation.isSuccess ? + <> +
+
+ + +
-
-
-
- - +
+
+ + +
-
-
-
- - +
+
+ + +
-
- {/*
-
- - + {/*
+
+ + +
-
-
-
- - +
+
+ + +
+
*/} +
+
+ + +
-
*/} -
-
- - -
-
-
- -
- - -
-
-

Check your email to continue.

-

Home

-
-
+ {mutation.error && + <> +
+

{mutation.error.message}

+
+ + } + +
+ +
+ + : +
+
+

Check your email to continue.

+

Home

+
+
+ } +

Already have an account ? Sign In

diff --git a/src/services/services.js b/src/services/services.js index a18ef1e..e964dcf 100644 --- a/src/services/services.js +++ b/src/services/services.js @@ -50,6 +50,14 @@ export const loginUser = (reqData) => { return postAuxEnd('/panel/auth/login', postData, false) } +// FUNCTION TO LOGIN USER IN +export const signUpUser = (reqData) => { + let postData = { + ...reqData + } + return postAuxEnd('/panel/auth/register', postData, false) +} + // FUNCTION TO GET DASHBOARD DATA export const accountDashboard = () => {