adding complete registration endpoint started
This commit is contained in:
@@ -5,7 +5,7 @@ import * as Yup from "yup";
|
||||
import { Link, useNavigate, useParams } from 'react-router-dom'
|
||||
import siteLinks from '../../links/siteLinks'
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { verifyEmail } from '../../services/services';
|
||||
import { completeRegistration, verifyEmail } from '../../services/services';
|
||||
|
||||
import { IoMdArrowDropdown } from "react-icons/io";
|
||||
|
||||
@@ -31,34 +31,48 @@ export default function CSignup() {
|
||||
|
||||
const navigate = useNavigate()
|
||||
|
||||
const [user, setUser] = useState(null)
|
||||
|
||||
// API to verify email link
|
||||
const verifyLink = useMutation({
|
||||
mutationFn: (fields) => {
|
||||
return verifyEmail(fields)
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
console.log('res', res)
|
||||
setUser(res.data)
|
||||
},
|
||||
onError: (err) => {
|
||||
console.log('err', err)
|
||||
}
|
||||
// onError: (err) => {
|
||||
// console.log('err', err)
|
||||
// }
|
||||
})
|
||||
|
||||
const cSignup = useMutation({
|
||||
mutationFn: (fields) => {
|
||||
return null
|
||||
return completeRegistration(fields)
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
console.log('res', res)
|
||||
},
|
||||
onError: (err) => {
|
||||
console.log('err', err)
|
||||
const {token, room} = res?.data?.data
|
||||
if(token){
|
||||
localStorage.setItem('token', token)
|
||||
localStorage.setItem('room', room)
|
||||
// const data = {token}
|
||||
// dispatch(updateUserDetails({ ...data }));
|
||||
navigate('/dash') // later add redux to dispatch state
|
||||
}
|
||||
}
|
||||
// onError: (err) => {
|
||||
// console.log('err', err)
|
||||
// }
|
||||
})
|
||||
|
||||
const completeSignup = (values) => {
|
||||
// cSignup()
|
||||
console.log('values', values)
|
||||
let reqData = {
|
||||
country : values.country,
|
||||
username: values.username,
|
||||
password: values.password,
|
||||
verify_link: user.verify_link
|
||||
}
|
||||
cSignup.mutate(reqData)
|
||||
}
|
||||
|
||||
useEffect(()=>{
|
||||
@@ -106,21 +120,22 @@ export default function CSignup() {
|
||||
<>
|
||||
<div className="col-12">
|
||||
<div className="form-group">
|
||||
<label className={`text-black fw-bold control-label`}>Email:</label>
|
||||
<label className={`text-black fw-bold control-label`}>Email: {user?.user?.email}</label>
|
||||
{/* <input type="text" name='firstname' className="form-control" placeholder="First Name" value={props.values.firstname} onChange={props.handleChange} /> */}
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-12">
|
||||
<div class="form-group" data-select2-id="7">
|
||||
<div className="form-group" data-select2-id="7">
|
||||
<label className={`text-black fw-bold control-label ${(props.errors.country && props.touched.country) && 'text-danger'}`}>Country*</label>
|
||||
<div className='position-relative'>
|
||||
<select class="js-basic-single form-control select2-hidden-accessible" name="country" data-select2-id="1" tabindex="-1" aria-hidden="true" value={props.values.country} onChange={props.handleChange}>
|
||||
<select className="js-basic-single form-control select2-hidden-accessible" name="country" data-select2-id="1" tabIndex="-1" aria-hidden="true" value={props.values.country} onChange={props.handleChange}>
|
||||
<option value="" data-select2-id="3">Select</option>
|
||||
<option value="AK" data-select2-id="3">Alaska</option>
|
||||
{user?.country?.list && user?.country?.list?.map(item => (
|
||||
<option key={item.code} value={item.code} data-select2-id="3">{item?.description}</option>
|
||||
))}
|
||||
</select>
|
||||
<IoMdArrowDropdown className='position-absolute w-auto' style={{top: '50%', right: '2px', transform: 'translateY(-50%)'}} />
|
||||
</div>
|
||||
{/* <span class="select2 select2-container select2-container--default select2-container--below select2-container--focus" dir="ltr" data-select2-id="2" style="width: 1570px;"><span class="selection"><span class="select2-selection select2-selection--single" role="combobox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-labelledby="select2-state-g2-container"><span class="select2-selection__rendered" id="select2-state-g2-container" role="textbox" aria-readonly="true" title="Alaska">Alaska</span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span></span></span><span class="dropdown-wrapper" aria-hidden="true"></span></span> */}
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-12">
|
||||
|
||||
@@ -66,6 +66,14 @@ export const verifyEmail = (reqData) => {
|
||||
return postAuxEnd('/panel/auth/register/verify', postData, false)
|
||||
}
|
||||
|
||||
// FUNCTION TO COMPLETE REGISTRATION
|
||||
export const completeRegistration = (reqData) => {
|
||||
let postData = {
|
||||
...reqData
|
||||
}
|
||||
return postAuxEnd('/panel/auth/register/complete', postData, false)
|
||||
}
|
||||
|
||||
// FUNCTION TO SUBSCRIBE
|
||||
export const subscribe = (reqData) => {
|
||||
let postData = {
|
||||
|
||||
Reference in New Issue
Block a user