Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2be1f2ebd1 | |||
| 8eefbbede8 | |||
| fa6b53ede0 | |||
| a5ac576176 | |||
| b840f28667 | |||
| 66d1ae1609 | |||
| 9cfb4651af | |||
| 2d141b529c |
+2
-1
@@ -23,7 +23,7 @@ import SubscriptionPage from './views/SubscriptionPage';
|
||||
import OnboardPage from "./views/OnboardPage";
|
||||
import AccPWDResetPage from './views/AccPWDResetPage';
|
||||
import ProfileCompletePage from './views/ProfileCompletePage';
|
||||
|
||||
import SubscribePage from './views/Subscribe'
|
||||
|
||||
function AppRouters() {
|
||||
return (
|
||||
@@ -55,6 +55,7 @@ function AppRouters() {
|
||||
<Route path={siteLinks.onboard} element={<OnboardPage />} />
|
||||
<Route path={siteLinks.calendar} element={<CalendarPage />} />
|
||||
<Route path={siteLinks.settings} element={<SettingsPage />} />
|
||||
<Route path={siteLinks.subscribe} element={<SubscribePage />} />
|
||||
<Route path={siteLinks.help} element={<HelpPage />} />
|
||||
</Route>
|
||||
</Route>
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import React, {memo, useState} from 'react'
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { pageSettings } from "../../../services/services";
|
||||
import SiteTemplateSelector from './SiteTemplateSelector';
|
||||
import NoYesBooleanDropdown from './NoYesBooleanDropdown';
|
||||
import { IoMdArrowDropdown } from 'react-icons/io';
|
||||
import queryKeys from '../../../services/queryKeys';
|
||||
|
||||
const GeneralTab = memo(({name='Full Name', data, isCustom, productData, backendValues, setFieldsChanged}) =>{
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const [reqStatus, setReqStatus] = useState({error: null, message: ''})
|
||||
|
||||
const fieldData = {}
|
||||
@@ -41,6 +44,9 @@ const GeneralTab = memo(({name='Full Name', data, isCustom, productData, backend
|
||||
setReqStatus({error: true, message: 'Unable to complete, try again later'})
|
||||
},
|
||||
onSettled: () => {
|
||||
queryClient.refetchQueries({ // refetches productProvision API call
|
||||
queryKey: [...queryKeys.settingsData],
|
||||
})
|
||||
setTimeout(()=>{
|
||||
setReqStatus({error: null, message: ''})
|
||||
},3000)
|
||||
|
||||
@@ -1,145 +1,210 @@
|
||||
import React, { useEffect } from "react";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import BreadcrumbComBS from "../breadcrumb/BreadcrumbComBS";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { Form, Formik } from "formik";
|
||||
// import { useLocation } from "react-router-dom";
|
||||
// import { Form, Formik } from "formik";
|
||||
import * as Yup from "yup";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import getImage from "../../utils/getImage";
|
||||
import { IoMdArrowDropdown } from "react-icons/io";
|
||||
import { completeProfile } from '../../services/services';
|
||||
import { completeProfile, getCommonPractice } from '../../services/services';
|
||||
import siteLinks from "../../links/siteLinks";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
|
||||
const validationSchema = Yup.object().shape({
|
||||
practice: Yup.string().required("Required"),
|
||||
specialization: Yup.string().required("Required"),
|
||||
information: Yup.string().min(1, "Minimum 10 characters").max(50, "Maximum 50 characters").required("Required"),
|
||||
})
|
||||
// const validationSchema = Yup.object().shape({
|
||||
// practice: Yup.string().required("Required"),
|
||||
// specialization: Yup.string().required("Required"),
|
||||
// introduction: Yup.string().min(1, "Minimum 10 characters").max(50, "Maximum 50 characters").required("Required"),
|
||||
// })
|
||||
|
||||
const initialValues = {
|
||||
practice: '',
|
||||
specialization: '',
|
||||
information: '',
|
||||
};
|
||||
// const initialValues = {
|
||||
// practice: '',
|
||||
// specialization: '',
|
||||
// introduction: '',
|
||||
// };
|
||||
|
||||
|
||||
export default function ProfileCompleteCom(){
|
||||
|
||||
const {state:{profile_completed}} = useLocation()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const [practices, setPractices] = useState([])
|
||||
|
||||
const [initialValues, setInitialValues] = useState({
|
||||
practice: '',
|
||||
specialization: '',
|
||||
introduction: '',
|
||||
})
|
||||
|
||||
const specialties = useMemo(()=>{ // FUNCTION TO UPDATE SPECIALITY ARRAY EACH TIME PRACTICE CHANGES
|
||||
setInitialValues(prev => ({...prev, specialization: ''}))
|
||||
if(!initialValues.practice){
|
||||
return []
|
||||
}
|
||||
const specialtiesArr = practices.filter(item => item.practice == initialValues.practice)[0]?.specialties
|
||||
return specialtiesArr
|
||||
},[initialValues.practice])
|
||||
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: (fields) => {
|
||||
const {practice, specialization} = fields
|
||||
if(!practice || !specialization){
|
||||
throw new Error('Please select both practice and specialization fields')
|
||||
}
|
||||
return completeProfile(fields)
|
||||
},
|
||||
onError: () => {
|
||||
setTimeout(()=>{mutation.reset()}, 4000)
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
console.log('res', res)
|
||||
if(res.data.resultCode != '0'){
|
||||
throw({message: res?.data?.resultDescription})
|
||||
}
|
||||
setTimeout(()=>{
|
||||
navigate(siteLinks.home)
|
||||
},2000)
|
||||
// console.log('res', res)
|
||||
}
|
||||
})
|
||||
|
||||
const handleCompleteProfile = (values, helpers) => {
|
||||
// helpers.resetForm()
|
||||
let reqData = {
|
||||
token: localStorage.getItem('token'), // USER TOKEN
|
||||
uid: localStorage.getItem('uid'), // USER UID
|
||||
// ...values
|
||||
const commonPractices = useMutation({ // FUNCTION TO GET COMMON PRACTICES
|
||||
mutationFn: (fields) => {
|
||||
return getCommonPractice(fields)
|
||||
},
|
||||
onError: ()=> {
|
||||
setPractices([])
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
if(!res?.data){
|
||||
return setPractices([])
|
||||
}
|
||||
let returnPractices = Object.entries(res?.data).filter(([key, value]) => typeof value == 'object')?.map(item => item[1])
|
||||
setPractices(returnPractices)
|
||||
}
|
||||
})
|
||||
|
||||
const handlePracticeChange = ({target:{name, value}}) => {
|
||||
setInitialValues(prev => ({...prev, [name]:value}))
|
||||
}
|
||||
console.log('values', values, helpers)
|
||||
// mutation.mutate(reqData)
|
||||
|
||||
const handleCompleteProfile = () => { // FUNCTION TO COMPLETE PROFILE
|
||||
let reqData = {
|
||||
token: localStorage.getItem('token'), // USER TOKEN
|
||||
uid: localStorage.getItem('uid'), // USER UID
|
||||
...initialValues
|
||||
}
|
||||
mutation.mutate(reqData)
|
||||
}
|
||||
|
||||
useEffect(()=>{
|
||||
let reqData = {
|
||||
token: localStorage.getItem('token'), // USER TOKEN
|
||||
uid: localStorage.getItem('uid') // USER UID
|
||||
}
|
||||
commonPractices.mutate(reqData)
|
||||
},[])
|
||||
|
||||
return <>
|
||||
|
||||
<BreadcrumbComBS title='Update Profile' paths={['Dashboard', 'Profile']} />
|
||||
|
||||
<div className="row pt-1">
|
||||
{commonPractices?.isFetching ?
|
||||
<>
|
||||
<div className="row">
|
||||
<div className="col-12">
|
||||
<p className='text-mute'>Loading...</p>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
: commonPractices?.isError ?
|
||||
<div className="row">
|
||||
<div className="col-12">
|
||||
<p className='text-danger'>{commonPractices?.error?.message}</p>
|
||||
</div>
|
||||
</div>
|
||||
:
|
||||
<div className="row pt-1">
|
||||
<div className="col-md-6 m-b-30">
|
||||
<div className="card card-statistics h-100 mb-0">
|
||||
{/* <div className="card-header d-flex align-items-center justify-content-between">
|
||||
<div className="card-heading">
|
||||
<h4 className="card-title">My Product URLs</h4>
|
||||
</div>
|
||||
</div> */}
|
||||
{/* <div style={{minHeight: '400px'}}></div> */}
|
||||
<div className="card-body">
|
||||
<div className='h-100 row flex-column'>
|
||||
{/* <div className="row"> */}
|
||||
<>
|
||||
<div className="">
|
||||
<div className="form-group position-relative">
|
||||
<label className={`text-black fw-bold control-label`}>Practice :</label>
|
||||
<div className="position-relative">
|
||||
{/* <select onChange={props.handleChange} name='practice' value={props.values.practice} className="form-control">
|
||||
<option value=''>Select</option>
|
||||
{practices.map((practice, index)=>(
|
||||
<option key={index} value={practice.practice}>{practice.practice}</option>
|
||||
))}
|
||||
</select> */}
|
||||
<select onChange={handlePracticeChange} name='practice' value={initialValues.practice} className="form-control">
|
||||
<option value=''>Select</option>
|
||||
{practices.map((practice, index)=>(
|
||||
<option key={index} value={practice.practice}>{practice.practice}</option>
|
||||
))}
|
||||
</select>
|
||||
<IoMdArrowDropdown className='position-absolute w-auto' style={{top: '50%', right: '2px', transform: 'translateY(-50%)'}} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/*<div className="col-xxl-6 m-b-30">*/}
|
||||
{/* <div className="card card-statistics h-100 mb-0" style={{minHeight: '100px'}}>*/}
|
||||
{/* /!* <div className="card-header d-flex align-items-center justify-content-between">*/}
|
||||
{/* <div className="card-heading">*/}
|
||||
{/* <h4 className="card-title">My Product URLs</h4>*/}
|
||||
{/* </div>*/}
|
||||
{/* </div> *!/*/}
|
||||
{/* </div>*/}
|
||||
{/*</div>*/}
|
||||
<div className="col-md-6 m-b-30">
|
||||
<div className="card card-statistics h-100 mb-0">
|
||||
{/* <div className="card-header d-flex align-items-center justify-content-between">
|
||||
<div className="card-heading">
|
||||
<h4 className="card-title">My Product URLs</h4>
|
||||
<div className="">
|
||||
<div className="form-group">
|
||||
<label className={`text-black fw-bold control-label`}>Specialization :</label>
|
||||
<div className="position-relative">
|
||||
<select onChange={handlePracticeChange} name='specialization' value={initialValues.specialization} className="form-control">
|
||||
<option value=''>Select</option>
|
||||
{specialties.map((specialty, index)=>(
|
||||
<option key={index} value={specialty}>{specialty}</option>
|
||||
))}
|
||||
</select>
|
||||
<IoMdArrowDropdown className='position-absolute w-auto' style={{top: '50%', right: '2px', transform: 'translateY(-50%)'}} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="">
|
||||
<div className="form-group position-relative">
|
||||
<label className={`text-black fw-bold control-label`}>General Information :</label>
|
||||
<textarea name='introduction' rows={10} style={{resize: 'none'}} className="form-control" value={initialValues.introduction} onChange={handlePracticeChange} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{(mutation.isError || mutation.isSuccess) &&
|
||||
<>
|
||||
<div className="">
|
||||
<p className={`${mutation.isSuccess ? 'text-success' : 'text-danger'}`}>{mutation.isSuccess ? 'Completed successfully, redirecting...' : mutation.error.message}</p>
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
|
||||
<div className="mt-auto text-end">
|
||||
<button type='button' onClick={handleCompleteProfile} className="btn btn-primary text-uppercase">{mutation.isPending ? 'loading...' : 'Continue'}</button>
|
||||
</div>
|
||||
</>
|
||||
{/* </div> */}
|
||||
</div>
|
||||
</div>
|
||||
</div> */}
|
||||
{/* <div style={{minHeight: '400px'}}></div> */}
|
||||
<div className="card-body">
|
||||
<Formik
|
||||
initialValues={initialValues}
|
||||
validationSchema={validationSchema}
|
||||
onSubmit={handleCompleteProfile}
|
||||
>
|
||||
{(props) => {
|
||||
return (
|
||||
<Form className='h-100 row flex-column'>
|
||||
{/* <div className="row"> */}
|
||||
<>
|
||||
<div className="">
|
||||
<div className="form-group position-relative">
|
||||
<label className={`text-black fw-bold control-label ${(props.errors.practice && props.touched.practice) && 'text-danger'}`}>Practice :</label>
|
||||
<div className="position-relative">
|
||||
<select onChange={props.handleChange} name='practice' value={props.values.practice} className="form-control">
|
||||
<option value=''>Select</option>
|
||||
<option value='engineering'>Engineering</option>
|
||||
</select>
|
||||
<IoMdArrowDropdown className='position-absolute w-auto' style={{top: '50%', right: '2px', transform: 'translateY(-50%)'}} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="">
|
||||
<div className="form-group">
|
||||
<label className={`text-black fw-bold control-label ${(props.errors.specialization && props.touched.specialization) && 'text-danger'}`}>Specialization :</label>
|
||||
<div className="position-relative">
|
||||
<select onChange={props.handleChange} name='specialization' value={props.values.specialization} className="form-control">
|
||||
<option value=''>Select</option>
|
||||
<option value='construction'>Construction</option>
|
||||
</select>
|
||||
<IoMdArrowDropdown className='position-absolute w-auto' style={{top: '50%', right: '2px', transform: 'translateY(-50%)'}} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="">
|
||||
<div className="form-group position-relative">
|
||||
<label className={`text-black fw-bold control-label ${(props.errors.information && props.touched.information) && 'text-danger'}`}>General Information :</label>
|
||||
<textarea name='information' rows={10} style={{resize: 'none'}} className="form-control" value={props.values.information} onChange={props.handleChange} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{/* {(mutation.isErrorrror || mutation.isSuccess) &&
|
||||
<>
|
||||
<div className="col-12">
|
||||
<p className={`${mutation.isSuccess ? 'text-success' : 'text-danger'}`}>{mutation.isSuccess ? 'Completed successfully' : mutation.error.message}</p>
|
||||
</div>
|
||||
</>
|
||||
} */}
|
||||
|
||||
<div className="mt-auto text-end">
|
||||
<button type='submit' className="btn btn-primary text-uppercase">{false ? 'loading...' : 'Continue'}</button>
|
||||
</div>
|
||||
</>
|
||||
{/* </div> */}
|
||||
</Form>
|
||||
);
|
||||
}}
|
||||
</Formik>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-md-6 m-b-30">
|
||||
<div className="text-center img-block left-column wow fadeInRight">
|
||||
<img className="img-fluid" src={getImage('img-07.png')} alt="content-image" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-md-6 m-b-30">
|
||||
<div class="text-center img-block left-column wow fadeInRight">
|
||||
<img className="img-fluid" src={getImage('img-07.png')} alt="content-image" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</>;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import React from 'react'
|
||||
import BreadcrumbComBS from "../breadcrumb/BreadcrumbComBS";
|
||||
import getImage from "../../utils/getImage";
|
||||
import { getSubscriptions } from '../../services/services';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import queryKeys from '../../services/queryKeys';
|
||||
import siteLinks from "../../links/siteLinks";
|
||||
import { Link, useNavigate } from 'react-router-dom'
|
||||
|
||||
export default function Subscribe() {
|
||||
const navigate = useNavigate()
|
||||
const pricingFields ={
|
||||
starter: { name: 'Starter', price: 5.99, active: true },
|
||||
basic: { name: 'Basic', price: 12.99, active: true },
|
||||
premium: { name: 'Premium', price: 20.00, active: true },
|
||||
}
|
||||
|
||||
const {data, isFetching, isError, error} = useQuery({
|
||||
queryKey: queryKeys.subscriptions,
|
||||
queryFn: () => {
|
||||
let reqData = {
|
||||
token: localStorage.getItem('token'), // USER TOKEN
|
||||
uid: localStorage.getItem('uid') // USER UID
|
||||
}
|
||||
return getSubscriptions(reqData)
|
||||
}
|
||||
})
|
||||
|
||||
const currentSubscription = data?.data?.current_product
|
||||
const otherSubscriptions = data?.data?.options
|
||||
console.log('urlData', data?.data)
|
||||
|
||||
return (
|
||||
<>
|
||||
<BreadcrumbComBS title='Subscription' paths={['Dashboard', 'Subscription']} />
|
||||
|
||||
{isFetching ?
|
||||
<>
|
||||
<div className="col-12">
|
||||
<p className='text-mute'>Loading...</p>
|
||||
</div>
|
||||
</>
|
||||
: isError ?
|
||||
<div className="col-12">
|
||||
<p className='text-danger'>{error.message}</p>
|
||||
</div>
|
||||
:
|
||||
<div className="row">
|
||||
<div className="col-12 col-lg-6 col-xl-3">
|
||||
<div className="card card-statistics text-center py-3">
|
||||
<div className="card-body pricing-content">
|
||||
<div className="pricing-content-card">
|
||||
<h5>Current Subscription(s)</h5>
|
||||
<h2 className="text-primary pt-3">{currentSubscription?.display_name}</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<>
|
||||
{Object.entries(otherSubscriptions)?.map(([key, value]) => (
|
||||
|
||||
<div key={key} className="col-12 col-lg-6 col-xl-3">
|
||||
<div className="card card-statistics text-center py-3">
|
||||
<div className="card-body pricing-content">
|
||||
<div className="pricing-content-card">
|
||||
<h5>{value.display_name}</h5>
|
||||
<h2 className="text-primary pt-3">${value.monthly}</h2>
|
||||
<p className="text-primary pb-3">/ Monthly</p>
|
||||
<ul className="py-2">
|
||||
{value?.items?.map(item =>(
|
||||
<li key={item}>{item}</li>
|
||||
))}
|
||||
</ul>
|
||||
<div className="pt-2">
|
||||
<button onClick={()=>{navigate(siteLinks.subscribe)}} className="btn btn-inverse-secondary btn-round btn-sm">Go {value.display_name}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
))}
|
||||
</>
|
||||
|
||||
</div>
|
||||
}
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -4,9 +4,11 @@ import getImage from "../../utils/getImage";
|
||||
import { getSubscriptions } from '../../services/services';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import queryKeys from '../../services/queryKeys';
|
||||
import siteLinks from "../../links/siteLinks";
|
||||
import { Link, useNavigate } from 'react-router-dom'
|
||||
|
||||
export default function Subscription() {
|
||||
|
||||
const navigate = useNavigate()
|
||||
const pricingFields ={
|
||||
starter: { name: 'Starter', price: 5.99, active: true },
|
||||
basic: { name: 'Basic', price: 12.99, active: true },
|
||||
@@ -71,7 +73,7 @@ export default function Subscription() {
|
||||
))}
|
||||
</ul>
|
||||
<div className="pt-2">
|
||||
<button className="btn btn-inverse-secondary btn-round btn-sm">Go {value.display_name}</button>
|
||||
<button onClick={()=>{navigate(siteLinks.subscribe)}} className="btn btn-inverse-secondary btn-round btn-sm">Go {value.display_name}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -85,4 +87,4 @@ export default function Subscription() {
|
||||
}
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ const siteLinks = {
|
||||
comments: '/comments',
|
||||
reports: '/reports',
|
||||
subscription: '/subscription',
|
||||
subscribe: '/subscribe',
|
||||
onboard: '/subscription',
|
||||
user: '/user',
|
||||
calendar: '/calendar',
|
||||
|
||||
@@ -171,7 +171,7 @@ export const completeProfile = (reqData) => {
|
||||
let postData = {
|
||||
...reqData,
|
||||
}
|
||||
return postAuxEnd(`/panel/`, postData, false)
|
||||
return postAuxEnd(`/panel/account/startprofile`, postData, false)
|
||||
}
|
||||
|
||||
// FUNCTION TO COMPLETE PROFILE
|
||||
@@ -182,6 +182,14 @@ export const getSubscriptions = (reqData) => {
|
||||
return postAuxEnd(`/panel/subscription/products`, postData, false)
|
||||
}
|
||||
|
||||
// FUNCTION TO GET COMMON PRACTICE
|
||||
export const getCommonPractice = (reqData) => {
|
||||
let postData = {
|
||||
...reqData,
|
||||
}
|
||||
return postAuxEnd(`/panel/common/practice`, postData, false)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import React from 'react'
|
||||
//import Signup2 from '../component/auth/Signup2'
|
||||
import Subscribe from '../component/subscribe/Subscribe'
|
||||
|
||||
export default function SubscribePage() {
|
||||
return (
|
||||
<Subscribe />
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user