testimonial and product
This commit is contained in:
parent
f797f442be
commit
4a1baaf854
@ -15,7 +15,7 @@
|
|||||||
<meta name="description" content="CoreUI for React - Open Source Bootstrap Admin Template">
|
<meta name="description" content="CoreUI for React - Open Source Bootstrap Admin Template">
|
||||||
<meta name="author" content="Łukasz Holeczek">
|
<meta name="author" content="Łukasz Holeczek">
|
||||||
<meta name="keyword" content="Bootstrap,Admin,Template,Open,Source,CSS,SCSS,HTML,RWD,Dashboard,React">
|
<meta name="keyword" content="Bootstrap,Admin,Template,Open,Source,CSS,SCSS,HTML,RWD,Dashboard,React">
|
||||||
<title>Airport Admin</title>
|
<title>Jatin Mor Admin</title>
|
||||||
<!--
|
<!--
|
||||||
manifest.json provides metadata used when your web app is added to the
|
manifest.json provides metadata used when your web app is added to the
|
||||||
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
|
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
|
||||||
|
@ -61,9 +61,9 @@ const _nav = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: 'Complaints',
|
name: 'Testimonials',
|
||||||
icon: <CIcon icon={cilCompress} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilCompress} customClassName="nav-icon" />,
|
||||||
to: '/complaints',
|
to: '/testimonials',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
|
@ -64,7 +64,7 @@ const AppSidebar = () => {
|
|||||||
<CSidebarBrand className="d-none d-md-flex" style={{ background: 'rgb(140, 213, 213)' }} to="/">
|
<CSidebarBrand className="d-none d-md-flex" style={{ background: 'rgb(140, 213, 213)' }} to="/">
|
||||||
{/* <CIcon className="sidebar-brand-full" icon={logoNegative} height={35} /> */}
|
{/* <CIcon className="sidebar-brand-full" icon={logoNegative} height={35} /> */}
|
||||||
|
|
||||||
{HeaderlogoUrl ? <Link to='/dashboard'><img src={HeaderlogoUrl} alt='' /></Link> : { AppName } ? <h2>Airport Dashboard</h2> : ''}
|
{HeaderlogoUrl ? <Link to='/dashboard'><img src={HeaderlogoUrl} alt='' /></Link> : { AppName } ? <h2>Jatin Mor </h2> : ''}
|
||||||
{/* <CIcon className="sidebar-brand-narrow" height={35} /> */}
|
{/* <CIcon className="sidebar-brand-narrow" height={35} /> */}
|
||||||
<CIcon className="sidebar-brand-narrow" icon={sygnet} height={35} />
|
<CIcon className="sidebar-brand-narrow" icon={sygnet} height={35} />
|
||||||
</CSidebarBrand>
|
</CSidebarBrand>
|
||||||
|
@ -11,7 +11,7 @@ import axios from 'axios'
|
|||||||
import { store } from './redux/store';
|
import { store } from './redux/store';
|
||||||
|
|
||||||
const setupAxios = () => {
|
const setupAxios = () => {
|
||||||
axios.defaults.baseURL = 'https://atpapi.checkapp.one'
|
axios.defaults.baseURL = 'https://api-airport.checkapp.one/'
|
||||||
//axios.defaults.baseURL = 'http://localhost:5000'
|
//axios.defaults.baseURL = 'http://localhost:5000'
|
||||||
axios.defaults.headers = {
|
axios.defaults.headers = {
|
||||||
'Cache-Control': 'no-cache,no-store',
|
'Cache-Control': 'no-cache,no-store',
|
||||||
|
@ -51,13 +51,14 @@ import Departures from './views/Departures/Departures'
|
|||||||
import AddDeparture from './views/Departures/AddDeparture'
|
import AddDeparture from './views/Departures/AddDeparture'
|
||||||
import Informations from './views/Informations/Informations'
|
import Informations from './views/Informations/Informations'
|
||||||
import AddInformations from './views/Informations/AddInformations'
|
import AddInformations from './views/Informations/AddInformations'
|
||||||
import Complaints from './views/Complaints/Complaints'
|
|
||||||
import AddComplaint from './views/Complaints/AddComplaint'
|
|
||||||
import ViewComplaint from './views/Complaints/ViewComplaint'
|
|
||||||
import ApplicationName from './views/configuration/ApplicationName'
|
import ApplicationName from './views/configuration/ApplicationName'
|
||||||
import CopyrightMessage from './views/configuration/CopyrightMessage'
|
import CopyrightMessage from './views/configuration/CopyrightMessage'
|
||||||
import ContactRequests from './views/ContactRequests/ContactRequests'
|
import ContactRequests from './views/ContactRequests/ContactRequests'
|
||||||
import AddContactRequest from './views/ContactRequests/AddContactRequest'
|
import AddContactRequest from './views/ContactRequests/AddContactRequest'
|
||||||
|
import Testimonials from './views/Testimonials/Testimonials'
|
||||||
|
import AddTestimonial from './views/Testimonials/AddTestimonial'
|
||||||
|
import ViewTestimonial from './views/Testimonials/ViewTestimonial'
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
|
|
||||||
@ -82,9 +83,9 @@ const routes = [
|
|||||||
{ path: '/contact/request/new', name: 'AddContact Request', element: AddContactRequest },
|
{ path: '/contact/request/new', name: 'AddContact Request', element: AddContactRequest },
|
||||||
// { path: '/complaint/view/:id', name: 'view Complain', element: ViewComplaint },
|
// { path: '/complaint/view/:id', name: 'view Complain', element: ViewComplaint },
|
||||||
//Complaints
|
//Complaints
|
||||||
{ path: '/complaints', name: 'Complaints', element: Complaints },
|
{ path: '/testimonials', name: 'Testimonials', element: Testimonials },
|
||||||
{ path: '/complaint/new', name: 'Add Complaint', element: AddComplaint },
|
{ path: '/testimonial/new', name: 'AddTestimonial', element: AddTestimonial },
|
||||||
{ path: '/complaint/view/:id', name: 'view Complain', element: ViewComplaint },
|
{ path: '/testimonial/view/:id', name: 'ViewTestimonial', element: ViewTestimonial },
|
||||||
//informations
|
//informations
|
||||||
{ path: '/informations', name: 'Informations', element: Informations },
|
{ path: '/informations', name: 'Informations', element: Informations },
|
||||||
{ path: '/information/new', name: 'Add Informations', element: AddInformations },
|
{ path: '/information/new', name: 'Add Informations', element: AddInformations },
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
|
|
||||||
const ViewComplaint = () => {
|
|
||||||
return (
|
|
||||||
<div>ViewComplaint</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ViewComplaint
|
|
@ -13,19 +13,13 @@ const AddProduct = () => {
|
|||||||
const token = isAutheticated()
|
const token = isAutheticated()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const [data, setData] = useState({
|
const [data, setData] = useState({
|
||||||
image: '',
|
image: [],
|
||||||
imageURL: '',
|
imageURL: [],
|
||||||
name: '',
|
name: '',
|
||||||
description: '',
|
description: '',
|
||||||
|
|
||||||
base_Price: '',
|
price: '',
|
||||||
base_Price_With_Tax: '',
|
|
||||||
price_Level_2: '',
|
|
||||||
price_Level_2_With_Tax: '',
|
|
||||||
|
|
||||||
price_Level_3: '',
|
|
||||||
price_Level_3_With_Tax: '',
|
|
||||||
taxId: ''
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -33,7 +27,8 @@ const AddProduct = () => {
|
|||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [allTax, setAllTax] = useState([])
|
const [allTax, setAllTax] = useState([])
|
||||||
|
|
||||||
|
const [imagesPreview, setImagesPreview] = useState([]);
|
||||||
|
const [allimage, setAllImage] = useState([]);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -57,10 +52,38 @@ const AddProduct = () => {
|
|||||||
e.target.files[0]?.type === 'image/png' ||
|
e.target.files[0]?.type === 'image/png' ||
|
||||||
e.target.files[0]?.type === 'image/jpg'
|
e.target.files[0]?.type === 'image/jpg'
|
||||||
) {
|
) {
|
||||||
|
if (imagesPreview.length > 3) {
|
||||||
|
swal({
|
||||||
|
title: 'Warning',
|
||||||
|
text: 'maximum Four image Upload ',
|
||||||
|
icon: 'error',
|
||||||
|
button: 'Close',
|
||||||
|
dangerMode: true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// only for file preview------------------------------------
|
||||||
|
const files = Array.from(e.target.files);
|
||||||
|
files.forEach((file) => {
|
||||||
|
const reader = new FileReader();
|
||||||
|
|
||||||
|
reader.onload = () => {
|
||||||
|
if (reader.readyState === 2) {
|
||||||
|
setImagesPreview((old) => [...old, reader.result]);
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
reader.readAsDataURL(file)
|
||||||
|
});
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
setData((prev) => ({
|
setData((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
imageURL: URL.createObjectURL(e.target.files[0]),
|
|
||||||
image: e.target.files[0],
|
|
||||||
|
image: [...data.image, ...e.target.files],
|
||||||
}))
|
}))
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
@ -94,7 +117,7 @@ const AddProduct = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let trRate = taxDetails.rate / 100
|
let trRate = taxDetails.rate / 100
|
||||||
let PriceWithT = Number(data.base_Price);
|
let PriceWithT = Number(data.price);
|
||||||
PriceWithT += +((PriceWithT * trRate).toFixed());
|
PriceWithT += +((PriceWithT * trRate).toFixed());
|
||||||
|
|
||||||
//price_Level_2_With_Tax
|
//price_Level_2_With_Tax
|
||||||
@ -106,7 +129,7 @@ const AddProduct = () => {
|
|||||||
price_Level_3_With_Tax += +((price_Level_3_With_Tax * trRate).toFixed());
|
price_Level_3_With_Tax += +((price_Level_3_With_Tax * trRate).toFixed());
|
||||||
setData((prev) => ({
|
setData((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
base_Price_With_Tax: PriceWithT,
|
price_With_Tax: PriceWithT,
|
||||||
|
|
||||||
price_Level_2_With_Tax: price_Level_2_With_Tax,
|
price_Level_2_With_Tax: price_Level_2_With_Tax,
|
||||||
|
|
||||||
@ -117,19 +140,20 @@ const AddProduct = () => {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// console.log(data.image.length)
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
if (
|
if (
|
||||||
data.name.trim() === '' ||
|
data.name.trim() === '' ||
|
||||||
|
|
||||||
data.description.trim() === '' ||
|
data.description.trim() === '' ||
|
||||||
data.base_Price === '' ||
|
data.price === '' ||
|
||||||
data.base_Price_With_Tax === '' ||
|
data.image === ''
|
||||||
data.price_Level_2 === '' ||
|
// data.price_With_Tax === '' ||
|
||||||
data.price_Level_2_With_Tax === '' ||
|
// data.price_Level_2 === '' ||
|
||||||
data.price_Level_3 === '' ||
|
// data.price_Level_2_With_Tax === '' ||
|
||||||
data.price_Level_3_With_Tax === '' ||
|
// data.price_Level_3 === '' ||
|
||||||
data.imageURL.trim() === ''
|
// data.price_Level_3_With_Tax === '' ||
|
||||||
|
// data.imageURL.trim() === ''
|
||||||
) {
|
) {
|
||||||
swal({
|
swal({
|
||||||
title: 'Warning',
|
title: 'Warning',
|
||||||
@ -142,21 +166,19 @@ const AddProduct = () => {
|
|||||||
}
|
}
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.set('name', data.name)
|
formData.append('name', data.name)
|
||||||
|
|
||||||
formData.set('description', data.description)
|
formData.append('description', data.description)
|
||||||
formData.set('base_Price', data.base_Price)
|
formData.append('price', data.price)
|
||||||
formData.set('base_Price_With_Tax', data.base_Price_With_Tax)
|
|
||||||
|
|
||||||
formData.set('price_Level_2', data.price_Level_2)
|
|
||||||
formData.set('price_Level_2_With_Tax', data.price_Level_2_With_Tax)
|
|
||||||
|
|
||||||
formData.set('price_Level_3', data.price_Level_3)
|
|
||||||
formData.set('price_Level_3_With_Tax', data.price_Level_3_With_Tax)
|
|
||||||
formData.set('taxId', data.taxId)
|
|
||||||
|
|
||||||
|
|
||||||
formData.append('image', data.image)
|
|
||||||
|
|
||||||
|
data.image.forEach((Singleimage) => {
|
||||||
|
// console.log(Singleimage)
|
||||||
|
formData.append("image", Singleimage);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
axios
|
axios
|
||||||
@ -172,14 +194,14 @@ const AddProduct = () => {
|
|||||||
title: 'Added',
|
title: 'Added',
|
||||||
text: 'Product added successfully!',
|
text: 'Product added successfully!',
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
button: 'Return',
|
button: 'ok',
|
||||||
})
|
})
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
navigate('/products', { replace: true })
|
navigate('/products', { replace: true })
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
const message = err.response?.data?.message || 'Something went wrong!'
|
const message = err.response?.data?.message ? err.response?.data?.message : 'Something went wrong!'
|
||||||
swal({
|
swal({
|
||||||
title: 'Warning',
|
title: 'Warning',
|
||||||
text: message,
|
text: message,
|
||||||
@ -296,13 +318,14 @@ const AddProduct = () => {
|
|||||||
/>
|
/>
|
||||||
<p className="pt-1 pl-2 text-secondary">Upload jpg, jpeg and png only*</p>
|
<p className="pt-1 pl-2 text-secondary">Upload jpg, jpeg and png only*</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-3" style={{ height: '200px', maxWdth: '100%' }}>
|
<div><strong className="fs-6 fst-italic">*Please Upload maximum four images</strong></div>
|
||||||
<img
|
|
||||||
src={data.imageURL}
|
|
||||||
alt="Uploaded Image will be shown here"
|
|
||||||
style={{ maxHeight: '200px', maxWidth: '100%' }}
|
|
||||||
/>
|
|
||||||
|
|
||||||
|
|
||||||
|
<div id="createProductFormImage" className="w-25 d-flex">
|
||||||
|
|
||||||
|
{imagesPreview.map((image, index) => (
|
||||||
|
<img className=" w-50 p-1 " key={index} src={image} alt="Product Preview" />
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -312,126 +335,27 @@ const AddProduct = () => {
|
|||||||
<div className="col-lg-6 col-md-6 col-sm-12 my-1">
|
<div className="col-lg-6 col-md-6 col-sm-12 my-1">
|
||||||
<div className="card h-100">
|
<div className="card h-100">
|
||||||
<div className="card-body px-5">
|
<div className="card-body px-5">
|
||||||
<div className="d-flex flex-wrap">
|
|
||||||
|
|
||||||
<div className="mb-3 me-3">
|
<div className="mb-3 me-3">
|
||||||
<label htmlFor="title" className="form-label">
|
<label htmlFor="title" className="form-label">
|
||||||
Base Price*
|
Price (optional)
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
id="base_Price"
|
id="price"
|
||||||
value={data.base_Price}
|
value={data.price}
|
||||||
onChange={(e) => handleChange(e)}
|
onChange={(e) => handleChange(e)}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-3">
|
|
||||||
<label htmlFor="title" className="form-label">
|
|
||||||
Base Price With Tax
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
disabled
|
|
||||||
className="form-control"
|
|
||||||
id="base_Price_With_Tax"
|
|
||||||
value={data.base_Price_With_Tax}
|
|
||||||
placeholder={data.base_Price_With_Tax}
|
|
||||||
// onChange={(e) => handleChange(e)}
|
|
||||||
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
{/* <div className="mb-3">
|
|
||||||
<label htmlFor="title" className="form-label">
|
|
||||||
Base Price*
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
className="form-control"
|
|
||||||
id="base_Price"
|
|
||||||
value={data.base_Price}
|
|
||||||
onChange={(e) => handleChange(e)}
|
|
||||||
|
|
||||||
/>
|
|
||||||
</div> */}
|
|
||||||
|
|
||||||
<div className="d-flex flex-wrap">
|
|
||||||
|
|
||||||
<div className="mb-3 me-3">
|
|
||||||
<label htmlFor="title" className="form-label">
|
|
||||||
Price Level 2*
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
className="form-control"
|
|
||||||
id="price_Level_2"
|
|
||||||
value={data.price_Level_2}
|
|
||||||
onChange={(e) => handleChange(e)}
|
|
||||||
|
|
||||||
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="mb-3">
|
|
||||||
<label htmlFor="title" className="form-label">
|
|
||||||
Price Level 2 with Tax
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
disabled
|
|
||||||
className="form-control"
|
|
||||||
id="price_Level_2_With_Tax"
|
|
||||||
value={data.price_Level_2_With_Tax}
|
|
||||||
placeholder={data.price_Level_2_With_Tax}
|
|
||||||
// onChange={(e) => handleChange(e)}
|
|
||||||
|
|
||||||
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="d-flex flex-wrap">
|
|
||||||
|
|
||||||
<div className="mb-3 me-3">
|
|
||||||
<label htmlFor="title" className="form-label">
|
|
||||||
Price Level 3*
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
className="form-control"
|
|
||||||
id="price_Level_3"
|
|
||||||
value={data.price_Level_3}
|
|
||||||
onChange={(e) => handleChange(e)}
|
|
||||||
|
|
||||||
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="mb-3">
|
|
||||||
<label htmlFor="title" className="form-label">
|
|
||||||
Price Level 3 with Tax
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
disabled
|
|
||||||
className="form-control"
|
|
||||||
id="price_Level_3_With_Tax"
|
|
||||||
placeholder={data.price_Level_3_With_Tax}
|
|
||||||
// onChange={(e) => handleChange(e)}
|
|
||||||
|
|
||||||
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
{allTax.length > 0 && <div className=" mb-3">
|
{allTax.length > 0 && <div className=" mb-3">
|
||||||
|
@ -1,19 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import React, { useEffect, useState } from 'react'
|
import React, { useEffect, useState } from 'react'
|
||||||
import Button from '@material-ui/core/Button'
|
import Button from '@material-ui/core/Button'
|
||||||
import { Link, useNavigate, useParams } from 'react-router-dom'
|
import { Link, useNavigate, useParams } from 'react-router-dom'
|
||||||
@ -28,19 +13,13 @@ const EditProduct = () => {
|
|||||||
const token = isAutheticated()
|
const token = isAutheticated()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const [data, setData] = useState({
|
const [data, setData] = useState({
|
||||||
image: '',
|
image: [],
|
||||||
imageURL: '',
|
imageURL: [],
|
||||||
name: '',
|
name: '',
|
||||||
description: '',
|
description: '',
|
||||||
|
|
||||||
base_Price: '',
|
price: '',
|
||||||
base_Price_With_Tax: '',
|
|
||||||
price_Level_2: '',
|
|
||||||
price_Level_2_With_Tax: '',
|
|
||||||
|
|
||||||
price_Level_3: '',
|
|
||||||
price_Level_3_With_Tax: '',
|
|
||||||
taxId: ''
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -48,7 +27,7 @@ const EditProduct = () => {
|
|||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [allTax, setAllTax] = useState([])
|
const [allTax, setAllTax] = useState([])
|
||||||
|
|
||||||
|
const [imagesPreview, setImagesPreview] = useState([]);
|
||||||
//get Productdata
|
//get Productdata
|
||||||
const getProduct = async () => {
|
const getProduct = async () => {
|
||||||
|
|
||||||
@ -60,6 +39,14 @@ const EditProduct = () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
// console.log(res.data?.product?.image)
|
||||||
|
// if (res.data?.product?.image) {
|
||||||
|
// res.data?.product?.image.map(item => {
|
||||||
|
// })
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// setImagesPreview(res.data?.product?.image)
|
||||||
setData((prev) => ({
|
setData((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
...res.data?.product,
|
...res.data?.product,
|
||||||
@ -68,11 +55,13 @@ const EditProduct = () => {
|
|||||||
})
|
})
|
||||||
.catch((err) => { })
|
.catch((err) => { })
|
||||||
}
|
}
|
||||||
|
// console.log(imagesPreview)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getProduct()
|
getProduct()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getAllTax = async () => {
|
const getAllTax = async () => {
|
||||||
const res = await axios.get(`/api/tax/view_tax`, {
|
const res = await axios.get(`/api/tax/view_tax`, {
|
||||||
@ -94,10 +83,38 @@ const EditProduct = () => {
|
|||||||
e.target.files[0]?.type === 'image/png' ||
|
e.target.files[0]?.type === 'image/png' ||
|
||||||
e.target.files[0]?.type === 'image/jpg'
|
e.target.files[0]?.type === 'image/jpg'
|
||||||
) {
|
) {
|
||||||
|
if (imagesPreview.length > 3) {
|
||||||
|
swal({
|
||||||
|
title: 'Warning',
|
||||||
|
text: 'maximum Four image Upload ',
|
||||||
|
icon: 'error',
|
||||||
|
button: 'Close',
|
||||||
|
dangerMode: true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// only for file preview------------------------------------
|
||||||
|
const files = Array.from(e.target.files);
|
||||||
|
files.forEach((file) => {
|
||||||
|
const reader = new FileReader();
|
||||||
|
|
||||||
|
reader.onload = () => {
|
||||||
|
if (reader.readyState === 2) {
|
||||||
|
setImagesPreview((old) => [...old, reader.result]);
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
reader.readAsDataURL(file)
|
||||||
|
});
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
setData((prev) => ({
|
setData((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
imageURL: URL.createObjectURL(e.target.files[0]),
|
|
||||||
image: e.target.files[0],
|
|
||||||
|
image: [...data.image, ...e.target.files],
|
||||||
}))
|
}))
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
@ -129,8 +146,9 @@ const EditProduct = () => {
|
|||||||
taxId: e.target.value.slice(24)
|
taxId: e.target.value.slice(24)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let trRate = taxDetails.rate / 100
|
let trRate = taxDetails.rate / 100
|
||||||
let PriceWithT = Number(data.base_Price);
|
let PriceWithT = Number(data.price);
|
||||||
PriceWithT += +((PriceWithT * trRate).toFixed());
|
PriceWithT += +((PriceWithT * trRate).toFixed());
|
||||||
|
|
||||||
//price_Level_2_With_Tax
|
//price_Level_2_With_Tax
|
||||||
@ -142,7 +160,7 @@ const EditProduct = () => {
|
|||||||
price_Level_3_With_Tax += +((price_Level_3_With_Tax * trRate).toFixed());
|
price_Level_3_With_Tax += +((price_Level_3_With_Tax * trRate).toFixed());
|
||||||
setData((prev) => ({
|
setData((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
base_Price_With_Tax: PriceWithT,
|
price_With_Tax: PriceWithT,
|
||||||
|
|
||||||
price_Level_2_With_Tax: price_Level_2_With_Tax,
|
price_Level_2_With_Tax: price_Level_2_With_Tax,
|
||||||
|
|
||||||
@ -150,23 +168,23 @@ const EditProduct = () => {
|
|||||||
price_Level_3_With_Tax: price_Level_3_With_Tax,
|
price_Level_3_With_Tax: price_Level_3_With_Tax,
|
||||||
taxId: taxDetails.taxId
|
taxId: taxDetails.taxId
|
||||||
|
|
||||||
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// console.log(data.image.length)
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
if (
|
if (
|
||||||
data.name.trim() === '' ||
|
data.name.trim() === '' ||
|
||||||
|
|
||||||
data.description.trim() === '' ||
|
data.description.trim() === '' ||
|
||||||
data.base_Price === '' ||
|
data.price === '' ||
|
||||||
data.base_Price_With_Tax === '' ||
|
data.image === ''
|
||||||
data.price_Level_2 === '' ||
|
// data.price_With_Tax === '' ||
|
||||||
data.price_Level_2_With_Tax === '' ||
|
// data.price_Level_2 === '' ||
|
||||||
data.price_Level_3 === '' ||
|
// data.price_Level_2_With_Tax === '' ||
|
||||||
data.price_Level_3_With_Tax === '' ||
|
// data.price_Level_3 === '' ||
|
||||||
data.imageURL.trim() === ''
|
// data.price_Level_3_With_Tax === '' ||
|
||||||
|
// data.imageURL.trim() === ''
|
||||||
) {
|
) {
|
||||||
swal({
|
swal({
|
||||||
title: 'Warning',
|
title: 'Warning',
|
||||||
@ -179,22 +197,18 @@ const EditProduct = () => {
|
|||||||
}
|
}
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.set('name', data.name)
|
formData.append('name', data.name)
|
||||||
|
|
||||||
formData.set('description', data.description)
|
formData.append('description', data.description)
|
||||||
formData.set('base_Price', data.base_Price)
|
formData.append('price', data.price)
|
||||||
formData.set('base_Price_With_Tax', data.base_Price_With_Tax)
|
|
||||||
|
|
||||||
formData.set('price_Level_2', data.price_Level_2)
|
|
||||||
formData.set('price_Level_2_With_Tax', data.price_Level_2_With_Tax)
|
|
||||||
|
|
||||||
formData.set('price_Level_3', data.price_Level_3)
|
|
||||||
|
|
||||||
formData.set('price_Level_3_With_Tax', data.price_Level_3_With_Tax)
|
|
||||||
formData.set('taxId', data.taxId)
|
|
||||||
|
|
||||||
|
|
||||||
formData.append('image', data.image)
|
|
||||||
|
|
||||||
|
data.image.forEach((Singleimage) => {
|
||||||
|
formData.append("image", Singleimage);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
axios
|
axios
|
||||||
@ -207,18 +221,17 @@ const EditProduct = () => {
|
|||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
swal({
|
swal({
|
||||||
title: 'Edited',
|
title: 'Updated',
|
||||||
text: 'Product Edited successfully!',
|
text: 'Product Updated successfully!',
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
button: 'Return',
|
button: 'ok',
|
||||||
})
|
})
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
navigate('/products', { replace: true })
|
navigate('/products', { replace: true })
|
||||||
})
|
})
|
||||||
|
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
const message = err.response?.data?.message || 'Something went wrong!'
|
const message = err.response?.data?.message ? err.response?.data?.message : 'Something went wrong!'
|
||||||
swal({
|
swal({
|
||||||
title: 'Warning',
|
title: 'Warning',
|
||||||
text: message,
|
text: message,
|
||||||
@ -335,14 +348,15 @@ const EditProduct = () => {
|
|||||||
/>
|
/>
|
||||||
<p className="pt-1 pl-2 text-secondary">Upload jpg, jpeg and png only*</p>
|
<p className="pt-1 pl-2 text-secondary">Upload jpg, jpeg and png only*</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-3" style={{ height: '200px', maxWdth: '100%' }}>
|
<div><strong className="fs-6 fst-italic">*Please Upload maximum four images</strong></div>
|
||||||
<img
|
|
||||||
src={data.imageURL}
|
|
||||||
alt="Uploaded Image will be shown here"
|
|
||||||
style={{ maxHeight: '200px', maxWidth: '100%' }}
|
|
||||||
/>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
{imagesPreview.length > 0 && <div id="createProductFormImage" className="w-25 d-flex">
|
||||||
|
|
||||||
|
{imagesPreview.map((image, index) => (
|
||||||
|
<img className=" w-50 p-1 " key={index} src={image} alt="Product Preview" />
|
||||||
|
))}
|
||||||
|
</div>}
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -351,126 +365,27 @@ const EditProduct = () => {
|
|||||||
<div className="col-lg-6 col-md-6 col-sm-12 my-1">
|
<div className="col-lg-6 col-md-6 col-sm-12 my-1">
|
||||||
<div className="card h-100">
|
<div className="card h-100">
|
||||||
<div className="card-body px-5">
|
<div className="card-body px-5">
|
||||||
<div className="d-flex flex-wrap">
|
|
||||||
|
|
||||||
<div className="mb-3 me-3">
|
<div className="mb-3 me-3">
|
||||||
<label htmlFor="title" className="form-label">
|
<label htmlFor="title" className="form-label">
|
||||||
Base Price*
|
Price (optional)
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
id="base_Price"
|
id="price"
|
||||||
value={data.base_Price}
|
value={data.price}
|
||||||
onChange={(e) => handleChange(e)}
|
onChange={(e) => handleChange(e)}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-3">
|
|
||||||
<label htmlFor="title" className="form-label">
|
|
||||||
Base Price With Tax
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
disabled
|
|
||||||
className="form-control"
|
|
||||||
id="base_Price_With_Tax"
|
|
||||||
value={data.base_Price_With_Tax}
|
|
||||||
placeholder={data.base_Price_With_Tax}
|
|
||||||
// onChange={(e) => handleChange(e)}
|
|
||||||
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
{/* <div className="mb-3">
|
|
||||||
<label htmlFor="title" className="form-label">
|
|
||||||
Base Price*
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
className="form-control"
|
|
||||||
id="base_Price"
|
|
||||||
value={data.base_Price}
|
|
||||||
onChange={(e) => handleChange(e)}
|
|
||||||
|
|
||||||
/>
|
|
||||||
</div> */}
|
|
||||||
|
|
||||||
<div className="d-flex flex-wrap">
|
|
||||||
|
|
||||||
<div className="mb-3 me-3">
|
|
||||||
<label htmlFor="title" className="form-label">
|
|
||||||
Price Level 2*
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
className="form-control"
|
|
||||||
id="price_Level_2"
|
|
||||||
value={data.price_Level_2}
|
|
||||||
onChange={(e) => handleChange(e)}
|
|
||||||
|
|
||||||
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="mb-3">
|
|
||||||
<label htmlFor="title" className="form-label">
|
|
||||||
Price Level 2 with Tax
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
disabled
|
|
||||||
className="form-control"
|
|
||||||
id="price_Level_2_With_Tax"
|
|
||||||
value={data.price_Level_2_With_Tax}
|
|
||||||
placeholder={data.price_Level_2_With_Tax}
|
|
||||||
// onChange={(e) => handleChange(e)}
|
|
||||||
|
|
||||||
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="d-flex flex-wrap">
|
|
||||||
|
|
||||||
<div className="mb-3 me-3">
|
|
||||||
<label htmlFor="title" className="form-label">
|
|
||||||
Price Level 3*
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
className="form-control"
|
|
||||||
id="price_Level_3"
|
|
||||||
value={data.price_Level_3}
|
|
||||||
onChange={(e) => handleChange(e)}
|
|
||||||
|
|
||||||
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="mb-3">
|
|
||||||
<label htmlFor="title" className="form-label">
|
|
||||||
Price Level 3 with Tax
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
disabled
|
|
||||||
className="form-control"
|
|
||||||
id="price_Level_3_With_Tax"
|
|
||||||
placeholder={data.price_Level_3_With_Tax}
|
|
||||||
// onChange={(e) => handleChange(e)}
|
|
||||||
|
|
||||||
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
{allTax.length > 0 && <div className=" mb-3">
|
{allTax.length > 0 && <div className=" mb-3">
|
||||||
@ -479,7 +394,7 @@ const EditProduct = () => {
|
|||||||
</label> <select className=" form-control" name="" id=""
|
</label> <select className=" form-control" name="" id=""
|
||||||
onChange={(e) => TaxRatechange(e)}
|
onChange={(e) => TaxRatechange(e)}
|
||||||
>
|
>
|
||||||
<option value="" disabled>---</option>
|
<option value="" disabled>-----</option>
|
||||||
|
|
||||||
{allTax.map((t, i) =>
|
{allTax.map((t, i) =>
|
||||||
<option key={i} value={`tax:${t.tax},name:${t.name} ,taxId:${t._id}`}>{t.tax}% {t.name}</option>
|
<option key={i} value={`tax:${t.tax},name:${t.name} ,taxId:${t._id}`}>{t.tax}% {t.name}</option>
|
||||||
@ -496,3 +411,4 @@ const EditProduct = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default EditProduct
|
export default EditProduct
|
||||||
|
|
||||||
|
@ -67,6 +67,12 @@ const Products = () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
swal({
|
||||||
|
title: 'Deleted',
|
||||||
|
text: 'Product Deleted successfully!',
|
||||||
|
icon: 'success',
|
||||||
|
button: 'ok',
|
||||||
|
})
|
||||||
setSuccess((prev) => !prev)
|
setSuccess((prev) => !prev)
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@ -159,8 +165,8 @@ const Products = () => {
|
|||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<th className="text-start">Product Name</th>
|
<th className="text-start">Product Name</th>
|
||||||
<th className="text-start">Thumbnail</th>
|
<th className="text-start">Image</th>
|
||||||
<th className="text-start">Base Price</th>
|
<th className="text-start">Price</th>
|
||||||
<th className="text-start">Added On</th>
|
<th className="text-start">Added On</th>
|
||||||
<th className="text-start">Actions</th>
|
<th className="text-start">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -185,13 +191,14 @@ const Products = () => {
|
|||||||
<tr key={i}>
|
<tr key={i}>
|
||||||
<td className="text-start">{product.name}</td>
|
<td className="text-start">{product.name}</td>
|
||||||
<th>
|
<th>
|
||||||
{product?.image && (
|
{product.image &&
|
||||||
<>
|
product.image.map(i =>
|
||||||
<img src={product.image?.url} width="50" alt="preview" />
|
<img className="me-2" src={`${i?.url}`} width="40" alt="" />
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
||||||
</th>
|
</th>
|
||||||
<th className="text-start">₹{product.base_Price}</th>
|
<th className="text-start">₹{product.price}</th>
|
||||||
<td className="text-start">
|
<td className="text-start">
|
||||||
{new Date(product.createdAt).toLocaleString('en-IN', {
|
{new Date(product.createdAt).toLocaleString('en-IN', {
|
||||||
weekday: 'short',
|
weekday: 'short',
|
||||||
|
@ -82,17 +82,17 @@ function ViewProduct() {
|
|||||||
<table className="table table-centered table-nowrap mb-0">
|
<table className="table table-centered table-nowrap mb-0">
|
||||||
<thead className="thead-light">
|
<thead className="thead-light">
|
||||||
|
|
||||||
<tr><th>Id</th> <td>{product?._id}</td></tr>
|
<tr><th>Id</th> <td><h5>{product?._id}</h5></td></tr>
|
||||||
<tr><th>Name</th> <td>{product?.name}</td></tr>
|
<tr><th>Name</th> <td>{product?.name}</td></tr>
|
||||||
|
|
||||||
<tr><th>image</th><td>
|
{product.image && <tr><th>image</th><td>
|
||||||
<img src={`${product.image?.url}`} width="50" alt="" />
|
{product.image.map(i =>
|
||||||
</td></tr>
|
<img className="me-2" src={`${i?.url}`} width="70" alt="" />
|
||||||
|
)}
|
||||||
|
</td></tr>}
|
||||||
<tr><th>Description</th><td>{product?.description}</td></tr>
|
<tr><th>Description</th><td>{product?.description}</td></tr>
|
||||||
<tr><th>Base Price</th><td>{product?.base_Price}</td></tr>
|
<tr><th>Base Price</th><td>₹{product?.price}</td></tr>
|
||||||
<tr><th>Price Level 2</th><td>{product?.price_Level_2}</td></tr>
|
|
||||||
|
|
||||||
<tr><th>Price Level 3</th><td>{product?.price_Level_3}</td></tr>
|
|
||||||
|
|
||||||
{/* <tr><th>Product Time</th><td>{product?.time}</td></tr>
|
{/* <tr><th>Product Time</th><td>{product?.time}</td></tr>
|
||||||
<tr><th>Location</th><td>{product?.location}</td></tr> */}
|
<tr><th>Location</th><td>{product?.location}</td></tr> */}
|
||||||
|
@ -8,15 +8,16 @@ import axios from 'axios'
|
|||||||
import { isAutheticated } from 'src/auth'
|
import { isAutheticated } from 'src/auth'
|
||||||
// import { WebsiteURL } from '../WebsiteURL'
|
// import { WebsiteURL } from '../WebsiteURL'
|
||||||
|
|
||||||
const AddComplaint = () => {
|
const AddTestimonial = () => {
|
||||||
const token = isAutheticated()
|
const token = isAutheticated()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const [data, setData] = useState({
|
const [data, setData] = useState({
|
||||||
|
|
||||||
MobileOrEmail: '',
|
name: '',
|
||||||
Complaint: '',
|
testimonial: '',
|
||||||
|
company: '',
|
||||||
|
image: '',
|
||||||
|
imageURL: '',
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -31,18 +32,47 @@ const AddComplaint = () => {
|
|||||||
|
|
||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
|
|
||||||
|
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 }))
|
setData((prev) => ({ ...prev, [e.target.id]: e.target.value }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
if (
|
if (
|
||||||
data.MobileOrEmail.trim() === '' ||
|
data.name.trim() === '' ||
|
||||||
|
data.company.trim() === '' ||
|
||||||
|
data.image === '' ||
|
||||||
|
|
||||||
data.Complaint.trim() === ''
|
data.testimonial.trim() === ''
|
||||||
|
|
||||||
) {
|
) {
|
||||||
swal({
|
swal({
|
||||||
@ -56,14 +86,16 @@ const AddComplaint = () => {
|
|||||||
}
|
}
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.set('MobileOrEmail', data.MobileOrEmail)
|
formData.set('name', data.name)
|
||||||
|
formData.set('company', data.company)
|
||||||
|
formData.set('image', data.image)
|
||||||
|
|
||||||
formData.set('Complaint', data.Complaint)
|
formData.set('testimonial', data.testimonial)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
axios
|
axios
|
||||||
.post(`/api/complaint/new/`, formData, {
|
.post(`/api/testimonial/new/`, formData, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
'Content-Type': 'multipart/formdata',
|
'Content-Type': 'multipart/formdata',
|
||||||
@ -73,12 +105,12 @@ const AddComplaint = () => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
swal({
|
swal({
|
||||||
title: 'Added',
|
title: 'Added',
|
||||||
text: 'Complaint added successfully!',
|
text: 'Testimonial added successfully!',
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
button: 'ok',
|
button: 'ok',
|
||||||
})
|
})
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
navigate('/complaints', { replace: true })
|
navigate('/testimonials', { replace: true })
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
@ -106,7 +138,7 @@ const AddComplaint = () => {
|
|||||||
"
|
"
|
||||||
>
|
>
|
||||||
<div style={{ fontSize: '22px' }} className="fw-bold">
|
<div style={{ fontSize: '22px' }} className="fw-bold">
|
||||||
Complaint
|
Testimonial
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: 'flex', gap: '1rem' }}>
|
<div style={{ display: 'flex', gap: '1rem' }}>
|
||||||
<h4 className="mb-0"></h4>
|
<h4 className="mb-0"></h4>
|
||||||
@ -127,7 +159,7 @@ const AddComplaint = () => {
|
|||||||
>
|
>
|
||||||
{loading ? 'Loading' : 'Save'}
|
{loading ? 'Loading' : 'Save'}
|
||||||
</Button>
|
</Button>
|
||||||
<Link to="/complaints">
|
<Link to="/testimonials">
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
@ -151,48 +183,87 @@ const AddComplaint = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className="mb-3">
|
<div className="mb-3">
|
||||||
<label htmlFor="title" className="form-label">
|
<label htmlFor="title" className="form-label">
|
||||||
Mobile Or Email *
|
Name *
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
id="MobileOrEmail"
|
id="name"
|
||||||
value={data.MobileOrEmail}
|
value={data.name}
|
||||||
maxLength={150}
|
maxLength={25}
|
||||||
onChange={(e) => handleChange(e)}
|
onChange={(e) => handleChange(e)}
|
||||||
/>
|
/>
|
||||||
{data.MobileOrEmail ? <><small className="charLeft mt-4 fst-italic">
|
{data.name ? <><small className="charLeft mt-4 fst-italic">
|
||||||
{150 - data.MobileOrEmail.length} characters left
|
{25 - data.name.length} characters left
|
||||||
</small></> : <></>
|
</small></> : <></>
|
||||||
|
|
||||||
} </div>
|
} </div>
|
||||||
|
|
||||||
|
|
||||||
<div className="mb-3">
|
<div className="mb-3">
|
||||||
<label htmlFor="title" className="form-label">
|
<label htmlFor="title" className="form-label">
|
||||||
Complaint *
|
Company (Optional) *
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
id="company"
|
||||||
|
value={data.company}
|
||||||
|
maxLength={30}
|
||||||
|
onChange={(e) => handleChange(e)}
|
||||||
|
/>
|
||||||
|
{data.company ? <><small className="charLeft mt-4 fst-italic">
|
||||||
|
{30 - data.company.length} characters left
|
||||||
|
</small></> : <></>
|
||||||
|
|
||||||
|
} </div>
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="title" className="form-label">
|
||||||
|
Testimonial *
|
||||||
</label>
|
</label>
|
||||||
<textarea
|
<textarea
|
||||||
type="text"
|
type="text"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
id="Complaint"
|
id="testimonial"
|
||||||
rows="10"
|
rows="10"
|
||||||
cols="100"
|
cols="80"
|
||||||
value={data.Complaint}
|
value={data.testimonial}
|
||||||
placeholder='your Complaint...'
|
placeholder='your Testimonial...'
|
||||||
maxLength="1000"
|
maxLength="500"
|
||||||
onChange={(e) => handleChange(e)}
|
onChange={(e) => handleChange(e)}
|
||||||
>
|
>
|
||||||
</textarea>
|
</textarea>
|
||||||
|
|
||||||
{data.Complaint ? <><small className="charLeft mt-4 fst-italic">
|
{data.testimonial ? <><small className="charLeft mt-4 fst-italic">
|
||||||
{1000 - data.Complaint.length} characters left
|
{500 - data.testimonial.length} characters left
|
||||||
</small></> : <></>
|
</small></> : <></>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="image" className="form-label">
|
||||||
|
Photo (optional)*
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
className="form-control"
|
||||||
|
id="image"
|
||||||
|
accept="image/*"
|
||||||
|
multiple
|
||||||
|
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 className="mb-3">
|
{/* <div className="mb-3">
|
||||||
<label htmlFor="title" className="form-label">
|
<label htmlFor="title" className="form-label">
|
||||||
Description *
|
Description *
|
||||||
@ -211,4 +282,4 @@ const AddComplaint = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AddComplaint
|
export default AddTestimonial
|
@ -7,16 +7,16 @@ import { useNavigate } from 'react-router-dom'
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { isAutheticated } from 'src/auth'
|
import { isAutheticated } from 'src/auth'
|
||||||
|
|
||||||
const Complaints = () => {
|
const Testimonials = () => {
|
||||||
const token = isAutheticated()
|
const token = isAutheticated()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const [success, setSuccess] = useState(true)
|
const [success, setSuccess] = useState(true)
|
||||||
const [ComplaintsData, setComplaintsData] = useState([])
|
const [TestimonialsData, setTestimonialsData] = useState([])
|
||||||
|
|
||||||
const [currentPage, setCurrentPage] = useState(1)
|
const [currentPage, setCurrentPage] = useState(1)
|
||||||
const [itemPerPage, setItemPerPage] = useState(10)
|
const [itemPerPage, setItemPerPage] = useState(10)
|
||||||
const [showData, setShowData] = useState(ComplaintsData)
|
const [showData, setShowData] = useState(TestimonialsData)
|
||||||
|
|
||||||
const handleShowEntries = (e) => {
|
const handleShowEntries = (e) => {
|
||||||
setCurrentPage(1)
|
setCurrentPage(1)
|
||||||
@ -25,15 +25,15 @@ const Complaints = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const getComplaintsData = async () => {
|
const getTestimonialsData = async () => {
|
||||||
axios
|
axios
|
||||||
.get(`/api/complaint/getAll/`, {
|
.get(`/api/testimonial/getAll/`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
setComplaintsData(res.data?.complaint)
|
setTestimonialsData(res.data?.testimonial)
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@ -42,17 +42,17 @@ const Complaints = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getComplaintsData()
|
getTestimonialsData()
|
||||||
}, [success])
|
}, [success])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = () => {
|
const loadData = () => {
|
||||||
const indexOfLastPost = currentPage * itemPerPage
|
const indexOfLastPost = currentPage * itemPerPage
|
||||||
const indexOfFirstPost = indexOfLastPost - itemPerPage
|
const indexOfFirstPost = indexOfLastPost - itemPerPage
|
||||||
setShowData(ComplaintsData.slice(indexOfFirstPost, indexOfLastPost))
|
setShowData(TestimonialsData.slice(indexOfFirstPost, indexOfLastPost))
|
||||||
}
|
}
|
||||||
loadData()
|
loadData()
|
||||||
}, [currentPage, itemPerPage, ComplaintsData])
|
}, [currentPage, itemPerPage, TestimonialsData])
|
||||||
|
|
||||||
const handleDelete = (id) => {
|
const handleDelete = (id) => {
|
||||||
swal({
|
swal({
|
||||||
@ -62,7 +62,7 @@ const Complaints = () => {
|
|||||||
}).then((value) => {
|
}).then((value) => {
|
||||||
if (value === true) {
|
if (value === true) {
|
||||||
axios
|
axios
|
||||||
.delete(`/api/product/delete/${id}`, {
|
.delete(`/api/item/delete/${id}`, {
|
||||||
headers: {
|
headers: {
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
@ -99,7 +99,7 @@ const Complaints = () => {
|
|||||||
"
|
"
|
||||||
>
|
>
|
||||||
<div style={{ fontSize: '22px' }} className="fw-bold">
|
<div style={{ fontSize: '22px' }} className="fw-bold">
|
||||||
Complaints
|
Testimonials
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="page-title-right">
|
<div className="page-title-right">
|
||||||
@ -112,10 +112,10 @@ const Complaints = () => {
|
|||||||
textTransform: 'capitalize',
|
textTransform: 'capitalize',
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigate('/complaint/new', { replace: true })
|
navigate('/testimonial/new', { replace: true })
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Add New Complaint
|
Add New Testimonial
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -163,8 +163,8 @@ const Complaints = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<th className="text-start">Mobile or EMail</th>
|
<th className="text-start">Name</th>
|
||||||
<th className="text-start">Complaints</th>
|
<th className="text-start">Testimonials</th>
|
||||||
<th className="text-start">Date & Time</th>
|
<th className="text-start">Date & Time</th>
|
||||||
|
|
||||||
|
|
||||||
@ -186,14 +186,14 @@ const Complaints = () => {
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
) : (
|
) : (
|
||||||
showData.map((product, i) => {
|
showData.map((item, i) => {
|
||||||
return (
|
return (
|
||||||
<tr key={i}>
|
<tr key={i}>
|
||||||
<td className="text-start">{product.MobileOrEmail}</td>
|
<td className="text-start">{item.name}</td>
|
||||||
|
|
||||||
<td className="text-start">{product.Complaint}</td>
|
<td className="text-start">{item.company}</td>
|
||||||
<td className="text-start">
|
<td className="text-start">
|
||||||
{new Date(product.createdAt).toLocaleString('en-IN', {
|
{new Date(item.createdAt).toLocaleString('en-IN', {
|
||||||
weekday: 'short',
|
weekday: 'short',
|
||||||
month: 'short',
|
month: 'short',
|
||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
@ -205,7 +205,7 @@ const Complaints = () => {
|
|||||||
</td>
|
</td>
|
||||||
<td className="text-start">
|
<td className="text-start">
|
||||||
|
|
||||||
<Link to={`/product/view/${product._id}`}>
|
<Link to={`/testimonial/view/${item._id}`}>
|
||||||
<button
|
<button
|
||||||
style={{ color: 'white', marginRight: '1rem' }}
|
style={{ color: 'white', marginRight: '1rem' }}
|
||||||
type="button"
|
type="button"
|
||||||
@ -239,8 +239,8 @@ const Complaints = () => {
|
|||||||
aria-live="polite"
|
aria-live="polite"
|
||||||
>
|
>
|
||||||
Showing {currentPage * itemPerPage - itemPerPage + 1} to{' '}
|
Showing {currentPage * itemPerPage - itemPerPage + 1} to{' '}
|
||||||
{Math.min(currentPage * itemPerPage, ComplaintsData.length)} of{' '}
|
{Math.min(currentPage * itemPerPage, TestimonialsData.length)} of{' '}
|
||||||
{ComplaintsData.length} entries
|
{TestimonialsData.length} entries
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ const Complaints = () => {
|
|||||||
|
|
||||||
{!(
|
{!(
|
||||||
(currentPage + 1) * itemPerPage - itemPerPage >
|
(currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
ComplaintsData.length - 1
|
TestimonialsData.length - 1
|
||||||
) && (
|
) && (
|
||||||
<li className="paginate_button page-item ">
|
<li className="paginate_button page-item ">
|
||||||
<span
|
<span
|
||||||
@ -302,7 +302,7 @@ const Complaints = () => {
|
|||||||
className={
|
className={
|
||||||
!(
|
!(
|
||||||
(currentPage + 1) * itemPerPage - itemPerPage >
|
(currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
ComplaintsData.length - 1
|
TestimonialsData.length - 1
|
||||||
)
|
)
|
||||||
? 'paginate_button page-item next'
|
? 'paginate_button page-item next'
|
||||||
: 'paginate_button page-item next disabled'
|
: 'paginate_button page-item next disabled'
|
||||||
@ -330,4 +330,4 @@ const Complaints = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Complaints
|
export default Testimonials
|
122
src/views/Testimonials/ViewTestimonial.js
Normal file
122
src/views/Testimonials/ViewTestimonial.js
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import axios from "axios";
|
||||||
|
import React, { useEffect, useState, useCallback, useMemo } from "react";
|
||||||
|
import swal from 'sweetalert';
|
||||||
|
|
||||||
|
import { Link, useParams } from "react-router-dom";
|
||||||
|
import { isAutheticated } from "src/auth";
|
||||||
|
|
||||||
|
function ViewTestimonial() {
|
||||||
|
const [testimonial, setTestimonial] = useState([])
|
||||||
|
const { id } = useParams();
|
||||||
|
const token = isAutheticated();
|
||||||
|
|
||||||
|
const getTestimonial = useCallback(async () => {
|
||||||
|
let res = await axios.get(
|
||||||
|
`/api/testimonial/getOne/${id}`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
setTestimonial(res.data.testimonial)
|
||||||
|
|
||||||
|
|
||||||
|
}, [token]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getTestimonial();
|
||||||
|
}, [getTestimonial]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//change time formate
|
||||||
|
function formatAMPM(date) {
|
||||||
|
var hours = new Date(date).getHours();
|
||||||
|
var minutes = new Date(date).getMinutes();
|
||||||
|
var ampm = hours >= 12 ? 'PM' : 'AM';
|
||||||
|
hours = hours % 12;
|
||||||
|
hours = hours ? hours : 12; // the hour '0' should be '12'
|
||||||
|
minutes = minutes < 10 ? '0' + minutes : minutes;
|
||||||
|
var strTime = hours + ':' + minutes + ' ' + ampm;
|
||||||
|
return strTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className=" main-content">
|
||||||
|
<div className=" my-3 page-content">
|
||||||
|
<div className="container-fluid">
|
||||||
|
{/* <!-- start page title --> */}
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-12">
|
||||||
|
<div className="page-title-box d-flex align-items-center justify-content-between">
|
||||||
|
<h4 className="mb-3">Testimonial</h4>
|
||||||
|
<Link to="/testimonials"><button type="button" className="btn btn-info float-end mb-3 ml-4">Back</button></Link>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* <!-- end page title --> */}
|
||||||
|
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-lg-12">
|
||||||
|
<div className="card">
|
||||||
|
<div className="card-body">
|
||||||
|
<div className="row ml-0 mr-0 mb-10">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div className="table-responsive table-shoot">
|
||||||
|
<table className="table table-centered table-nowrap mb-0">
|
||||||
|
<thead className="thead-light">
|
||||||
|
|
||||||
|
<tr><th>Id</th> <td><h5>{testimonial?._id}</h5></td></tr>
|
||||||
|
<tr><th>Name</th> <td>{testimonial?.name}</td></tr>
|
||||||
|
|
||||||
|
{testimonial.image && <tr><th>image</th><td>
|
||||||
|
|
||||||
|
<img className="me-2" src={`${testimonial.image?.url}`} width="70" alt="" />
|
||||||
|
|
||||||
|
</td></tr>}
|
||||||
|
{testimonial?.company && <tr><th> Company</th><td>{testimonial?.company}</td></tr>}
|
||||||
|
<tr><th>Testimonial</th><td>{testimonial?.testimonial}</td></tr>
|
||||||
|
|
||||||
|
|
||||||
|
{/* <tr><th>Testimonial Time</th><td>{testimonial?.time}</td></tr>
|
||||||
|
<tr><th>Location</th><td>{testimonial?.location}</td></tr> */}
|
||||||
|
<tr><th>Created On</th><td>
|
||||||
|
{new Date(`${testimonial?.createdAt}`).toDateString()}<span> , {`${formatAMPM(testimonial?.createdAt)}`}</span>
|
||||||
|
</td></tr>
|
||||||
|
<tr><th>Updated At</th>
|
||||||
|
<td>
|
||||||
|
{new Date(`${testimonial?.updatedAt}`).toDateString()}<span> , {`${formatAMPM(testimonial?.updatedAt)}`}</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{/* <!-- end table-responsive --> */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* <!-- container-fluid --> */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ViewTestimonial;
|
@ -146,7 +146,7 @@ const Login = () => {
|
|||||||
<CCardBody>
|
<CCardBody>
|
||||||
<CForm>
|
<CForm>
|
||||||
<h1>Login</h1>
|
<h1>Login</h1>
|
||||||
<p className="text-medium-emphasis">Sign In to Your ChatGpt Airport Admin Dashboard Account.</p>
|
<p className="text-medium-emphasis">Sign In to Your Jatin Mor Admin Dashboard Account.</p>
|
||||||
<CInputGroup className="mb-3">
|
<CInputGroup className="mb-3">
|
||||||
<CInputGroupText>
|
<CInputGroupText>
|
||||||
<CIcon icon={cilUser} />
|
<CIcon icon={cilUser} />
|
||||||
|
Loading…
Reference in New Issue
Block a user