first commit
This commit is contained in:
parent
0db219e2d3
commit
0fe41e3b3b
@ -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>Jatin Mor Admin</title>
|
<title>Bolo 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/
|
||||||
|
144
src/_nav.js
144
src/_nav.js
@ -5,6 +5,7 @@ import {
|
|||||||
cilAirplaneMode,
|
cilAirplaneMode,
|
||||||
cilAppsSettings,
|
cilAppsSettings,
|
||||||
cilBell,
|
cilBell,
|
||||||
|
cilBrush,
|
||||||
cilCalculator,
|
cilCalculator,
|
||||||
cilCart,
|
cilCart,
|
||||||
cilChartPie,
|
cilChartPie,
|
||||||
@ -17,6 +18,7 @@ import {
|
|||||||
cilFace,
|
cilFace,
|
||||||
cilFilterSquare,
|
cilFilterSquare,
|
||||||
cilInfo,
|
cilInfo,
|
||||||
|
cilLanguage,
|
||||||
cilLoopCircular,
|
cilLoopCircular,
|
||||||
cilMedicalCross,
|
cilMedicalCross,
|
||||||
cilMoney,
|
cilMoney,
|
||||||
@ -28,6 +30,7 @@ import {
|
|||||||
cilSitemap,
|
cilSitemap,
|
||||||
cilSpeedometer,
|
cilSpeedometer,
|
||||||
cilStar,
|
cilStar,
|
||||||
|
cilSwapHorizontal,
|
||||||
cilTablet,
|
cilTablet,
|
||||||
cilTags,
|
cilTags,
|
||||||
cilTennisBall,
|
cilTennisBall,
|
||||||
@ -79,56 +82,56 @@ const _nav = [
|
|||||||
// to: '/informations',
|
// to: '/informations',
|
||||||
// },
|
// },
|
||||||
|
|
||||||
// {
|
{
|
||||||
// component: CNavItem,
|
component: CNavItem,
|
||||||
// name: 'Franchisee',
|
name: 'Businesses',
|
||||||
// icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
|
||||||
// to: '/franchisees',
|
to: '/businesses',
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// component: CNavGroup,
|
component: CNavGroup,
|
||||||
// name: 'Franchisee Orders',
|
name: 'Franchisee Orders',
|
||||||
// icon: <CIcon icon={cilCart} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilCart} customClassName="nav-icon" />,
|
||||||
// items: [
|
items: [
|
||||||
// {
|
{
|
||||||
// component: CNavItem,
|
component: CNavItem,
|
||||||
// name: 'New',
|
name: 'New',
|
||||||
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
// to: '/orders/new',
|
to: '/orders/new',
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// component: CNavItem,
|
component: CNavItem,
|
||||||
// name: 'Paid',
|
name: 'Paid',
|
||||||
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
// to: '/orders/returned',
|
to: '/orders/returned',
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// component: CNavItem,
|
component: CNavItem,
|
||||||
// name: 'Processing',
|
name: 'Processing',
|
||||||
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
// to: '/orders/processing',
|
to: '/orders/processing',
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// component: CNavItem,
|
component: CNavItem,
|
||||||
// name: 'Dispatched',
|
name: 'Dispatched',
|
||||||
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
// to: '/orders/dispatched',
|
to: '/orders/dispatched',
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// component: CNavItem,
|
component: CNavItem,
|
||||||
// name: 'Delivered',
|
name: 'Delivered',
|
||||||
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
// to: '/orders/delivered',
|
to: '/orders/delivered',
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// component: CNavItem,
|
component: CNavItem,
|
||||||
// name: 'Cancelled',
|
name: 'Cancelled',
|
||||||
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
// to: '/orders/cancelled',
|
to: '/orders/cancelled',
|
||||||
// },
|
},
|
||||||
|
|
||||||
// ],
|
],
|
||||||
// },
|
},
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -142,12 +145,19 @@ const _nav = [
|
|||||||
name: 'Configuration',
|
name: 'Configuration',
|
||||||
icon: <CIcon icon={cilAppsSettings} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilAppsSettings} customClassName="nav-icon" />,
|
||||||
items: [
|
items: [
|
||||||
// {
|
{
|
||||||
// component: CNavItem,
|
component: CNavItem,
|
||||||
// name: 'Cities',
|
name: 'Purpose',
|
||||||
// icon: <CIcon icon={cilLoopCircular} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilLoopCircular} customClassName="nav-icon" />,
|
||||||
// to: '/cities',
|
to: '/purpose',
|
||||||
// },
|
},
|
||||||
|
{
|
||||||
|
component: CNavItem,
|
||||||
|
name: 'Business Type',
|
||||||
|
icon: <CIcon icon={cilBrush} customClassName="nav-icon" />,
|
||||||
|
to: '/business',
|
||||||
|
},
|
||||||
|
|
||||||
// {
|
// {
|
||||||
// component: CNavItem,
|
// component: CNavItem,
|
||||||
// name: 'States',
|
// name: 'States',
|
||||||
@ -178,18 +188,18 @@ const _nav = [
|
|||||||
// icon: <CIcon icon={cilTags} customClassName="nav-icon" />,
|
// icon: <CIcon icon={cilTags} customClassName="nav-icon" />,
|
||||||
// to: '/tax',
|
// to: '/tax',
|
||||||
// },
|
// },
|
||||||
// {
|
{
|
||||||
// component: CNavItem,
|
component: CNavItem,
|
||||||
// name: 'Pages',
|
name: 'Languages',
|
||||||
// icon: <CIcon icon={cilCommand} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilLanguage} customClassName="nav-icon" />,
|
||||||
// to: '/page',
|
to: '/languages',
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// component: CNavItem,
|
component: CNavItem,
|
||||||
// name: 'Terms of Use',
|
name: 'Policies',
|
||||||
// icon: <CIcon icon={cilCommand} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilSwapHorizontal} customClassName="nav-icon" />,
|
||||||
// to: '/terms_of_use',
|
to: '/policies',
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: 'Social Media',
|
name: 'Social Media',
|
||||||
|
@ -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>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" height={35} /> */}
|
||||||
<CIcon className="sidebar-brand-narrow" icon={sygnet} height={35} />
|
<CIcon className="sidebar-brand-narrow" icon={sygnet} height={35} />
|
||||||
</CSidebarBrand>
|
</CSidebarBrand>
|
||||||
|
@ -11,8 +11,8 @@ import axios from 'axios'
|
|||||||
import { store } from './redux/store';
|
import { store } from './redux/store';
|
||||||
|
|
||||||
const setupAxios = () => {
|
const setupAxios = () => {
|
||||||
axios.defaults.baseURL = 'https://jatinmor-api.checkapp.one/'
|
// axios.defaults.baseURL = 'https://bolo-api.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',
|
||||||
'Pragma': 'no-cache',
|
'Pragma': 'no-cache',
|
||||||
|
@ -10,9 +10,9 @@ import EditProfile from './views/Profile/EditProfile'
|
|||||||
const Dashboard = React.lazy(() => import('./views/dashboard/Dashboard'))
|
const Dashboard = React.lazy(() => import('./views/dashboard/Dashboard'))
|
||||||
///
|
///
|
||||||
//Cities
|
//Cities
|
||||||
import Cities from './views/configuration/cities/Cities.js'
|
import Cities from './views/configuration/Purpose/Purpose.js'
|
||||||
import AddCity from './views/configuration/cities/AddCity.js'
|
import AddCity from './views/configuration/Purpose/AddPurpose.js'
|
||||||
import EditCity from './views/configuration/cities/EditCity.js'
|
import EditCity from './views/configuration/Purpose/EditPurpose.js'
|
||||||
//states
|
//states
|
||||||
import EditState from './views/configuration/states/EditStates.js'
|
import EditState from './views/configuration/states/EditStates.js'
|
||||||
import AddState from './views/configuration/states/AddState.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 Address from './views/configuration/Address.js'
|
||||||
import Logo from './views/configuration/Logo.js'
|
import Logo from './views/configuration/Logo.js'
|
||||||
import Login from './views/pages/login/Login'
|
import Login from './views/pages/login/Login'
|
||||||
//Franchisees
|
|
||||||
import Franchisees from './views/Temples/Franchisees'
|
//Businesses
|
||||||
import AddFranchisee from './views/Temples/AddFranchisee'
|
import Businesses from './views/Business/Businesses.js'
|
||||||
import EditFranchisee from './views/Temples/EditFranchisee'
|
import AddBusiness from './views/Business/AddBusiness.js'
|
||||||
|
import EditBusiness from './views/Business/EditBusiness.js'
|
||||||
import Products from './views/Products/Products'
|
import Products from './views/Products/Products'
|
||||||
//product
|
//product
|
||||||
import AddProduct from './views/Products/AddProduct'
|
import AddProduct from './views/Products/AddProduct'
|
||||||
@ -59,7 +60,17 @@ import AddContactRequest from './views/ContactRequests/AddContactRequest'
|
|||||||
import Testimonials from './views/Testimonials/Testimonials'
|
import Testimonials from './views/Testimonials/Testimonials'
|
||||||
import AddTestimonial from './views/Testimonials/AddTestimonial'
|
import AddTestimonial from './views/Testimonials/AddTestimonial'
|
||||||
import ViewTestimonial from './views/Testimonials/ViewTestimonial'
|
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 = [
|
const routes = [
|
||||||
|
|
||||||
{ path: '/', exact: true, name: 'Home' },
|
{ path: '/', exact: true, name: 'Home' },
|
||||||
@ -78,6 +89,11 @@ const routes = [
|
|||||||
{ path: '/departure/add', name: 'Add Departure', element: AddDeparture },
|
{ path: '/departure/add', name: 'Add Departure', element: AddDeparture },
|
||||||
{ path: '/product/edit/:id', name: 'Edit products', element: EditProduct },
|
{ path: '/product/edit/:id', name: 'Edit products', element: EditProduct },
|
||||||
{ path: '/product/view/:id', name: 'view products', element: ViewProduct },
|
{ 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
|
//Contact Requests
|
||||||
{ path: '/contact/request', name: 'Contact Requests', element: ContactRequests },
|
{ path: '/contact/request', name: 'Contact Requests', element: ContactRequests },
|
||||||
{ path: '/contact/request/new', name: 'AddContact Request', element: AddContactRequest },
|
{ path: '/contact/request/new', name: 'AddContact Request', element: AddContactRequest },
|
||||||
@ -114,8 +130,29 @@ const routes = [
|
|||||||
|
|
||||||
//------------settings------------------------//
|
//------------settings------------------------//
|
||||||
|
|
||||||
|
{ path: '/policies', name: 'Policies', element: Policies },
|
||||||
|
|
||||||
{ path: '/socialmedia', name: 'Social Media', element: Socialmedia },
|
{ 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: '/application/name', name: 'ApplicationName', element: ApplicationName },
|
||||||
{ path: '/copyright/message', name: 'Copyright Message', element: CopyrightMessage },
|
{ path: '/copyright/message', name: 'Copyright Message', element: CopyrightMessage },
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import axios from 'axios'
|
|||||||
import { isAutheticated } from 'src/auth'
|
import { isAutheticated } from 'src/auth'
|
||||||
// import { WebsiteURL } from '../WebsiteURL'
|
// import { WebsiteURL } from '../WebsiteURL'
|
||||||
|
|
||||||
const AddFranchisee = () => {
|
const AddBusiness = () => {
|
||||||
const [WebsiteURL, setWebsiteURL] = useState('https://reinventuniforms.in/')
|
const [WebsiteURL, setWebsiteURL] = useState('https://reinventuniforms.in/')
|
||||||
const token = isAutheticated()
|
const token = isAutheticated()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
@ -509,4 +509,4 @@ const AddFranchisee = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AddFranchisee
|
export default AddBusiness
|
@ -8,15 +8,15 @@ import swal from 'sweetalert'
|
|||||||
import OverLayButton from './OverLayButton.js'
|
import OverLayButton from './OverLayButton.js'
|
||||||
import { isAutheticated } from 'src/auth.js'
|
import { isAutheticated } from 'src/auth.js'
|
||||||
|
|
||||||
const Franchisees = () => {
|
const Businesses = () => {
|
||||||
const token = isAutheticated()
|
const token = isAutheticated()
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const [success, setSuccess] = useState(true)
|
const [success, setSuccess] = useState(true)
|
||||||
const [FranchiseesData, setFranchiseesData] = useState([])
|
const [BusinessesData, setBusinessesData] = 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(FranchiseesData)
|
const [showData, setShowData] = useState(BusinessesData)
|
||||||
|
|
||||||
const handleShowEntries = (e) => {
|
const handleShowEntries = (e) => {
|
||||||
setCurrentPage(1)
|
setCurrentPage(1)
|
||||||
@ -30,7 +30,7 @@ const Franchisees = () => {
|
|||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
// console.log(res.data.data)
|
// console.log(res.data.data)
|
||||||
setFranchiseesData(res.data.data)
|
setBusinessesData(res.data.data)
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@ -47,10 +47,10 @@ const Franchisees = () => {
|
|||||||
const loadData = () => {
|
const loadData = () => {
|
||||||
const indexOfLastPost = currentPage * itemPerPage
|
const indexOfLastPost = currentPage * itemPerPage
|
||||||
const indexOfFirstPost = indexOfLastPost - itemPerPage
|
const indexOfFirstPost = indexOfLastPost - itemPerPage
|
||||||
setShowData(FranchiseesData.slice(indexOfFirstPost, indexOfLastPost))
|
setShowData(BusinessesData.slice(indexOfFirstPost, indexOfLastPost))
|
||||||
}
|
}
|
||||||
loadData()
|
loadData()
|
||||||
}, [currentPage, itemPerPage, FranchiseesData])
|
}, [currentPage, itemPerPage, BusinessesData])
|
||||||
|
|
||||||
|
|
||||||
const handleVarification = (id) => {
|
const handleVarification = (id) => {
|
||||||
@ -134,11 +134,11 @@ const Franchisees = () => {
|
|||||||
"
|
"
|
||||||
>
|
>
|
||||||
<div style={{ fontSize: '22px' }} className="fw-bold">
|
<div style={{ fontSize: '22px' }} className="fw-bold">
|
||||||
Franchisees
|
Businesses
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="page-title-right">
|
<div className="page-title-right">
|
||||||
<Link to="/franchisee/add">
|
<Link to="/business/add">
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="primary"
|
color="primary"
|
||||||
@ -148,7 +148,7 @@ const Franchisees = () => {
|
|||||||
textTransform: 'capitalize',
|
textTransform: 'capitalize',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Add Franchisee
|
Add Business
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
@ -192,7 +192,7 @@ const Franchisees = () => {
|
|||||||
>
|
>
|
||||||
<thead className="thead-info" style={{ background: 'rgb(140, 213, 213)' }}>
|
<thead className="thead-info" style={{ background: 'rgb(140, 213, 213)' }}>
|
||||||
<tr>
|
<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">Logo</th>
|
||||||
<th className="text-start">City </th>
|
<th className="text-start">City </th>
|
||||||
<th className="text-start">Created On</th>
|
<th className="text-start">Created On</th>
|
||||||
@ -259,7 +259,7 @@ const Franchisees = () => {
|
|||||||
<td className=" text-center">
|
<td className=" text-center">
|
||||||
<OverLayButton data={{ url: franchisee?.url }} />
|
<OverLayButton data={{ url: franchisee?.url }} />
|
||||||
|
|
||||||
<Link to={`/franchisee/products/${franchisee._id}`}>
|
<Link to={`/business/products/${franchisee._id}`}>
|
||||||
<button
|
<button
|
||||||
style={{ color: 'white' }}
|
style={{ color: 'white' }}
|
||||||
type="button"
|
type="button"
|
||||||
@ -273,7 +273,7 @@ const Franchisees = () => {
|
|||||||
</button>
|
</button>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<Link to={`/franchisee/edit/${franchisee._id}`}>
|
<Link to={`/business/edit/${franchisee._id}`}>
|
||||||
<button
|
<button
|
||||||
style={{ color: 'white' }}
|
style={{ color: 'white' }}
|
||||||
type="button"
|
type="button"
|
||||||
@ -319,8 +319,8 @@ const Franchisees = () => {
|
|||||||
aria-live="polite"
|
aria-live="polite"
|
||||||
>
|
>
|
||||||
Showing {currentPage * itemPerPage - itemPerPage + 1} to{' '}
|
Showing {currentPage * itemPerPage - itemPerPage + 1} to{' '}
|
||||||
{Math.min(currentPage * itemPerPage, FranchiseesData.length)} of{' '}
|
{Math.min(currentPage * itemPerPage, BusinessesData.length)} of{' '}
|
||||||
{FranchiseesData.length} entries
|
{BusinessesData.length} entries
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -363,7 +363,7 @@ const Franchisees = () => {
|
|||||||
|
|
||||||
{!(
|
{!(
|
||||||
(currentPage + 1) * itemPerPage - itemPerPage >
|
(currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
FranchiseesData.length - 1
|
BusinessesData.length - 1
|
||||||
) && (
|
) && (
|
||||||
<li className="paginate_button page-item ">
|
<li className="paginate_button page-item ">
|
||||||
<span
|
<span
|
||||||
@ -382,7 +382,7 @@ const Franchisees = () => {
|
|||||||
className={
|
className={
|
||||||
!(
|
!(
|
||||||
(currentPage + 1) * itemPerPage - itemPerPage >
|
(currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
FranchiseesData.length - 1
|
BusinessesData.length - 1
|
||||||
)
|
)
|
||||||
? 'paginate_button page-item next'
|
? 'paginate_button page-item next'
|
||||||
: 'paginate_button page-item next disabled'
|
: 'paginate_button page-item next disabled'
|
||||||
@ -410,4 +410,4 @@ const Franchisees = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Franchisees
|
export default Businesses
|
@ -7,7 +7,7 @@ import swal from 'sweetalert'
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { isAutheticated } from 'src/auth'
|
import { isAutheticated } from 'src/auth'
|
||||||
|
|
||||||
const EditFranchisee = () => {
|
const EditBusiness = () => {
|
||||||
|
|
||||||
|
|
||||||
const [WebsiteURL, setWebsiteURL] = useState('https://reinventuniforms.in/')
|
const [WebsiteURL, setWebsiteURL] = useState('https://reinventuniforms.in/')
|
||||||
@ -531,4 +531,4 @@ const EditFranchisee = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default EditFranchisee
|
export default EditBusiness
|
153
src/views/configuration/Business/AddBusiness.js
Normal file
153
src/views/configuration/Business/AddBusiness.js
Normal 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
|
345
src/views/configuration/Business/Business.js
Normal file
345
src/views/configuration/Business/Business.js
Normal 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
|
172
src/views/configuration/Business/EditLanguage.js
Normal file
172
src/views/configuration/Business/EditLanguage.js
Normal 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
|
168
src/views/configuration/Language/AddLanguage.js
Normal file
168
src/views/configuration/Language/AddLanguage.js
Normal 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
|
172
src/views/configuration/Language/EditLanguage.js
Normal file
172
src/views/configuration/Language/EditLanguage.js
Normal 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
|
346
src/views/configuration/Language/Languages.js
Normal file
346
src/views/configuration/Language/Languages.js
Normal 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
|
406
src/views/configuration/Policies/Policies.js
Normal file
406
src/views/configuration/Policies/Policies.js
Normal 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
|
@ -10,59 +10,20 @@ import { isAutheticated } from 'src/auth'
|
|||||||
const AddCity = () => {
|
const AddCity = () => {
|
||||||
const token = isAutheticated();
|
const token = isAutheticated();
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const [statesData, setStatesData] = useState([])
|
|
||||||
const [data, setData] = useState({
|
const [data, setData] = useState({
|
||||||
city_name: '',
|
purpose: '',
|
||||||
state: '',
|
|
||||||
|
|
||||||
})
|
})
|
||||||
const [loading, setLoading] = useState(false)
|
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) => {
|
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 }))
|
setData((prev) => ({ ...prev, [e.target.id]: e.target.value }))
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
if (data.city_name.trim() === '' || data.state.trim() === '') {
|
if (data.purpose.trim() === '') {
|
||||||
swal({
|
swal({
|
||||||
title: 'Warning',
|
title: 'Warning',
|
||||||
text: 'Fill all mandatory fields',
|
text: 'Fill all mandatory fields',
|
||||||
@ -74,7 +35,7 @@ const AddCity = () => {
|
|||||||
}
|
}
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
axios
|
axios
|
||||||
.post(`/api/city`, data, {
|
.post(`/api/purpose`, data, {
|
||||||
headers: {
|
headers: {
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
@ -83,12 +44,12 @@ const AddCity = () => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
swal({
|
swal({
|
||||||
title: 'Added',
|
title: 'Added',
|
||||||
text: 'City added successfully!',
|
text: 'Purpose added successfully!',
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
button: 'Return',
|
button: 'Return',
|
||||||
})
|
})
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
navigate('/cities', { replace: true })
|
navigate('/purpose', { replace: true })
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
@ -116,7 +77,7 @@ const AddCity = () => {
|
|||||||
"
|
"
|
||||||
>
|
>
|
||||||
<div style={{ fontSize: '22px' }} className="fw-bold">
|
<div style={{ fontSize: '22px' }} className="fw-bold">
|
||||||
Add City
|
Add Perpose
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: 'flex', gap: '1rem' }}>
|
<div style={{ display: 'flex', gap: '1rem' }}>
|
||||||
<h4 className="mb-0"></h4>
|
<h4 className="mb-0"></h4>
|
||||||
@ -137,7 +98,7 @@ const AddCity = () => {
|
|||||||
>
|
>
|
||||||
{loading ? 'Loading' : 'Save'}
|
{loading ? 'Loading' : 'Save'}
|
||||||
</Button>
|
</Button>
|
||||||
<Link to="/cities">
|
<Link to="/purpose">
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
@ -159,23 +120,23 @@ const AddCity = () => {
|
|||||||
<div className="card h-100">
|
<div className="card h-100">
|
||||||
<div className="card-body px-5">
|
<div className="card-body px-5">
|
||||||
<div className="mb-3">
|
<div className="mb-3">
|
||||||
<label htmlFor="city_name" className="form-label">
|
<label htmlFor="purpose" className="form-label">
|
||||||
City Name*
|
Purpose *
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
id="city_name"
|
id="purpose"
|
||||||
value={data.city_name}
|
value={data.purpose}
|
||||||
maxLength="50"
|
maxLength="60"
|
||||||
onChange={(e) => handleChange(e)}
|
onChange={(e) => handleChange(e)}
|
||||||
/>
|
/>
|
||||||
<p className="pt-1 pl-2 text-secondary">
|
<p className="pt-1 pl-2 text-secondary">
|
||||||
Remaining characters : {limiter.city_nameHas}
|
Remaining characters : {50 - data.purpose.length}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-3">
|
{/* <div className="mb-3">
|
||||||
<label htmlFor="city_name" className="form-label">
|
<label htmlFor="purpose" className="form-label">
|
||||||
State Name*
|
State Name*
|
||||||
</label>
|
</label>
|
||||||
<select
|
<select
|
||||||
@ -197,7 +158,7 @@ const AddCity = () => {
|
|||||||
</option>
|
</option>
|
||||||
)}
|
)}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div> */}
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
@ -7,25 +7,19 @@ import axios from 'axios'
|
|||||||
import { isAutheticated } from 'src/auth'
|
import { isAutheticated } from 'src/auth'
|
||||||
|
|
||||||
|
|
||||||
const EditCity = () => {
|
const EditPurpose = () => {
|
||||||
const id = useParams()?.id
|
const id = useParams()?.id
|
||||||
const token = isAutheticated();
|
const token = isAutheticated();
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const [statesData, setStatesData] = useState([])
|
|
||||||
const [data, setData] = useState({
|
const [data, setData] = useState({
|
||||||
city_name: '',
|
purpose: '',
|
||||||
state: '',
|
|
||||||
|
|
||||||
})
|
})
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [limiter, setLimiter] = useState({
|
|
||||||
city_name: 30,
|
|
||||||
city_nameHas: 30,
|
|
||||||
})
|
|
||||||
|
|
||||||
const getCategory = () => {
|
const getCategory = () => {
|
||||||
axios
|
axios
|
||||||
.get(`$/api/city/${id}`, {
|
.get(`/api/purpose/${id}`, {
|
||||||
headers: {
|
headers: {
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
@ -36,22 +30,10 @@ const EditCity = () => {
|
|||||||
...prev,
|
...prev,
|
||||||
...res.data?.data,
|
...res.data?.data,
|
||||||
}))
|
}))
|
||||||
setLimiter((prev) => ({
|
|
||||||
...prev,
|
|
||||||
city_nameHas: prev.city_name - res.data?.data?.city_name.length,
|
|
||||||
}))
|
|
||||||
})
|
})
|
||||||
.catch((err) => { })
|
.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(() => {
|
useEffect(() => {
|
||||||
@ -59,18 +41,12 @@ const EditCity = () => {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const handleChange = (e) => {
|
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 }))
|
setData((prev) => ({ ...prev, [e.target.id]: e.target.value }))
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
if (data.city_name.trim() === '' || data.state.trim() === '') {
|
if (data.purpose.trim() === '') {
|
||||||
swal({
|
swal({
|
||||||
title: 'Warning',
|
title: 'Warning',
|
||||||
text: 'Fill all mandatory fields',
|
text: 'Fill all mandatory fields',
|
||||||
@ -82,7 +58,7 @@ const EditCity = () => {
|
|||||||
}
|
}
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
axios
|
axios
|
||||||
.patch(`/api/city/${id}`, data, {
|
.patch(`/api/purpose/${id}`, data, {
|
||||||
headers: {
|
headers: {
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
@ -91,12 +67,12 @@ const EditCity = () => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
swal({
|
swal({
|
||||||
title: 'Updated',
|
title: 'Updated',
|
||||||
text: 'City updated successfully!',
|
text: 'Purpose updated successfully!',
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
button: 'Close',
|
button: 'Close',
|
||||||
})
|
})
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
navigate('/cities', { replace: true })
|
navigate('/purpose', { replace: true })
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
@ -123,7 +99,7 @@ const EditCity = () => {
|
|||||||
"
|
"
|
||||||
>
|
>
|
||||||
<div style={{ fontSize: '22px' }} className="fw-bold">
|
<div style={{ fontSize: '22px' }} className="fw-bold">
|
||||||
Edit City
|
Edit Purpose
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: 'flex', gap: '1rem' }}>
|
<div style={{ display: 'flex', gap: '1rem' }}>
|
||||||
<h4 className="mb-0"></h4>
|
<h4 className="mb-0"></h4>
|
||||||
@ -144,7 +120,7 @@ const EditCity = () => {
|
|||||||
>
|
>
|
||||||
{loading ? 'Loading' : 'Update'}
|
{loading ? 'Loading' : 'Update'}
|
||||||
</Button>
|
</Button>
|
||||||
<Link to="/cities">
|
<Link to="/purpose">
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
@ -166,45 +142,23 @@ const EditCity = () => {
|
|||||||
<div className="card h-100">
|
<div className="card h-100">
|
||||||
<div className="card-body px-5">
|
<div className="card-body px-5">
|
||||||
<div className="mb-3">
|
<div className="mb-3">
|
||||||
<label htmlFor="city_name" className="form-label">
|
<label htmlFor="purpose" className="form-label">
|
||||||
City Name*
|
Purpose Name*
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
id="city_name"
|
id="purpose"
|
||||||
value={data.city_name}
|
|
||||||
maxLength={limiter.city_name}
|
value={data.purpose}
|
||||||
|
maxLength='50'
|
||||||
onChange={(e) => handleChange(e)}
|
onChange={(e) => handleChange(e)}
|
||||||
/>
|
/>
|
||||||
<p className="pt-1 pl-2 text-secondary">
|
<p className="pt-1 pl-2 text-secondary">
|
||||||
Remaining characters : {limiter.city_nameHas}
|
Remaining characters : {50 - data.purpose.length}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</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">
|
{/* <div className="mb-3">
|
||||||
<label>Unique ID</label>
|
<label>Unique ID</label>
|
||||||
<input type="text" value={data._id} className="form-control" disabled />
|
<input type="text" value={data._id} className="form-control" disabled />
|
||||||
@ -226,4 +180,4 @@ const EditCity = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default EditCity
|
export default EditPurpose
|
@ -25,7 +25,7 @@ const Cities = () => {
|
|||||||
|
|
||||||
const getCategories = () => {
|
const getCategories = () => {
|
||||||
axios
|
axios
|
||||||
.get(`/api/city`, {
|
.get(`/api/purpose`, {
|
||||||
headers: { 'Access-Control-Allow-Origin': '*', Authorization: `Bearer ${token}` },
|
headers: { 'Access-Control-Allow-Origin': '*', Authorization: `Bearer ${token}` },
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@ -59,7 +59,7 @@ const Cities = () => {
|
|||||||
}).then((value) => {
|
}).then((value) => {
|
||||||
if (value === true) {
|
if (value === true) {
|
||||||
axios
|
axios
|
||||||
.delete(`/api/city/${id}`, {
|
.delete(`/api/purpose/${id}`, {
|
||||||
headers: {
|
headers: {
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
@ -96,11 +96,11 @@ const Cities = () => {
|
|||||||
"
|
"
|
||||||
>
|
>
|
||||||
<div style={{ fontSize: '22px' }} className="fw-bold">
|
<div style={{ fontSize: '22px' }} className="fw-bold">
|
||||||
Cities
|
Purpose
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="page-title-right">
|
<div className="page-title-right">
|
||||||
<Link to="/cities/add">
|
<Link to="/purpose/add">
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="primary"
|
color="primary"
|
||||||
@ -110,7 +110,7 @@ const Cities = () => {
|
|||||||
textTransform: 'capitalize',
|
textTransform: 'capitalize',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Add City
|
Add Purpose
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
@ -154,8 +154,8 @@ const Cities = () => {
|
|||||||
>
|
>
|
||||||
<thead className="thead" style={{ background: 'rgb(140, 213, 213)' }}>
|
<thead className="thead" style={{ background: 'rgb(140, 213, 213)' }}>
|
||||||
<tr>
|
<tr>
|
||||||
<th className="text-start">City Name</th>
|
<th className="text-start">Purpose</th>
|
||||||
<th className="text-start">State Name</th>
|
|
||||||
<th className="text-start">Created On</th>
|
<th className="text-start">Created On</th>
|
||||||
<th className="text-start">Actions</th>
|
<th className="text-start">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -175,13 +175,13 @@ const Cities = () => {
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
) : (
|
) : (
|
||||||
showData.map((city, i) => {
|
showData.map((purpose, i) => {
|
||||||
return (
|
return (
|
||||||
<tr key={i}>
|
<tr key={i}>
|
||||||
<td className="text-start">{city.city_name}</td>
|
<td className="text-start">{purpose.purpose}</td>
|
||||||
<td className="text-start">{city.state?.state_name}</td>
|
{/* <td className="text-start">{purpose.state?.state_name}</td> */}
|
||||||
<td className="text-start">
|
<td className="text-start">
|
||||||
{new Date(city.createdAt).toLocaleString('en-IN', {
|
{new Date(purpose.createdAt).toLocaleString('en-IN', {
|
||||||
weekday: 'short',
|
weekday: 'short',
|
||||||
month: 'short',
|
month: 'short',
|
||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
@ -193,7 +193,7 @@ const Cities = () => {
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td className="text-start">
|
<td className="text-start">
|
||||||
<Link to={`/cities/edit/${city._id}`}>
|
<Link to={`/purpose/edit/${purpose._id}`}>
|
||||||
<button
|
<button
|
||||||
style={{ color: 'white', margin: '0 1rem' }}
|
style={{ color: 'white', margin: '0 1rem' }}
|
||||||
type="button"
|
type="button"
|
||||||
@ -224,7 +224,7 @@ const Cities = () => {
|
|||||||
|
|
||||||
"
|
"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
handleDelete(city._id)
|
handleDelete(purpose._id)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Delete
|
Delete
|
@ -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 Jatin Mor Admin Dashboard Account.</p>
|
<p className="text-medium-emphasis">Sign In to Your Bolo 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