first commit

This commit is contained in:
pawan-dot 2023-03-09 16:10:39 +05:30
parent 0db219e2d3
commit 0fe41e3b3b
20 changed files with 1961 additions and 237 deletions

View File

@ -15,7 +15,7 @@
<meta name="description" content="CoreUI for React - Open Source Bootstrap Admin Template">
<meta name="author" content="Łukasz Holeczek">
<meta name="keyword" content="Bootstrap,Admin,Template,Open,Source,CSS,SCSS,HTML,RWD,Dashboard,React">
<title>Jatin Mor Admin</title>
<title>Bolo Admin</title>
<!--
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/

View File

@ -5,6 +5,7 @@ import {
cilAirplaneMode,
cilAppsSettings,
cilBell,
cilBrush,
cilCalculator,
cilCart,
cilChartPie,
@ -17,6 +18,7 @@ import {
cilFace,
cilFilterSquare,
cilInfo,
cilLanguage,
cilLoopCircular,
cilMedicalCross,
cilMoney,
@ -28,6 +30,7 @@ import {
cilSitemap,
cilSpeedometer,
cilStar,
cilSwapHorizontal,
cilTablet,
cilTags,
cilTennisBall,
@ -79,56 +82,56 @@ const _nav = [
// to: '/informations',
// },
// {
// component: CNavItem,
// name: 'Franchisee',
// icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
// to: '/franchisees',
// },
// {
// component: CNavGroup,
// name: 'Franchisee Orders',
// icon: <CIcon icon={cilCart} customClassName="nav-icon" />,
// items: [
// {
// component: CNavItem,
// name: 'New',
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
// to: '/orders/new',
// },
// {
// component: CNavItem,
// name: 'Paid',
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
// to: '/orders/returned',
// },
// {
// component: CNavItem,
// name: 'Processing',
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
// to: '/orders/processing',
// },
// {
// component: CNavItem,
// name: 'Dispatched',
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
// to: '/orders/dispatched',
// },
// {
// component: CNavItem,
// name: 'Delivered',
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
// to: '/orders/delivered',
// },
// {
// component: CNavItem,
// name: 'Cancelled',
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
// to: '/orders/cancelled',
// },
{
component: CNavItem,
name: 'Businesses',
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
to: '/businesses',
},
{
component: CNavGroup,
name: 'Franchisee Orders',
icon: <CIcon icon={cilCart} customClassName="nav-icon" />,
items: [
{
component: CNavItem,
name: 'New',
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
to: '/orders/new',
},
{
component: CNavItem,
name: 'Paid',
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
to: '/orders/returned',
},
{
component: CNavItem,
name: 'Processing',
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
to: '/orders/processing',
},
{
component: CNavItem,
name: 'Dispatched',
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
to: '/orders/dispatched',
},
{
component: CNavItem,
name: 'Delivered',
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
to: '/orders/delivered',
},
{
component: CNavItem,
name: 'Cancelled',
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
to: '/orders/cancelled',
},
// ],
// },
],
},
{
@ -142,12 +145,19 @@ const _nav = [
name: 'Configuration',
icon: <CIcon icon={cilAppsSettings} customClassName="nav-icon" />,
items: [
// {
// component: CNavItem,
// name: 'Cities',
// icon: <CIcon icon={cilLoopCircular} customClassName="nav-icon" />,
// to: '/cities',
// },
{
component: CNavItem,
name: 'Purpose',
icon: <CIcon icon={cilLoopCircular} customClassName="nav-icon" />,
to: '/purpose',
},
{
component: CNavItem,
name: 'Business Type',
icon: <CIcon icon={cilBrush} customClassName="nav-icon" />,
to: '/business',
},
// {
// component: CNavItem,
// name: 'States',
@ -178,18 +188,18 @@ const _nav = [
// icon: <CIcon icon={cilTags} customClassName="nav-icon" />,
// to: '/tax',
// },
// {
// component: CNavItem,
// name: 'Pages',
// icon: <CIcon icon={cilCommand} customClassName="nav-icon" />,
// to: '/page',
// },
// {
// component: CNavItem,
// name: 'Terms of Use',
// icon: <CIcon icon={cilCommand} customClassName="nav-icon" />,
// to: '/terms_of_use',
// },
{
component: CNavItem,
name: 'Languages',
icon: <CIcon icon={cilLanguage} customClassName="nav-icon" />,
to: '/languages',
},
{
component: CNavItem,
name: 'Policies',
icon: <CIcon icon={cilSwapHorizontal} customClassName="nav-icon" />,
to: '/policies',
},
{
component: CNavItem,
name: 'Social Media',

View File

@ -64,7 +64,7 @@ const AppSidebar = () => {
<CSidebarBrand className="d-none d-md-flex" style={{ background: 'rgb(140, 213, 213)' }} to="/">
{/* <CIcon className="sidebar-brand-full" icon={logoNegative} height={35} /> */}
{HeaderlogoUrl ? <Link to='/dashboard'><img src={HeaderlogoUrl} alt='' /></Link> : { AppName } ? <h2>Jatin Mor </h2> : ''}
{HeaderlogoUrl ? <Link to='/dashboard'><img src={HeaderlogoUrl} alt='' width='100%' /></Link> : { AppName } ? <h2>Bolo </h2> : ''}
{/* <CIcon className="sidebar-brand-narrow" height={35} /> */}
<CIcon className="sidebar-brand-narrow" icon={sygnet} height={35} />
</CSidebarBrand>

View File

@ -11,8 +11,8 @@ import axios from 'axios'
import { store } from './redux/store';
const setupAxios = () => {
axios.defaults.baseURL = 'https://jatinmor-api.checkapp.one/'
//axios.defaults.baseURL = 'http://localhost:5000'
// axios.defaults.baseURL = 'https://bolo-api.checkapp.one/'
axios.defaults.baseURL = 'http://localhost:5000'
axios.defaults.headers = {
'Cache-Control': 'no-cache,no-store',
'Pragma': 'no-cache',

View File

@ -10,9 +10,9 @@ import EditProfile from './views/Profile/EditProfile'
const Dashboard = React.lazy(() => import('./views/dashboard/Dashboard'))
///
//Cities
import Cities from './views/configuration/cities/Cities.js'
import AddCity from './views/configuration/cities/AddCity.js'
import EditCity from './views/configuration/cities/EditCity.js'
import Cities from './views/configuration/Purpose/Purpose.js'
import AddCity from './views/configuration/Purpose/AddPurpose.js'
import EditCity from './views/configuration/Purpose/EditPurpose.js'
//states
import EditState from './views/configuration/states/EditStates.js'
import AddState from './views/configuration/states/AddState.js'
@ -22,10 +22,11 @@ import Socialmedia from './views/configuration/Socialmedia.js'
import Address from './views/configuration/Address.js'
import Logo from './views/configuration/Logo.js'
import Login from './views/pages/login/Login'
//Franchisees
import Franchisees from './views/Temples/Franchisees'
import AddFranchisee from './views/Temples/AddFranchisee'
import EditFranchisee from './views/Temples/EditFranchisee'
//Businesses
import Businesses from './views/Business/Businesses.js'
import AddBusiness from './views/Business/AddBusiness.js'
import EditBusiness from './views/Business/EditBusiness.js'
import Products from './views/Products/Products'
//product
import AddProduct from './views/Products/AddProduct'
@ -59,7 +60,17 @@ import AddContactRequest from './views/ContactRequests/AddContactRequest'
import Testimonials from './views/Testimonials/Testimonials'
import AddTestimonial from './views/Testimonials/AddTestimonial'
import ViewTestimonial from './views/Testimonials/ViewTestimonial'
import Policies from './views/configuration/Policies/Policies'
import Purpose from './views/configuration/Purpose/Purpose'
import AddPurpose from './views/configuration/Purpose/AddPurpose'
import Languages from './views/configuration/Language/Languages'
import AddLanguage from './views/configuration/Language/AddLanguage'
import EditLanguage from './views/configuration/Language/EditLanguage'
//
import BusinessType from './views/configuration/Business/Business'
import AddBusinessType from './views/configuration/Language/AddLanguage'
import EditBusinessType from './views/configuration/Business/EditLanguage'
import EditPurpose from './views/configuration/Purpose/EditPurpose.js'
const routes = [
{ path: '/', exact: true, name: 'Home' },
@ -78,6 +89,11 @@ const routes = [
{ path: '/departure/add', name: 'Add Departure', element: AddDeparture },
{ path: '/product/edit/:id', name: 'Edit products', element: EditProduct },
{ path: '/product/view/:id', name: 'view products', element: ViewProduct },
//Franchisee
{ path: '/businesses', name: 'business', element: Businesses },
{ path: '/business/add', name: 'Add business', element: AddBusiness },
{ path: '/business/edit/:id', name: 'Edit business', element: EditBusiness },
// { path: '/franchisee/view/:id', name: 'view franchisee', element: ViewFra },
//Contact Requests
{ path: '/contact/request', name: 'Contact Requests', element: ContactRequests },
{ path: '/contact/request/new', name: 'AddContact Request', element: AddContactRequest },
@ -114,8 +130,29 @@ const routes = [
//------------settings------------------------//
{ path: '/policies', name: 'Policies', element: Policies },
{ path: '/socialmedia', name: 'Social Media', element: Socialmedia },
{ path: '/purpose', name: 'Purpose', element: Purpose },
{ path: '/purpose/add', name: 'Add Purpose', element: AddPurpose },
//languge
{ path: '/languages', name: 'languages', element: Languages },
{ path: '/language/add', name: 'Add languages', element: AddLanguage },
{ path: '/language/edit/:id', name: 'Edit languages', element: EditLanguage },
//business
{ path: '/business', name: 'business', element: BusinessType },
{ path: '/business/add', name: 'Add business', element: AddBusinessType },
{ path: '/business/edit/:id', name: 'Edit business', element: EditBusinessType },
//purpose
{ path: '/purpose', name: 'purpose', element: Languages },
{ path: '/purpose/add', name: 'Add purpose', element: AddLanguage },
{ path: '/purpose/edit/:id', name: 'Edit purpose', element: EditPurpose },
//languge
{ path: '/application/name', name: 'ApplicationName', element: ApplicationName },
{ path: '/copyright/message', name: 'Copyright Message', element: CopyrightMessage },

View File

@ -9,7 +9,7 @@ import axios from 'axios'
import { isAutheticated } from 'src/auth'
// import { WebsiteURL } from '../WebsiteURL'
const AddFranchisee = () => {
const AddBusiness = () => {
const [WebsiteURL, setWebsiteURL] = useState('https://reinventuniforms.in/')
const token = isAutheticated()
const navigate = useNavigate()
@ -509,4 +509,4 @@ const AddFranchisee = () => {
)
}
export default AddFranchisee
export default AddBusiness

View File

@ -8,15 +8,15 @@ import swal from 'sweetalert'
import OverLayButton from './OverLayButton.js'
import { isAutheticated } from 'src/auth.js'
const Franchisees = () => {
const Businesses = () => {
const token = isAutheticated()
const [loading, setLoading] = useState(true)
const [success, setSuccess] = useState(true)
const [FranchiseesData, setFranchiseesData] = useState([])
const [BusinessesData, setBusinessesData] = useState([])
const [currentPage, setCurrentPage] = useState(1)
const [itemPerPage, setItemPerPage] = useState(10)
const [showData, setShowData] = useState(FranchiseesData)
const [showData, setShowData] = useState(BusinessesData)
const handleShowEntries = (e) => {
setCurrentPage(1)
@ -30,7 +30,7 @@ const Franchisees = () => {
})
.then((res) => {
// console.log(res.data.data)
setFranchiseesData(res.data.data)
setBusinessesData(res.data.data)
setLoading(false)
})
.catch((err) => {
@ -47,10 +47,10 @@ const Franchisees = () => {
const loadData = () => {
const indexOfLastPost = currentPage * itemPerPage
const indexOfFirstPost = indexOfLastPost - itemPerPage
setShowData(FranchiseesData.slice(indexOfFirstPost, indexOfLastPost))
setShowData(BusinessesData.slice(indexOfFirstPost, indexOfLastPost))
}
loadData()
}, [currentPage, itemPerPage, FranchiseesData])
}, [currentPage, itemPerPage, BusinessesData])
const handleVarification = (id) => {
@ -134,11 +134,11 @@ const Franchisees = () => {
"
>
<div style={{ fontSize: '22px' }} className="fw-bold">
Franchisees
Businesses
</div>
<div className="page-title-right">
<Link to="/franchisee/add">
<Link to="/business/add">
<Button
variant="contained"
color="primary"
@ -148,7 +148,7 @@ const Franchisees = () => {
textTransform: 'capitalize',
}}
>
Add Franchisee
Add Business
</Button>
</Link>
</div>
@ -192,7 +192,7 @@ const Franchisees = () => {
>
<thead className="thead-info" style={{ background: 'rgb(140, 213, 213)' }}>
<tr>
<th className="text-start">Franchisee Name</th>
<th className="text-start">Business Name</th>
<th className="text-start">Logo</th>
<th className="text-start">City </th>
<th className="text-start">Created On</th>
@ -259,7 +259,7 @@ const Franchisees = () => {
<td className=" text-center">
<OverLayButton data={{ url: franchisee?.url }} />
<Link to={`/franchisee/products/${franchisee._id}`}>
<Link to={`/business/products/${franchisee._id}`}>
<button
style={{ color: 'white' }}
type="button"
@ -273,7 +273,7 @@ const Franchisees = () => {
</button>
</Link>
<Link to={`/franchisee/edit/${franchisee._id}`}>
<Link to={`/business/edit/${franchisee._id}`}>
<button
style={{ color: 'white' }}
type="button"
@ -319,8 +319,8 @@ const Franchisees = () => {
aria-live="polite"
>
Showing {currentPage * itemPerPage - itemPerPage + 1} to{' '}
{Math.min(currentPage * itemPerPage, FranchiseesData.length)} of{' '}
{FranchiseesData.length} entries
{Math.min(currentPage * itemPerPage, BusinessesData.length)} of{' '}
{BusinessesData.length} entries
</div>
</div>
@ -363,7 +363,7 @@ const Franchisees = () => {
{!(
(currentPage + 1) * itemPerPage - itemPerPage >
FranchiseesData.length - 1
BusinessesData.length - 1
) && (
<li className="paginate_button page-item ">
<span
@ -382,7 +382,7 @@ const Franchisees = () => {
className={
!(
(currentPage + 1) * itemPerPage - itemPerPage >
FranchiseesData.length - 1
BusinessesData.length - 1
)
? 'paginate_button page-item next'
: 'paginate_button page-item next disabled'
@ -410,4 +410,4 @@ const Franchisees = () => {
)
}
export default Franchisees
export default Businesses

View File

@ -7,7 +7,7 @@ import swal from 'sweetalert'
import axios from 'axios'
import { isAutheticated } from 'src/auth'
const EditFranchisee = () => {
const EditBusiness = () => {
const [WebsiteURL, setWebsiteURL] = useState('https://reinventuniforms.in/')
@ -531,4 +531,4 @@ const EditFranchisee = () => {
)
}
export default EditFranchisee
export default EditBusiness

View File

@ -0,0 +1,153 @@
import React, { useEffect, useState } from 'react'
import Button from '@material-ui/core/Button'
import { Link, useParams, useNavigate } from 'react-router-dom'
import swal from 'sweetalert'
import axios from 'axios'
import { isAutheticated } from 'src/auth'
const AddBusiness = () => {
const token = isAutheticated();
const navigate = useNavigate()
const [data, setData] = useState({
business: '',
})
const [loading, setLoading] = useState(false)
const handleChange = (e) => {
setData((prev) => ({ ...prev, [e.target.id]: e.target.value }))
}
const handleSubmit = () => {
if (data.business.trim() === '') {
swal({
title: 'Warning',
text: 'Fill all mandatory fields',
icon: 'error',
button: 'Close',
dangerMode: true,
})
return
}
setLoading(true)
axios
.post(`/api/business`, data, {
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
swal({
title: 'Added',
text: 'business added successfully!',
icon: 'success',
button: 'Return',
})
setLoading(false)
navigate('/business', { replace: true })
})
.catch((err) => {
setLoading(false)
swal({
title: 'Warning',
text: 'Something went wrong!',
icon: 'error',
button: 'Retry',
dangerMode: true
})
})
}
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">
Add Business
</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={() => handleSubmit()}
disabled={loading}
>
{loading ? 'Loading' : 'Save'}
</Button>
<Link to="/cities">
<Button
variant="contained"
color="secondary"
style={{
fontWeight: 'bold',
marginBottom: '1rem',
textTransform: 'capitalize',
}}
>
Back
</Button>
</Link>
</div>
</div>
</div>
</div>
<div className="row">
<div className="col-8 mx-auto">
<div className="card h-100">
<div className="card-body px-5">
<div className="mb-3">
<label htmlFor="business" className="form-label">
Business *
</label>
<input
type="text"
className="form-control"
id="business"
value={data.business}
maxLength="50"
onChange={(e) => handleChange(e)}
/>
{data.business && <p className="pt-1 pl-2 text-secondary">
Remaining characters : {50 - data.business.length}
</p>}
</div>
</div>
</div>
</div>
</div>
</div>
)
}
export default AddBusiness

View File

@ -0,0 +1,345 @@
import React, { useEffect } from 'react'
import Button from '@material-ui/core/Button'
import { useState } from 'react'
import { Link } from 'react-router-dom'
import axios from 'axios'
import swal from 'sweetalert'
import { isAutheticated } from 'src/auth'
const Business = () => {
const token = isAutheticated();
const [loading, setLoading] = useState(true)
const [success, setSuccess] = useState(true)
const [BusinessData, setBusinessData] = useState([])
const [currentPage, setCurrentPage] = useState(1)
const [itemPerPage, setItemPerPage] = useState(10)
const [showData, setShowData] = useState(BusinessData)
const handleShowEntries = (e) => {
setCurrentPage(1)
setItemPerPage(e.target.value)
}
const getCategories = () => {
axios
.get(`/api/business`, {
headers: { 'Access-Control-Allow-Origin': '*', Authorization: `Bearer ${token}` },
})
.then((res) => {
console.log(res.data)
setBusinessData(res.data.data)
setLoading(false)
})
.catch((err) => {
console.log(err)
setLoading(false)
})
}
useEffect(() => {
getCategories()
}, [success])
useEffect(() => {
const loadData = () => {
const indexOfLastPost = currentPage * itemPerPage
const indexOfFirstPost = indexOfLastPost - itemPerPage
setShowData(BusinessData.slice(indexOfFirstPost, indexOfLastPost))
}
loadData()
}, [currentPage, itemPerPage, BusinessData])
const handleDelete = (id) => {
swal({
title: 'Are you sure?',
icon: 'error',
buttons: { Yes: { text: 'Yes', value: true }, Cancel: { text: 'Cancel', value: 'cancel' } },
}).then((value) => {
if (value === true) {
axios
.delete(`/api/business/${id}`, {
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
setSuccess((prev) => !prev)
})
.catch((err) => {
swal({
title: 'Warning',
text: 'Something went wrong!',
icon: 'error',
button: 'Retry',
dangerMode: true,
})
})
}
})
}
return (
<div className="main-content">
<div className="page-content">
<div className="container-fluid">
<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">
Business
</div>
<div className="page-title-right">
<Link to="/business/add">
<Button
variant="contained"
color="primary"
style={{
fontWeight: 'bold',
marginBottom: '1rem',
textTransform: 'capitalize',
}}
>
Add Business
</Button>
</Link>
</div>
</div>
</div>
</div>
<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 className="col-sm-12 col-md-12">
<div className="dataTables_length">
<label className="w-100">
Show
<select
style={{ width: '10%' }}
name=""
onChange={(e) => handleShowEntries(e)}
className="
select-w
custom-select custom-select-sm
form-control form-control-sm
"
>
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
entries
</label>
</div>
</div>
</div>
<div className="table-responsive table-shoot mt-3">
<table
className="table table-centered table-nowrap"
style={{ border: '1px solid' }}
>
<thead className="thead" style={{ background: 'rgb(140, 213, 213)' }}>
<tr>
<th className="text-start">Business </th>
<th className="text-start">Created On</th>
<th className="text-start">Actions</th>
</tr>
</thead>
<tbody>
{!loading && showData.length === 0 && (
<tr className="text-center">
<td colSpan="6">
<h5>No Data Available</h5>
</td>
</tr>
)}
{loading ? (
<tr>
<td className="text-center" colSpan="6">
Loading...
</td>
</tr>
) : (
showData.map((business, i) => {
return (
<tr key={i}>
<td className="text-start">{business.business}</td>
{/* <td className="text-start">{business.state?.state_name}</td> */}
<td className="text-start">
{new Date(business.createdAt).toLocaleString('en-IN', {
weekday: 'short',
month: 'short',
day: 'numeric',
year: 'numeric',
hour: 'numeric',
minute: 'numeric',
hour12: true,
})}
</td>
<td className="text-start">
<Link to={`/business/edit/${business._id}`}>
<button
style={{ color: 'white', margin: '0 1rem' }}
type="button"
className="
btn btn-primary btn-sm
waves-effect waves-light
btn-table
me-1
"
>
Edit
</button>
</Link>
<Link
to={'#'}
style={{
margin: '1rem',
}}
>
<button
style={{ color: 'white' }}
type="button"
className="
btn btn-danger btn-sm
waves-effect waves-light
btn-table
me-1
"
onClick={() => {
handleDelete(business._id)
}}
>
Delete
</button>
</Link>
</td>
</tr>
)
})
)}
</tbody>
</table>
</div>
<div className="row mt-20">
<div className="col-sm-12 col-md-6 mb-20">
<div
className="dataTables_info"
id="datatable_info"
role="status"
aria-live="polite"
>
Showing {currentPage * itemPerPage - itemPerPage + 1} to{' '}
{Math.min(currentPage * itemPerPage, BusinessData.length)} of{' '}
{BusinessData.length} entries
</div>
</div>
<div className="col-sm-12 col-md-6">
<div className="d-flex">
<ul className="pagination ms-auto">
<li
className={
currentPage === 1
? 'paginate_button page-item previous disabled'
: 'paginate_button page-item previous'
}
>
<span
className="page-link"
style={{ cursor: 'pointer' }}
onClick={() => setCurrentPage((prev) => prev - 1)}
>
Previous
</span>
</li>
{!(currentPage - 1 < 1) && (
<li className="paginate_button page-item">
<span
className="page-link"
style={{ cursor: 'pointer' }}
onClick={(e) => setCurrentPage((prev) => prev - 1)}
>
{currentPage - 1}
</span>
</li>
)}
<li className="paginate_button page-item active">
<span className="page-link" style={{ cursor: 'pointer' }}>
{currentPage}
</span>
</li>
{!(
(currentPage + 1) * itemPerPage - itemPerPage >
BusinessData.length - 1
) && (
<li className="paginate_button page-item ">
<span
className="page-link"
style={{ cursor: 'pointer' }}
onClick={() => {
setCurrentPage((prev) => prev + 1)
}}
>
{currentPage + 1}
</span>
</li>
)}
<li
className={
!(
(currentPage + 1) * itemPerPage - itemPerPage >
BusinessData.length - 1
)
? 'paginate_button page-item next'
: 'paginate_button page-item next disabled'
}
>
<span
className="page-link"
style={{ cursor: 'pointer' }}
onClick={() => setCurrentPage((prev) => prev + 1)}
>
Next
</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
)
}
export default Business

View File

@ -0,0 +1,172 @@
import React, { useEffect, useState } from 'react'
import Button from '@material-ui/core/Button'
import { Link, useNavigate, useParams } from 'react-router-dom'
import swal from 'sweetalert'
import axios from 'axios'
import { isAutheticated } from 'src/auth'
const EditBusiness = () => {
const id = useParams()?.id
const token = isAutheticated();
const navigate = useNavigate()
const [data, setData] = useState({
business: '',
})
const [loading, setLoading] = useState(false)
const getCategory = () => {
axios
.get(`/api/business/${id}`, {
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
setData((prev) => ({
...prev,
...res.data?.data,
}))
})
.catch((err) => { })
}
useEffect(() => {
getCategory()
}, [])
const handleChange = (e) => {
setData((prev) => ({ ...prev, [e.target.id]: e.target.value }))
}
const handleSubmit = () => {
if (data.business.trim() === '') {
swal({
title: 'Warning',
text: 'Fill all mandatory fields',
icon: 'error',
button: 'Close',
dangerMode: true,
})
return
}
setLoading(true)
axios
.patch(`/api/business/${id}`, data, {
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
swal({
title: 'Updated',
text: 'business updated successfully!',
icon: 'success',
button: 'Close',
})
setLoading(false)
navigate('/business', { replace: true })
})
.catch((err) => {
setLoading(false)
swal({
title: 'Warning',
text: 'Something went wrong!',
icon: 'error',
button: 'Retry',
dangerMode: true,
})
})
}
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">
Edit business
</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={() => handleSubmit()}
disabled={loading}
>
{loading ? 'Loading' : 'Update'}
</Button>
<Link to="/cities">
<Button
variant="contained"
color="secondary"
style={{
fontWeight: 'bold',
marginBottom: '1rem',
textTransform: 'capitalize',
}}
>
Back
</Button>
</Link>
</div>
</div>
</div>
</div>
<div className="row">
<div className="col-8 mx-auto">
<div className="card h-100">
<div className="card-body px-5">
<div className="mb-3">
<label htmlFor="business" className="form-label">
business *
</label>
<input
type="text"
className="form-control"
id="business"
value={data.business}
maxLength='50'
onChange={(e) => handleChange(e)}
/>
{data.business && <p className="pt-1 pl-2 text-secondary">
Remaining characters : {50 - data.business.length}
</p>}
</div>
</div>
</div>
</div>
</div>
</div>
)
}
export default EditBusiness

View File

@ -0,0 +1,168 @@
import React, { useEffect, useState } from 'react'
import Button from '@material-ui/core/Button'
import { Link, useParams, useNavigate } from 'react-router-dom'
import swal from 'sweetalert'
import axios from 'axios'
import { isAutheticated } from 'src/auth'
const AddBusiness = () => {
const token = isAutheticated();
const navigate = useNavigate()
const [data, setData] = useState({
business: '',
})
const [loading, setLoading] = useState(false)
// const getNewId = () => {
// axios
// .get(`/api/city/newid`, {
// headers: {
// 'Access-Control-Allow-Origin': '*',
// Authorization: `Bearer ${token}`,
// },
// })
// .then((res) => {
// setData((prev) => ({ ...prev, _id: res.data.data._id }))
// })
// .catch((err) => { })
// useEffect(() => {
// getNewId()
// }, [])
const handleChange = (e) => {
setData((prev) => ({ ...prev, [e.target.id]: e.target.value }))
}
const handleSubmit = () => {
if (data.business.trim() === '') {
swal({
title: 'Warning',
text: 'Fill all mandatory fields',
icon: 'error',
button: 'Close',
dangerMode: true,
})
return
}
setLoading(true)
axios
.post(`/api/business`, data, {
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
swal({
title: 'Added',
text: 'Business added successfully!',
icon: 'success',
button: 'Return',
})
setLoading(false)
navigate('/businesss', { replace: true })
})
.catch((err) => {
setLoading(false)
swal({
title: 'Warning',
text: 'Something went wrong!',
icon: 'error',
button: 'Retry',
dangerMode: true
})
})
}
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">
Add Business
</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={() => handleSubmit()}
disabled={loading}
>
{loading ? 'Loading' : 'Save'}
</Button>
<Link to="/businesss">
<Button
variant="contained"
color="secondary"
style={{
fontWeight: 'bold',
marginBottom: '1rem',
textTransform: 'capitalize',
}}
>
Back
</Button>
</Link>
</div>
</div>
</div>
</div>
<div className="row">
<div className="col-8 mx-auto">
<div className="card h-100">
<div className="card-body px-5">
<div className="mb-3">
<label htmlFor="business" className="form-label">
Business *
</label>
<input
type="text"
className="form-control"
id="business"
value={data.business}
maxLength="50"
onChange={(e) => handleChange(e)}
/>
{data.business && <p className="pt-1 pl-2 text-secondary">
Remaining characters : {50 - data.business.length}
</p>}
</div>
</div>
</div>
</div>
</div>
</div>
)
}
export default AddBusiness

View File

@ -0,0 +1,172 @@
import React, { useEffect, useState } from 'react'
import Button from '@material-ui/core/Button'
import { Link, useNavigate, useParams } from 'react-router-dom'
import swal from 'sweetalert'
import axios from 'axios'
import { isAutheticated } from 'src/auth'
const EditLanguage = () => {
const id = useParams()?.id
const token = isAutheticated();
const navigate = useNavigate()
const [data, setData] = useState({
language: '',
})
const [loading, setLoading] = useState(false)
const getCategory = () => {
axios
.get(`/api/language/${id}`, {
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
setData((prev) => ({
...prev,
...res.data?.data,
}))
})
.catch((err) => { })
}
useEffect(() => {
getCategory()
}, [])
const handleChange = (e) => {
setData((prev) => ({ ...prev, [e.target.id]: e.target.value }))
}
const handleSubmit = () => {
if (data.language.trim() === '') {
swal({
title: 'Warning',
text: 'Fill all mandatory fields',
icon: 'error',
button: 'Close',
dangerMode: true,
})
return
}
setLoading(true)
axios
.patch(`/api/Language/${id}`, data, {
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
swal({
title: 'Updated',
text: 'Language updated successfully!',
icon: 'success',
button: 'Close',
})
setLoading(false)
navigate('/languages', { replace: true })
})
.catch((err) => {
setLoading(false)
swal({
title: 'Warning',
text: 'Something went wrong!',
icon: 'error',
button: 'Retry',
dangerMode: true,
})
})
}
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">
Edit Language
</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={() => handleSubmit()}
disabled={loading}
>
{loading ? 'Loading' : 'Update'}
</Button>
<Link to="/cities">
<Button
variant="contained"
color="secondary"
style={{
fontWeight: 'bold',
marginBottom: '1rem',
textTransform: 'capitalize',
}}
>
Back
</Button>
</Link>
</div>
</div>
</div>
</div>
<div className="row">
<div className="col-8 mx-auto">
<div className="card h-100">
<div className="card-body px-5">
<div className="mb-3">
<label htmlFor="language" className="form-label">
Language *
</label>
<input
type="text"
className="form-control"
id="language"
value={data.language}
maxLength='50'
onChange={(e) => handleChange(e)}
/>
{data.language && <p className="pt-1 pl-2 text-secondary">
Remaining characters : {50 - data.language.length}
</p>}
</div>
</div>
</div>
</div>
</div>
</div>
)
}
export default EditLanguage

View File

@ -0,0 +1,346 @@
import React, { useEffect } from 'react'
import Button from '@material-ui/core/Button'
import { useState } from 'react'
import { Link } from 'react-router-dom'
import axios from 'axios'
import swal from 'sweetalert'
import { isAutheticated } from 'src/auth'
const Languages = () => {
const token = isAutheticated();
const [loading, setLoading] = useState(true)
const [success, setSuccess] = useState(true)
const [LanguagesData, setLanguagesData] = useState([])
const [currentPage, setCurrentPage] = useState(1)
const [itemPerPage, setItemPerPage] = useState(10)
const [showData, setShowData] = useState(LanguagesData)
const handleShowEntries = (e) => {
setCurrentPage(1)
setItemPerPage(e.target.value)
}
const getCategories = () => {
axios
.get(`/api/language`, {
headers: { 'Access-Control-Allow-Origin': '*', Authorization: `Bearer ${token}` },
})
.then((res) => {
console.log(res.data)
setLanguagesData(res.data.data)
setLoading(false)
})
.catch((err) => {
console.log(err)
setLoading(false)
})
}
useEffect(() => {
getCategories()
}, [success])
useEffect(() => {
const loadData = () => {
const indexOfLastPost = currentPage * itemPerPage
const indexOfFirstPost = indexOfLastPost - itemPerPage
setShowData(LanguagesData.slice(indexOfFirstPost, indexOfLastPost))
}
loadData()
}, [currentPage, itemPerPage, LanguagesData])
const handleDelete = (id) => {
swal({
title: 'Are you sure?',
icon: 'error',
buttons: { Yes: { text: 'Yes', value: true }, Cancel: { text: 'Cancel', value: 'cancel' } },
}).then((value) => {
if (value === true) {
axios
.delete(`/api/language/${id}`, {
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
setSuccess((prev) => !prev)
})
.catch((err) => {
swal({
title: 'Warning',
text: 'Something went wrong!',
icon: 'error',
button: 'Retry',
dangerMode: true,
})
})
}
})
}
return (
<div className="main-content">
<div className="page-content">
<div className="container-fluid">
<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">
Languages
</div>
<div className="page-title-right">
<Link to="/language/add">
<Button
variant="contained"
color="primary"
style={{
fontWeight: 'bold',
marginBottom: '1rem',
textTransform: 'capitalize',
}}
>
Add Language
</Button>
</Link>
</div>
</div>
</div>
</div>
<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 className="col-sm-12 col-md-12">
<div className="dataTables_length">
<label className="w-100">
Show
<select
style={{ width: '10%' }}
name=""
onChange={(e) => handleShowEntries(e)}
className="
select-w
custom-select custom-select-sm
form-control form-control-sm
"
>
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
entries
</label>
</div>
</div>
</div>
<div className="table-responsive table-shoot mt-3">
<table
className="table table-centered table-nowrap"
style={{ border: '1px solid' }}
>
<thead className="thead" style={{ background: 'rgb(140, 213, 213)' }}>
<tr>
<th className="text-start">Language </th>
{/* <th className="text-start">State Name</th> */}
<th className="text-start">Created On</th>
<th className="text-start">Actions</th>
</tr>
</thead>
<tbody>
{!loading && showData.length === 0 && (
<tr className="text-center">
<td colSpan="6">
<h5>No Data Available</h5>
</td>
</tr>
)}
{loading ? (
<tr>
<td className="text-center" colSpan="6">
Loading...
</td>
</tr>
) : (
showData.map((language, i) => {
return (
<tr key={i}>
<td className="text-start">{language.language}</td>
{/* <td className="text-start">{language.state?.state_name}</td> */}
<td className="text-start">
{new Date(language.createdAt).toLocaleString('en-IN', {
weekday: 'short',
month: 'short',
day: 'numeric',
year: 'numeric',
hour: 'numeric',
minute: 'numeric',
hour12: true,
})}
</td>
<td className="text-start">
<Link to={`/language/edit/${language._id}`}>
<button
style={{ color: 'white', margin: '0 1rem' }}
type="button"
className="
btn btn-primary btn-sm
waves-effect waves-light
btn-table
me-1
"
>
Edit
</button>
</Link>
<Link
to={'#'}
style={{
margin: '1rem',
}}
>
<button
style={{ color: 'white' }}
type="button"
className="
btn btn-danger btn-sm
waves-effect waves-light
btn-table
me-1
"
onClick={() => {
handleDelete(language._id)
}}
>
Delete
</button>
</Link>
</td>
</tr>
)
})
)}
</tbody>
</table>
</div>
<div className="row mt-20">
<div className="col-sm-12 col-md-6 mb-20">
<div
className="dataTables_info"
id="datatable_info"
role="status"
aria-live="polite"
>
Showing {currentPage * itemPerPage - itemPerPage + 1} to{' '}
{Math.min(currentPage * itemPerPage, LanguagesData.length)} of{' '}
{LanguagesData.length} entries
</div>
</div>
<div className="col-sm-12 col-md-6">
<div className="d-flex">
<ul className="pagination ms-auto">
<li
className={
currentPage === 1
? 'paginate_button page-item previous disabled'
: 'paginate_button page-item previous'
}
>
<span
className="page-link"
style={{ cursor: 'pointer' }}
onClick={() => setCurrentPage((prev) => prev - 1)}
>
Previous
</span>
</li>
{!(currentPage - 1 < 1) && (
<li className="paginate_button page-item">
<span
className="page-link"
style={{ cursor: 'pointer' }}
onClick={(e) => setCurrentPage((prev) => prev - 1)}
>
{currentPage - 1}
</span>
</li>
)}
<li className="paginate_button page-item active">
<span className="page-link" style={{ cursor: 'pointer' }}>
{currentPage}
</span>
</li>
{!(
(currentPage + 1) * itemPerPage - itemPerPage >
LanguagesData.length - 1
) && (
<li className="paginate_button page-item ">
<span
className="page-link"
style={{ cursor: 'pointer' }}
onClick={() => {
setCurrentPage((prev) => prev + 1)
}}
>
{currentPage + 1}
</span>
</li>
)}
<li
className={
!(
(currentPage + 1) * itemPerPage - itemPerPage >
LanguagesData.length - 1
)
? 'paginate_button page-item next'
: 'paginate_button page-item next disabled'
}
>
<span
className="page-link"
style={{ cursor: 'pointer' }}
onClick={() => setCurrentPage((prev) => prev + 1)}
>
Next
</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
)
}
export default Languages

View File

@ -0,0 +1,406 @@
import React, { useState, useEffect } from 'react'
import { Link } from 'react-router-dom'
import Button from '@material-ui/core/Button'
import { useNavigate } from 'react-router-dom'
import axios from 'axios'
import { isAutheticated } from 'src/auth'
const Policies = () => {
const token = isAutheticated()
const navigate = useNavigate()
const [loading, setLoading] = useState(true)
const [success, setSuccess] = useState(true)
const [DeparturesData, setDeparturesData] = useState([])
const [currentPage, setCurrentPage] = useState(1)
const [itemPerPage, setItemPerPage] = useState(10)
const [showData, setShowData] = useState(DeparturesData)
const handleShowEntries = (e) => {
setCurrentPage(1)
setItemPerPage(e.target.value)
}
const getDeparturesData = async () => {
axios
.get(`/api/departure/flight/getAll/`, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
console.log(res.data.departure)
setDeparturesData(res.data?.departure)
setLoading(false)
})
.catch((err) => {
setLoading(false)
})
}
useEffect(() => {
getDeparturesData()
}, [success])
useEffect(() => {
const loadData = () => {
const indexOfLastPost = currentPage * itemPerPage
const indexOfFirstPost = indexOfLastPost - itemPerPage
setShowData(DeparturesData.slice(indexOfFirstPost, indexOfLastPost))
}
loadData()
}, [currentPage, itemPerPage, DeparturesData])
const handleDelete = (id) => {
swal({
title: 'Are you sure?',
icon: 'error',
buttons: { Yes: { text: 'Yes', value: true }, Cancel: { text: 'Cancel', value: 'cancel' } },
}).then((value) => {
if (value === true) {
axios
.delete(`/api/product/delete/${id}`, {
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
setSuccess((prev) => !prev)
})
.catch((err) => {
swal({
title: 'Warning',
text: 'Something went wrong!',
icon: 'error',
button: 'Retry',
dangerMode: true,
})
})
}
})
}
return (
<div className="main-content">
<div className="page-content">
<div className="container-fluid">
<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">
Policies
</div>
<div className="page-title-right">
<Button
variant="contained"
color="primary"
style={{
fontWeight: 'bold',
marginBottom: '1rem',
textTransform: 'capitalize',
}}
onClick={() => {
navigate('/dashboard/', { replace: true })
}}
>
Back
</Button>
</div>
</div>
</div>
</div>
<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 className="col-sm-12 col-md-12">
<div className="dataTables_length">
<label className="w-100">
Show
<select
style={{ width: '10%' }}
name=""
onChange={(e) => handleShowEntries(e)}
className="
select-w
custom-select custom-select-sm
form-control form-control-sm
"
>
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
entries
</label>
</div>
</div>
</div>
<div className="table-responsive table-shoot mt-3">
<table
className="table table-centered table-nowrap"
style={{ border: '1px solid' }}
>
<thead className="thead-info" style={{ background: 'rgb(140, 213, 213)' }}>
<tr>
<th className="text-start">Cancellation Policy </th>
<th className="text-start">Return Policy</th>
<th className="text-start"> Privacy Policy</th>
<th className="text-start"> Returns and Exchange</th>
<th className="text-start">Refund Policy</th>
<th className="text-start"> Shipping Policy</th>
<th className="text-start">Terms of Use</th>
<th className="text-start"> About Us
</th>
{/* <th className="text-start">Added On</th> */}
{/* <th className="text-start">Actions</th> */}
</tr>
</thead>
<tbody>
{/* {!loading && showData.length === 0 && (
<tr className="text-center">
<td colSpan="6">
<h5>No Data Available</h5>
</td>
</tr>
)} */}
{/* {loading ? (
<tr>
<td className="text-center" colSpan="6">
Loading...
</td>
</tr>
) : ( */}
{/* showData.map((product, i) => { */}
{/* return ( */}
<tr>
<Link to={`/policy/cancellation/`}>
<button
style={{ color: 'white', marginRight: '1rem' }}
type="button"
className="
btn btn-info btn-sm
waves-effect waves-light
btn-table
mt-2
mx-1
mb-3
"
>
View
</button>
</Link>
{/* <td className="text-start">{product.Airline}</td>
<td className="text-start">{product.Destination}</td>
<td className="text-start">{product.GateNumber}</td>
<td className="text-start">{product.ActualTimeofDeparture}</td>
<td className="text-start">{product.ScheduledTimeofDeparture}</td>
<td className="text-start">{product.EstimatedTimeofDeparture}</td>
<td className="text-start"> <button className=" btn btn-info btn-sm mt-1">{product.Status}</button></td> */}
{/* <td className="text-start">
{new Date(product.createdAt).toLocaleString('en-IN', {
weekday: 'short',
month: 'short',
day: 'numeric',
year: 'numeric',
hour: 'numeric',
minute: 'numeric',
hour12: true,
})}
</td> */}
{/* <td className="text-start">
<Link to={`/product/view/`}>
<button
style={{ color: 'white', marginRight: '1rem' }}
type="button"
className="
btn btn-primary btn-sm
waves-effect waves-light
btn-table
mx-1
mt-1
"
>
View
</button>
</Link>
<Link to={`/product/edit/`}>
<button
style={{ color: 'white', marginRight: '1rem' }}
type="button"
className="
btn btn-info btn-sm
waves-effect waves-light
btn-table
mt-1
mx-1
"
>
Edit
</button>
</Link>
<Link
to={'#'}
style={{
marginRight: '1rem',
}}
>
<button
style={{ color: 'white' }}
type="button"
className="
btn btn-danger btn-sm
waves-effect waves-light
btn-table
mt-1
mx-1
"
onClick={() => {
handleDelete()
}}
>
Delete
</button>
</Link>
</td> */}
</tr>
</tbody>
</table>
</div>
<div className="row mt-20">
<div className="col-sm-12 col-md-6 mb-20">
<div
className="dataTables_info"
id="datatable_info"
role="status"
aria-live="polite"
>
Showing {currentPage * itemPerPage - itemPerPage + 1} to{' '}
{Math.min(currentPage * itemPerPage, DeparturesData.length)} of{' '}
{DeparturesData.length} entries
</div>
</div>
<div className="col-sm-12 col-md-6">
<div className="d-flex">
<ul className="pagination ms-auto">
<li
className={
currentPage === 1
? 'paginate_button page-item previous disabled'
: 'paginate_button page-item previous'
}
>
<span
className="page-link"
style={{ cursor: 'pointer' }}
onClick={() => setCurrentPage((prev) => prev - 1)}
>
Previous
</span>
</li>
{!(currentPage - 1 < 1) && (
<li className="paginate_button page-item">
<span
className="page-link"
style={{ cursor: 'pointer' }}
onClick={(e) => setCurrentPage((prev) => prev - 1)}
>
{currentPage - 1}
</span>
</li>
)}
<li className="paginate_button page-item active">
<span className="page-link" style={{ cursor: 'pointer' }}>
{currentPage}
</span>
</li>
{!(
(currentPage + 1) * itemPerPage - itemPerPage >
DeparturesData.length - 1
) && (
<li className="paginate_button page-item ">
<span
className="page-link"
style={{ cursor: 'pointer' }}
onClick={() => {
setCurrentPage((prev) => prev + 1)
}}
>
{currentPage + 1}
</span>
</li>
)}
<li
className={
!(
(currentPage + 1) * itemPerPage - itemPerPage >
DeparturesData.length - 1
)
? 'paginate_button page-item next'
: 'paginate_button page-item next disabled'
}
>
<span
className="page-link"
style={{ cursor: 'pointer' }}
onClick={() => setCurrentPage((prev) => prev + 1)}
>
Next
</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
)
}
export default Policies

View File

@ -10,59 +10,20 @@ import { isAutheticated } from 'src/auth'
const AddCity = () => {
const token = isAutheticated();
const navigate = useNavigate()
const [statesData, setStatesData] = useState([])
const [data, setData] = useState({
city_name: '',
state: '',
purpose: '',
})
const [loading, setLoading] = useState(false)
const [limiter, setLimiter] = useState({
city_name: 30,
city_nameHas: 30,
})
const getNewId = () => {
axios
.get(`/api/city/newid`, {
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
setData((prev) => ({ ...prev, _id: res.data.data._id }))
})
.catch((err) => { })
axios
.get(`/api/state`, {
headers: { 'Access-Control-Allow-Origin': '*', Authorization: `Bearer ${token}` },
})
.then((res) => {
setStatesData(res.data.data)
})
.catch((err) => {
console.log(err)
})
}
useEffect(() => {
getNewId()
}, [])
const handleChange = (e) => {
if (e.target.type === 'text') {
if (e.target.value.length === limiter[e.target.id] + 1) return
setLimiter((prev) => ({
...prev,
[e.target.id + 'Has']: prev[e.target.id] - e.target.value.length,
}))
}
setData((prev) => ({ ...prev, [e.target.id]: e.target.value }))
}
const handleSubmit = () => {
if (data.city_name.trim() === '' || data.state.trim() === '') {
if (data.purpose.trim() === '') {
swal({
title: 'Warning',
text: 'Fill all mandatory fields',
@ -74,7 +35,7 @@ const AddCity = () => {
}
setLoading(true)
axios
.post(`/api/city`, data, {
.post(`/api/purpose`, data, {
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: `Bearer ${token}`,
@ -83,12 +44,12 @@ const AddCity = () => {
.then((res) => {
swal({
title: 'Added',
text: 'City added successfully!',
text: 'Purpose added successfully!',
icon: 'success',
button: 'Return',
})
setLoading(false)
navigate('/cities', { replace: true })
navigate('/purpose', { replace: true })
})
.catch((err) => {
setLoading(false)
@ -116,7 +77,7 @@ const AddCity = () => {
"
>
<div style={{ fontSize: '22px' }} className="fw-bold">
Add City
Add Perpose
</div>
<div style={{ display: 'flex', gap: '1rem' }}>
<h4 className="mb-0"></h4>
@ -137,7 +98,7 @@ const AddCity = () => {
>
{loading ? 'Loading' : 'Save'}
</Button>
<Link to="/cities">
<Link to="/purpose">
<Button
variant="contained"
color="secondary"
@ -159,23 +120,23 @@ const AddCity = () => {
<div className="card h-100">
<div className="card-body px-5">
<div className="mb-3">
<label htmlFor="city_name" className="form-label">
City Name*
<label htmlFor="purpose" className="form-label">
Purpose *
</label>
<input
type="text"
className="form-control"
id="city_name"
value={data.city_name}
maxLength="50"
id="purpose"
value={data.purpose}
maxLength="60"
onChange={(e) => handleChange(e)}
/>
<p className="pt-1 pl-2 text-secondary">
Remaining characters : {limiter.city_nameHas}
Remaining characters : {50 - data.purpose.length}
</p>
</div>
<div className="mb-3">
<label htmlFor="city_name" className="form-label">
{/* <div className="mb-3">
<label htmlFor="purpose" className="form-label">
State Name*
</label>
<select
@ -197,7 +158,7 @@ const AddCity = () => {
</option>
)}
</select>
</div>
</div> */}
</div>

View File

@ -7,25 +7,19 @@ import axios from 'axios'
import { isAutheticated } from 'src/auth'
const EditCity = () => {
const EditPurpose = () => {
const id = useParams()?.id
const token = isAutheticated();
const navigate = useNavigate()
const [statesData, setStatesData] = useState([])
const [data, setData] = useState({
city_name: '',
state: '',
purpose: '',
})
const [loading, setLoading] = useState(false)
const [limiter, setLimiter] = useState({
city_name: 30,
city_nameHas: 30,
})
const getCategory = () => {
axios
.get(`$/api/city/${id}`, {
.get(`/api/purpose/${id}`, {
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: `Bearer ${token}`,
@ -36,22 +30,10 @@ const EditCity = () => {
...prev,
...res.data?.data,
}))
setLimiter((prev) => ({
...prev,
city_nameHas: prev.city_name - res.data?.data?.city_name.length,
}))
})
.catch((err) => { })
axios
.get(`/api/state`, {
headers: { 'Access-Control-Allow-Origin': '*', Authorization: `Bearer ${token}` },
})
.then((res) => {
setStatesData(res.data.data)
})
.catch((err) => {
console.log(err)
})
}
useEffect(() => {
@ -59,18 +41,12 @@ const EditCity = () => {
}, [])
const handleChange = (e) => {
if (e.target.type === 'text') {
if (e.target.value.length === limiter[e.target.id] + 1) return
setLimiter((prev) => ({
...prev,
[e.target.id + 'Has']: prev[e.target.id] - e.target.value.length,
}))
}
setData((prev) => ({ ...prev, [e.target.id]: e.target.value }))
}
const handleSubmit = () => {
if (data.city_name.trim() === '' || data.state.trim() === '') {
if (data.purpose.trim() === '') {
swal({
title: 'Warning',
text: 'Fill all mandatory fields',
@ -82,7 +58,7 @@ const EditCity = () => {
}
setLoading(true)
axios
.patch(`/api/city/${id}`, data, {
.patch(`/api/purpose/${id}`, data, {
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: `Bearer ${token}`,
@ -91,12 +67,12 @@ const EditCity = () => {
.then((res) => {
swal({
title: 'Updated',
text: 'City updated successfully!',
text: 'Purpose updated successfully!',
icon: 'success',
button: 'Close',
})
setLoading(false)
navigate('/cities', { replace: true })
navigate('/purpose', { replace: true })
})
.catch((err) => {
setLoading(false)
@ -123,7 +99,7 @@ const EditCity = () => {
"
>
<div style={{ fontSize: '22px' }} className="fw-bold">
Edit City
Edit Purpose
</div>
<div style={{ display: 'flex', gap: '1rem' }}>
<h4 className="mb-0"></h4>
@ -144,7 +120,7 @@ const EditCity = () => {
>
{loading ? 'Loading' : 'Update'}
</Button>
<Link to="/cities">
<Link to="/purpose">
<Button
variant="contained"
color="secondary"
@ -166,45 +142,23 @@ const EditCity = () => {
<div className="card h-100">
<div className="card-body px-5">
<div className="mb-3">
<label htmlFor="city_name" className="form-label">
City Name*
<label htmlFor="purpose" className="form-label">
Purpose Name*
</label>
<input
type="text"
className="form-control"
id="city_name"
value={data.city_name}
maxLength={limiter.city_name}
id="purpose"
value={data.purpose}
maxLength='50'
onChange={(e) => handleChange(e)}
/>
<p className="pt-1 pl-2 text-secondary">
Remaining characters : {limiter.city_nameHas}
Remaining characters : {50 - data.purpose.length}
</p>
</div>
<div className="mb-3">
<label htmlFor="city_name" className="form-label">
State Name*
</label>
<select
onChange={(e) => handleChange(e)}
value={data.state}
className="form-control"
id="state"
>
<option value="">---select---</option>
{statesData[0] ? (
statesData.map((c, i) => (
<option key={i} value={c._id}>
{c.state_name}
</option>
))
) : (
<option value="" disabled>
Please add a City
</option>
)}
</select>
</div>
{/* <div className="mb-3">
<label>Unique ID</label>
<input type="text" value={data._id} className="form-control" disabled />
@ -226,4 +180,4 @@ const EditCity = () => {
)
}
export default EditCity
export default EditPurpose

View File

@ -25,7 +25,7 @@ const Cities = () => {
const getCategories = () => {
axios
.get(`/api/city`, {
.get(`/api/purpose`, {
headers: { 'Access-Control-Allow-Origin': '*', Authorization: `Bearer ${token}` },
})
.then((res) => {
@ -59,7 +59,7 @@ const Cities = () => {
}).then((value) => {
if (value === true) {
axios
.delete(`/api/city/${id}`, {
.delete(`/api/purpose/${id}`, {
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: `Bearer ${token}`,
@ -96,11 +96,11 @@ const Cities = () => {
"
>
<div style={{ fontSize: '22px' }} className="fw-bold">
Cities
Purpose
</div>
<div className="page-title-right">
<Link to="/cities/add">
<Link to="/purpose/add">
<Button
variant="contained"
color="primary"
@ -110,7 +110,7 @@ const Cities = () => {
textTransform: 'capitalize',
}}
>
Add City
Add Purpose
</Button>
</Link>
</div>
@ -154,8 +154,8 @@ const Cities = () => {
>
<thead className="thead" style={{ background: 'rgb(140, 213, 213)' }}>
<tr>
<th className="text-start">City Name</th>
<th className="text-start">State Name</th>
<th className="text-start">Purpose</th>
<th className="text-start">Created On</th>
<th className="text-start">Actions</th>
</tr>
@ -175,13 +175,13 @@ const Cities = () => {
</td>
</tr>
) : (
showData.map((city, i) => {
showData.map((purpose, i) => {
return (
<tr key={i}>
<td className="text-start">{city.city_name}</td>
<td className="text-start">{city.state?.state_name}</td>
<td className="text-start">{purpose.purpose}</td>
{/* <td className="text-start">{purpose.state?.state_name}</td> */}
<td className="text-start">
{new Date(city.createdAt).toLocaleString('en-IN', {
{new Date(purpose.createdAt).toLocaleString('en-IN', {
weekday: 'short',
month: 'short',
day: 'numeric',
@ -193,7 +193,7 @@ const Cities = () => {
</td>
<td className="text-start">
<Link to={`/cities/edit/${city._id}`}>
<Link to={`/purpose/edit/${purpose._id}`}>
<button
style={{ color: 'white', margin: '0 1rem' }}
type="button"
@ -224,7 +224,7 @@ const Cities = () => {
"
onClick={() => {
handleDelete(city._id)
handleDelete(purpose._id)
}}
>
Delete

View File

@ -146,7 +146,7 @@ const Login = () => {
<CCardBody>
<CForm>
<h1>Login</h1>
<p className="text-medium-emphasis">Sign In to Your Jatin Mor Admin Dashboard Account.</p>
<p className="text-medium-emphasis">Sign In to Your Bolo Admin Dashboard Account.</p>
<CInputGroup className="mb-3">
<CInputGroupText>
<CIcon icon={cilUser} />