business added and send email
This commit is contained in:
parent
a59cc491b5
commit
eda8686a99
@ -9,6 +9,7 @@ import * as serviceWorker from './serviceWorker'
|
||||
import { Provider } from 'react-redux'
|
||||
import axios from 'axios'
|
||||
import { store } from './redux/store';
|
||||
import { cibGmail } from '@coreui/icons';
|
||||
|
||||
const setupAxios = () => {
|
||||
axios.defaults.baseURL = 'https://bolo-api.checkapp.one/'
|
||||
|
@ -7,6 +7,7 @@ import { CCard, CCardBody, CCardGroup, CCol, CContainer, CRow } from '@coreui/re
|
||||
import SelectPurpose from './multiform/SelectPurpose.js'
|
||||
import SelectBusiness from './multiform/SelectBusiness.js'
|
||||
import SelectLanguage from './multiform/selectLanguage.js'
|
||||
import Contacts from './multiform/Contacts.js'
|
||||
import BAddress from './multiform/BAddress.js'
|
||||
import Button from '@material-ui/core/Button'
|
||||
|
||||
@ -18,12 +19,14 @@ const AddBusiness = () => {
|
||||
const token = isAutheticated()
|
||||
const [productId, setProductId] = useState('')
|
||||
const [viewState, setViewState] = useState(1)
|
||||
// const [WebsiteURL, setWebsiteURL] = useState('https://bolo.ai.in/')
|
||||
|
||||
|
||||
const navigate = useNavigate()
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
const [data, setData] = useState({
|
||||
WebsiteURL: 'https://bolo.ai.in/',
|
||||
business: '',
|
||||
purpose: '',
|
||||
|
||||
@ -33,7 +36,16 @@ const AddBusiness = () => {
|
||||
city: '',
|
||||
address_Line_1: '',
|
||||
address_Line_2: '',
|
||||
pincode: ''
|
||||
pincode: '',
|
||||
//contacts
|
||||
image: '',
|
||||
imageURL: '',
|
||||
business_name: '',
|
||||
email: '',
|
||||
|
||||
short_url: '',
|
||||
contact_Number: '',
|
||||
contact_Person_Name: '',
|
||||
})
|
||||
|
||||
|
||||
@ -55,7 +67,17 @@ const AddBusiness = () => {
|
||||
data.country === '' ||
|
||||
data.state === '' ||
|
||||
data.city === '' ||
|
||||
data.pincode.trim() === ''
|
||||
data.pincode.trim() === '' ||
|
||||
//Contacts
|
||||
// data.image === '' ||
|
||||
// data.imageURL.trim() === '' ||
|
||||
data.business_name.trim() === '' ||
|
||||
data.email.trim() === '' ||
|
||||
|
||||
data.short_url.trim() === '' ||
|
||||
data.contact_Number === '' ||
|
||||
data.contact_Person_Name.trim() === ''
|
||||
|
||||
) {
|
||||
swal({
|
||||
title: 'Warning',
|
||||
@ -81,6 +103,17 @@ const AddBusiness = () => {
|
||||
|
||||
|
||||
formData.set('pincode', data.pincode)
|
||||
//contacts
|
||||
formData.set('business_name', data.business_name)
|
||||
formData.set('email', data.email)
|
||||
|
||||
|
||||
formData.set('contact_Number', data.contact_Number)
|
||||
formData.set('contact_Person_Name', data.contact_Person_Name)
|
||||
|
||||
|
||||
formData.set('url', data.WebsiteURL + data.short_url + '/login')
|
||||
formData.set('short_url', data.short_url)
|
||||
|
||||
axios
|
||||
.post(`/api/businesses/add`, formData, {
|
||||
@ -151,7 +184,13 @@ const AddBusiness = () => {
|
||||
data.country === '' ||
|
||||
data.state === '' ||
|
||||
data.city === '' ||
|
||||
data.pincode.trim() === ''}
|
||||
data.pincode.trim() === '' ||
|
||||
data.business_name.trim() === '' ||
|
||||
data.email.trim() === '' ||
|
||||
|
||||
data.short_url.trim() === '' ||
|
||||
data.contact_Number === '' ||
|
||||
data.contact_Person_Name.trim() === ''}
|
||||
>
|
||||
{loading ? 'Loading' : 'Add Now'}
|
||||
</Button>
|
||||
@ -186,7 +225,19 @@ const AddBusiness = () => {
|
||||
loading={{ loading, setLoading }}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
|
||||
{viewState === 3 && (
|
||||
<Contacts
|
||||
data={{ data, setData }}
|
||||
handleView={handleView}
|
||||
// productId={productId}
|
||||
// data={{ images, setImages }}
|
||||
loading={{ loading, setLoading }}
|
||||
/>
|
||||
)}
|
||||
{viewState === 4 && (
|
||||
<SelectLanguage
|
||||
data={{ data, setData }}
|
||||
handleView={handleView}
|
||||
@ -196,7 +247,7 @@ const AddBusiness = () => {
|
||||
loading={{ loading, setLoading }}
|
||||
/>
|
||||
)}
|
||||
{viewState === 4 && (
|
||||
{viewState === 5 && (
|
||||
<BAddress
|
||||
data={{ data, setData }}
|
||||
handleView={handleView}
|
||||
@ -236,12 +287,19 @@ const AddBusiness = () => {
|
||||
type="button"
|
||||
onClick={() => handleView(3)}
|
||||
>
|
||||
Select Languages
|
||||
Contacts
|
||||
</button>
|
||||
<button
|
||||
className={viewState === 4 ? 'btn btn-light' : 'btn btn-info text-white'}
|
||||
type="button"
|
||||
onClick={() => handleView(4)}
|
||||
>
|
||||
Select Languages
|
||||
</button>
|
||||
<button
|
||||
className={viewState === 5 ? 'btn btn-light' : 'btn btn-info text-white'}
|
||||
type="button"
|
||||
onClick={() => handleView(5)}
|
||||
>
|
||||
Address
|
||||
</button>
|
||||
|
309
src/views/Business/multiform/Contacts.js
Normal file
309
src/views/Business/multiform/Contacts.js
Normal file
@ -0,0 +1,309 @@
|
||||
|
||||
|
||||
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import Button from '@material-ui/core/Button'
|
||||
import { Link, useNavigate } from 'react-router-dom'
|
||||
import swal from 'sweetalert'
|
||||
import axios from 'axios'
|
||||
import { isAutheticated } from 'src/auth'
|
||||
// import { WebsiteURL } from '../WebsiteURL'
|
||||
|
||||
const Contacts = (props) => {
|
||||
const token = isAutheticated()
|
||||
|
||||
const navigate = useNavigate()
|
||||
|
||||
const { data, setData } = props.data
|
||||
|
||||
const { loading, setLoading } = props.loading
|
||||
// const [data, setData] = useState({
|
||||
// image: '',
|
||||
// imageURL: '',
|
||||
// name: '',
|
||||
// email: '',
|
||||
|
||||
// short_url: '',
|
||||
// contact_Number: '',
|
||||
// contact_Person_Name: '',
|
||||
|
||||
// })
|
||||
|
||||
|
||||
|
||||
const [validForm, setValidForm] = useState(false)
|
||||
|
||||
|
||||
|
||||
|
||||
const [errors, setErrors] = useState({
|
||||
emailError: '',
|
||||
phoneError: ''
|
||||
|
||||
|
||||
})
|
||||
const validEmailRegex = RegExp(
|
||||
/^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i,
|
||||
)
|
||||
const validPhoneRegex = RegExp(
|
||||
/^(\+\d{1,2}\s?)?1?\-?\.?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/,
|
||||
)
|
||||
|
||||
|
||||
const validateForm = () => {
|
||||
let valid = true
|
||||
Object.values(errors).forEach((val) => {
|
||||
if (val.length > 0) {
|
||||
valid = false
|
||||
return false
|
||||
}
|
||||
})
|
||||
Object.values(data.email).forEach((val) => {
|
||||
if (val.length <= 0) {
|
||||
valid = false
|
||||
return false
|
||||
}
|
||||
})
|
||||
return valid
|
||||
}
|
||||
|
||||
//cheking email and password
|
||||
useEffect(() => {
|
||||
if (validateForm()) {
|
||||
setValidForm(true)
|
||||
} else {
|
||||
setValidForm(false)
|
||||
}
|
||||
}, [errors])
|
||||
|
||||
|
||||
const handleChange = (e) => {
|
||||
if (e.target.id === 'business_name') {
|
||||
if (e.target.value.length < 0) return
|
||||
|
||||
setData((prev) => ({ ...prev, short_url: e.target.value.toLowerCase().replace(/\s+/g, '-') }))
|
||||
}
|
||||
|
||||
if (e.target.id === 'contact_Number') {
|
||||
setErrors({
|
||||
...errors,
|
||||
phoneError: validPhoneRegex.test(e.target.value) ? '' : 'Number is not valid!',
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
if (e.target.id === 'email') {
|
||||
setErrors({
|
||||
...errors,
|
||||
emailError: validEmailRegex.test(e.target.value) ? '' : 'Email is not valid!',
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (e.target.id === 'image') {
|
||||
if (
|
||||
e.target.files[0]?.type === 'image/jpeg' ||
|
||||
e.target.files[0]?.type === 'image/png' ||
|
||||
e.target.files[0]?.type === 'image/jpg'
|
||||
) {
|
||||
setData((prev) => ({
|
||||
...prev,
|
||||
imageURL: URL.createObjectURL(e.target.files[0]),
|
||||
image: e.target.files[0],
|
||||
}))
|
||||
return
|
||||
} else {
|
||||
swal({
|
||||
title: 'Warning',
|
||||
text: 'Upload jpg, jpeg, png only.',
|
||||
icon: 'error',
|
||||
button: 'Close',
|
||||
dangerMode: true,
|
||||
})
|
||||
setData((prev) => ({
|
||||
...prev,
|
||||
imageURL: '',
|
||||
image: '',
|
||||
}))
|
||||
e.target.value = null
|
||||
return
|
||||
}
|
||||
}
|
||||
setData((prev) => ({ ...prev, [e.target.id]: e.target.value }))
|
||||
}
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<div className="container">
|
||||
<div className="row">
|
||||
<div className="col-12">
|
||||
<div
|
||||
className="
|
||||
page-title-box
|
||||
d-flex
|
||||
align-items-center
|
||||
justify-content-between
|
||||
"
|
||||
>
|
||||
<div style={{ fontSize: '22px' }} className="fw-bold">
|
||||
Contacts
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '1rem' }}>
|
||||
<h4 className="mb-0"></h4>
|
||||
</div>
|
||||
|
||||
<div className="page-title-right">
|
||||
<Button
|
||||
variant="contained"
|
||||
color="primary"
|
||||
style={{
|
||||
fontWeight: 'bold',
|
||||
marginBottom: '1rem',
|
||||
textTransform: 'capitalize',
|
||||
marginRight: '5px',
|
||||
}}
|
||||
onClick={() => props.handleView(2)}
|
||||
// disabled={loading}
|
||||
>
|
||||
Prev
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="contained"
|
||||
color="secondary"
|
||||
style={{
|
||||
fontWeight: 'bold',
|
||||
marginBottom: '1rem',
|
||||
textTransform: 'capitalize',
|
||||
}}
|
||||
onClick={() => props.handleView(4)}
|
||||
|
||||
>
|
||||
Next
|
||||
</Button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="col-sm-12 col-md-12 col-lg-12 my-1">
|
||||
<div className="card h-100">
|
||||
<div className="card-body px-5">
|
||||
<div className="mb-3">
|
||||
<label htmlFor="title" className="form-label">
|
||||
Business Name*
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
className="form-control"
|
||||
id="business_name"
|
||||
value={data.business_name}
|
||||
maxLength={50}
|
||||
onChange={(e) => handleChange(e)}
|
||||
/>
|
||||
{data.business_name.length > 0 && <p className="pt-1 pl-2 text-secondary">Remaining characters : {50 - data.business_name.length}</p>}
|
||||
</div>
|
||||
|
||||
<div className="mb-3">
|
||||
<label htmlFor="title" className="form-label">
|
||||
Email *
|
||||
</label>
|
||||
<input
|
||||
type="email"
|
||||
className="form-control"
|
||||
id="email"
|
||||
value={data.email}
|
||||
maxLength="50"
|
||||
onChange={(e) => handleChange(e)}
|
||||
/>
|
||||
{errors.emailError && (
|
||||
<p className="text-center py-2 text-danger">{errors.emailError}</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="mb-3">
|
||||
<label htmlFor="title" className="form-label">
|
||||
Contact Number*
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
className="form-control"
|
||||
id="contact_Number"
|
||||
value={data.contact_Number}
|
||||
onChange={(e) => handleChange(e)}
|
||||
/>
|
||||
{errors.phoneError && (
|
||||
<p className="text-center py-2 text-danger">{errors.phoneError}</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="mb-3">
|
||||
<label htmlFor="title" className="form-label">
|
||||
Contact Person Name*
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
className="form-control"
|
||||
id="contact_Person_Name"
|
||||
value={data.contact_Person_Name}
|
||||
onChange={(e) => handleChange(e)}
|
||||
/>
|
||||
</div>
|
||||
<div className="mb-3">
|
||||
<label htmlFor="title" className="form-label">
|
||||
URL*
|
||||
</label>
|
||||
<div className="input-group mb-3">
|
||||
<span className="input-group-text" id="basic-addon3">
|
||||
{data.WebsiteURL}
|
||||
</span>
|
||||
<input
|
||||
type="text"
|
||||
className="form-control"
|
||||
id="short_url"
|
||||
aria-describedby="basic-addon3"
|
||||
disabled
|
||||
value={data.short_url}
|
||||
onChange={(e) => handleChange(e)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{/* <div className="mb-3">
|
||||
<label htmlFor="image" className="form-label">
|
||||
Franchisee Banner (optional)
|
||||
</label>
|
||||
<input
|
||||
type="file"
|
||||
className="form-control"
|
||||
id="image"
|
||||
accept="image/*"
|
||||
onChange={(e) => handleChange(e)}
|
||||
/>
|
||||
<p className="pt-1 pl-2 text-secondary">Upload jpg, jpeg and png only*</p>
|
||||
</div>
|
||||
<div className="mb-3" style={{ height: '200px', maxWdth: '100%' }}>
|
||||
<img
|
||||
src={data.imageURL}
|
||||
alt="Uploaded Image will be shown here"
|
||||
style={{ maxHeight: '200px', maxWidth: '100%' }}
|
||||
/>
|
||||
</div> */}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Contacts
|
@ -101,7 +101,7 @@ const selectLanguage = (props) => {
|
||||
marginRight: '5px',
|
||||
|
||||
}}
|
||||
onClick={() => props.handleView(2)}
|
||||
onClick={() => props.handleView(3)}
|
||||
|
||||
>
|
||||
Prev
|
||||
@ -117,7 +117,7 @@ const selectLanguage = (props) => {
|
||||
textTransform: 'capitalize',
|
||||
// marginRight: '5px',
|
||||
}}
|
||||
onClick={() => props.handleView(4)}
|
||||
onClick={() => props.handleView(5)}
|
||||
// disabled={loading}
|
||||
// disabled={data.language.length < 0 && data.language.length > 3}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user