address commit
This commit is contained in:
parent
88797f7050
commit
e7f53a9dc4
@ -39,6 +39,7 @@
|
|||||||
"@coreui/react": "^4.3.0",
|
"@coreui/react": "^4.3.0",
|
||||||
"@coreui/react-chartjs": "^2.0.0",
|
"@coreui/react-chartjs": "^2.0.0",
|
||||||
"@coreui/utils": "^1.3.1",
|
"@coreui/utils": "^1.3.1",
|
||||||
|
"@material-ui/core": "^4.12.4",
|
||||||
"@reduxjs/toolkit": "^1.8.2",
|
"@reduxjs/toolkit": "^1.8.2",
|
||||||
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.5",
|
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.5",
|
||||||
"axios": "^0.25.0",
|
"axios": "^0.25.0",
|
||||||
@ -50,14 +51,14 @@
|
|||||||
"enzyme": "^3.11.0",
|
"enzyme": "^3.11.0",
|
||||||
"file-saver": "^2.0.5",
|
"file-saver": "^2.0.5",
|
||||||
"prop-types": "^15.7.2",
|
"prop-types": "^15.7.2",
|
||||||
"react": "^17.0.2",
|
"react": "18.2",
|
||||||
"react-app-polyfill": "^2.0.0",
|
"react-app-polyfill": "^2.0.0",
|
||||||
"react-date-picker": "^8.4.0",
|
"react-date-picker": "^8.4.0",
|
||||||
"react-datepicker": "^4.8.0",
|
"react-datepicker": "^4.8.0",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
"react-paginate": "^8.1.3",
|
"react-paginate": "^8.1.3",
|
||||||
"react-redux": "^7.2.6",
|
"react-redux": "^7.2.6",
|
||||||
"react-router-dom": "^5.3.0",
|
"react-router-dom": "^6.7.0",
|
||||||
"react-spinners": "^0.11.0",
|
"react-spinners": "^0.11.0",
|
||||||
"react-time-picker": "^4.5.0",
|
"react-time-picker": "^4.5.0",
|
||||||
"redux": "4.1.2",
|
"redux": "4.1.2",
|
||||||
|
41
src/App.js
41
src/App.js
@ -1,6 +1,6 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component, Suspense } from 'react'
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { BrowserRouter, Route, Switch } from 'react-router-dom'
|
import { Router, Route, Routes, HashRouter } from 'react-router-dom'
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import './scss/style.scss'
|
import './scss/style.scss'
|
||||||
import ForgotPassword from './views/pages/register/ForgotPassword'
|
import ForgotPassword from './views/pages/register/ForgotPassword'
|
||||||
@ -14,7 +14,7 @@ const loading = (
|
|||||||
<div className="sk-spinner sk-spinner-pulse"></div>
|
<div className="sk-spinner sk-spinner-pulse"></div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
// import EditProducts from './views/Commerce/Editproducts'
|
||||||
// Containers
|
// Containers
|
||||||
const DefaultLayout = React.lazy(() => import('./layout/DefaultLayout'))
|
const DefaultLayout = React.lazy(() => import('./layout/DefaultLayout'))
|
||||||
|
|
||||||
@ -64,31 +64,26 @@ const App = () => {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BrowserRouter>
|
|
||||||
<React.Suspense fallback={loading}>
|
|
||||||
<Switch>
|
|
||||||
< Route exact path="/" name="Login Page" render={(props) => <Login {...props} />} />
|
|
||||||
|
|
||||||
<Route exact path="/forgot" name="Forgot Page" render={(props) => <ForgotPassword {...props} />} />
|
<HashRouter>
|
||||||
<Route exact path="/register" name="Register Page" render={(props) => <NewRegister {...props} />} />
|
<Suspense fallback={loading}>
|
||||||
|
<Routes>
|
||||||
|
<Route exact path="/" name="Login Page" element={<Login />} />
|
||||||
|
<Route exact path="/register" name="Register Page" element={<NewRegister />} />
|
||||||
|
<Route exact path="/password/forgot" name="Forgot Page" element={<ForgotPassword />} />
|
||||||
|
<Route exact path="/404" name="Page 404" element={<Page404 />} />
|
||||||
|
<Route exact path="/500" name="Page 500" element={<Page500 />} />
|
||||||
|
|
||||||
<Route exact path="/404" name="Page 404" render={(props) => <Page404 {...props} />} />
|
<Route path="/" name="Home" element={userdata?.role === "admin" ? <DefaultLayout />
|
||||||
<Route exact path="/500" name="Page 500" render={(props) => <Page500 {...props} />} />
|
:
|
||||||
|
userdata === false ? <Login /> : <div></div>} />
|
||||||
|
|
||||||
|
|
||||||
|
<Route path="*" name="Home" element={<DefaultLayout />} />
|
||||||
|
</Routes>
|
||||||
|
</Suspense>
|
||||||
|
</HashRouter>
|
||||||
|
|
||||||
<Route path="/" name="Home" render={(props) => (
|
|
||||||
userdata?.role === "admin" ? <DefaultLayout {...props} /> :
|
|
||||||
userdata === false ? <Login {...props} /> : <div></div>
|
|
||||||
)} />
|
|
||||||
|
|
||||||
<Route path="/" name="Home" render={(props) => <DefaultLayout {...props} />} />
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</Switch>
|
|
||||||
</React.Suspense>
|
|
||||||
</BrowserRouter>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
export default App
|
export default App
|
||||||
|
77
src/_nav.js
77
src/_nav.js
@ -1,13 +1,17 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import CIcon from '@coreui/icons-react'
|
import CIcon from '@coreui/icons-react'
|
||||||
import {
|
import {
|
||||||
|
cilAddressBook,
|
||||||
|
cilAppsSettings,
|
||||||
cilBell,
|
cilBell,
|
||||||
cilCalculator,
|
cilCalculator,
|
||||||
cilChartPie,
|
cilChartPie,
|
||||||
|
cilCommand,
|
||||||
cilCursor,
|
cilCursor,
|
||||||
cilDrop,
|
cilDrop,
|
||||||
cilFace,
|
cilFace,
|
||||||
cilFilterSquare,
|
cilFilterSquare,
|
||||||
|
cilMedicalCross,
|
||||||
cilMoney,
|
cilMoney,
|
||||||
cilNewspaper,
|
cilNewspaper,
|
||||||
cilNotes,
|
cilNotes,
|
||||||
@ -38,6 +42,79 @@ const _nav = [
|
|||||||
icon: <CIcon icon={cilUser} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilUser} customClassName="nav-icon" />,
|
||||||
to: '/users',
|
to: '/users',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
component: CNavGroup,
|
||||||
|
name: 'Configuration',
|
||||||
|
icon: <CIcon icon={cilAppsSettings} customClassName="nav-icon" />,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
component: CNavItem,
|
||||||
|
name: 'Cities',
|
||||||
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
|
to: '/cities',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: CNavItem,
|
||||||
|
name: 'States',
|
||||||
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
|
to: '/states',
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// component: CNavItem,
|
||||||
|
// name: 'Standard Shipping',
|
||||||
|
// icon: <CIcon icon={cilCommand} customClassName="nav-icon" />,
|
||||||
|
// to: '/shipping',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// component: CNavItem,
|
||||||
|
// name: 'Custom Shipping',
|
||||||
|
// icon: <CIcon icon={cilCommand} customClassName="nav-icon" />,
|
||||||
|
// to: '/custom-shipping',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// component: CNavItem,
|
||||||
|
// name: 'Pincode',
|
||||||
|
// icon: <CIcon icon={cilCommand} customClassName="nav-icon" />,
|
||||||
|
// to: '/pincode',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// component: CNavItem,
|
||||||
|
// name: 'Tax Rates',
|
||||||
|
// icon: <CIcon icon={cilCommand} 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: 'Social Media',
|
||||||
|
icon: <CIcon icon={cilMedicalCross} customClassName="nav-icon" />,
|
||||||
|
to: '/socialmedia',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: CNavItem,
|
||||||
|
name: 'Address',
|
||||||
|
icon: <CIcon icon={cilAddressBook} customClassName="nav-icon" />,
|
||||||
|
to: '/address',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: CNavItem,
|
||||||
|
name: 'Logos',
|
||||||
|
icon: <CIcon icon={cilCommand} customClassName="nav-icon" />,
|
||||||
|
to: '/logo',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React, { Suspense } from 'react'
|
import React, { Suspense } from 'react'
|
||||||
import { Redirect, Route, Switch } from 'react-router-dom'
|
import { Navigate, Route, Routes } from 'react-router-dom'
|
||||||
import { CContainer, CSpinner } from '@coreui/react'
|
import { CContainer, CSpinner } from '@coreui/react'
|
||||||
|
|
||||||
// routes config
|
// routes config
|
||||||
@ -9,26 +9,22 @@ const AppContent = () => {
|
|||||||
return (
|
return (
|
||||||
<CContainer lg>
|
<CContainer lg>
|
||||||
<Suspense fallback={<CSpinner color="primary" />}>
|
<Suspense fallback={<CSpinner color="primary" />}>
|
||||||
<Switch>
|
<Routes>
|
||||||
{routes.map((route, idx) => {
|
{routes.map((route, idx) => {
|
||||||
return (
|
return (
|
||||||
route.component && (
|
route.element && (
|
||||||
<Route
|
<Route
|
||||||
key={idx}
|
key={idx}
|
||||||
path={route.path}
|
path={route.path}
|
||||||
exact={route.exact}
|
exact={route.exact}
|
||||||
name={route.name}
|
name={route.name}
|
||||||
render={(props) => (
|
element={<route.element />}
|
||||||
<>
|
|
||||||
<route.component {...props} />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
<Redirect from="/" to="/dashboard" />
|
<Route path="/" element={<Navigate to="dashboard" replace />} />
|
||||||
</Switch>
|
</Routes>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</CContainer>
|
</CContainer>
|
||||||
)
|
)
|
||||||
|
@ -6,7 +6,7 @@ const AppFooter = () => {
|
|||||||
<CFooter>
|
<CFooter>
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<span className="ms-1">{new Date().getFullYear()} ©ATP.</span>
|
<span className="ms-1">{new Date().getFullYear()} © Any Time Prasad ( ATP ) .</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</CFooter>
|
</CFooter>
|
||||||
|
@ -32,12 +32,12 @@ const AppHeader = () => {
|
|||||||
<CIcon icon={cilMenu} size="lg" />
|
<CIcon icon={cilMenu} size="lg" />
|
||||||
</CHeaderToggler>
|
</CHeaderToggler>
|
||||||
<CHeaderBrand className="mx-auto d-md-none" to="/">
|
<CHeaderBrand className="mx-auto d-md-none" to="/">
|
||||||
<h1>ATP</h1>
|
<h3>Any Time Prasad</h3>
|
||||||
</CHeaderBrand>
|
</CHeaderBrand>
|
||||||
<CHeaderNav className="d-none d-md-flex me-auto">
|
<CHeaderNav className="d-none d-md-flex me-auto">
|
||||||
<CNavItem>
|
<CNavItem>
|
||||||
<CNavLink to="/dashboard" component={NavLink} activeClassName="active">
|
<CNavLink to="/dashboard" component={NavLink} activeClassName="active">
|
||||||
Dashboard
|
ATP Dashboard
|
||||||
</CNavLink>
|
</CNavLink>
|
||||||
</CNavItem>
|
</CNavItem>
|
||||||
{/* <CNavItem>
|
{/* <CNavItem>
|
||||||
|
@ -31,7 +31,7 @@ const AppSidebar = () => {
|
|||||||
>
|
>
|
||||||
<CSidebarBrand className="d-none bg-info d-md-flex" to="/">
|
<CSidebarBrand className="d-none bg-info d-md-flex" to="/">
|
||||||
{/* <CIcon className="sidebar-brand-full" icon={logoNegative} height={35} /> */}
|
{/* <CIcon className="sidebar-brand-full" icon={logoNegative} height={35} /> */}
|
||||||
<h1>ATP</h1>
|
<h2>ATP Dashboard</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>
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import React, { useEffect, useState, } from "react";
|
import React, { useEffect, useState, } from "react";
|
||||||
import { useHistory } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
const ProtectedRoute = (props) => {
|
const ProtectedRoute = (props) => {
|
||||||
let Cmp = props;
|
let Cmp = props;
|
||||||
const history = useHistory();
|
const history = useNavigate();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!localStorage.getItem('authToken'))
|
if (!localStorage.getItem('authToken'))
|
||||||
history.push('/')
|
history('/')
|
||||||
}, [])
|
}, [])
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -27,7 +27,7 @@ import swal from 'sweetalert';
|
|||||||
import userImage from './../../assets/images/avatars/1.jpg'
|
import userImage from './../../assets/images/avatars/1.jpg'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
// import { signout } from 'src/auth'
|
// import { signout } from 'src/auth'
|
||||||
import { useHistory } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
@ -35,11 +35,11 @@ import { useState } from 'react';
|
|||||||
|
|
||||||
const AppHeaderDropdown = () => {
|
const AppHeaderDropdown = () => {
|
||||||
const [userData, setUserData] = useState()
|
const [userData, setUserData] = useState()
|
||||||
let history = useHistory();
|
let history = useNavigate();
|
||||||
const signout = async () => {
|
const signout = async () => {
|
||||||
localStorage.removeItem('authToken')
|
localStorage.removeItem('authToken')
|
||||||
swal("success!", "Logged Out", "success");
|
swal("success!", "Logged Out", "success");
|
||||||
history.push("/");
|
history("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
//for user image
|
//for user image
|
||||||
|
@ -8,24 +8,54 @@ const Change_Password = React.lazy(() => import('./views/pages/register/Change_p
|
|||||||
import Profile from './views/Profile/Profile'
|
import Profile from './views/Profile/Profile'
|
||||||
import EditProfile from './views/Profile/EditProfile'
|
import EditProfile from './views/Profile/EditProfile'
|
||||||
const Dashboard = React.lazy(() => import('./views/dashboard/Dashboard'))
|
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'
|
||||||
|
//states
|
||||||
|
import EditState from './views/configuration/states/EditStates.js'
|
||||||
|
import AddState from './views/configuration/states/AddState.js'
|
||||||
|
import States from './views/configuration/states/States.js'
|
||||||
|
//social media,address,logo
|
||||||
|
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'
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
|
|
||||||
{ path: '/', exact: true, name: 'Home' },
|
{ path: '/', exact: true, name: 'Home' },
|
||||||
{ path: '/change_password', name: 'Change Password', component: Change_Password },
|
{ path: '/change_password', name: 'Change Password', element: Change_Password },
|
||||||
{ path: '/profile/edit', name: 'Edit Profile', component: EditProfile },
|
{ path: '/profile/edit', name: 'Edit Profile', element: EditProfile },
|
||||||
// { path: '/profile', name: 'Profile', component: Profile },
|
// { path: '/profile', name: 'Profile', element: Profile },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//dashboard
|
//dashboard
|
||||||
|
|
||||||
{ path: '/dashboard', name: 'Dashboard', component: Dashboard },
|
{ path: '/dashboard', name: 'Dashboard', element: Dashboard },
|
||||||
|
|
||||||
|
//------------settings------------------------//
|
||||||
|
//cities
|
||||||
|
{ path: '/cities', name: 'Cities', element: Cities },
|
||||||
|
{ path: '/cities/add', name: 'Add City', element: AddCity },
|
||||||
|
{ path: '/cities/edit/:id', name: 'Edit City', element: EditCity },
|
||||||
|
//states
|
||||||
|
{ path: '/states', name: 'States', element: States },
|
||||||
|
{ path: '/states/add', name: 'Add State', element: AddState },
|
||||||
|
{ path: '/states/edit/:id', name: 'Edit State', element: EditState },
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
{ path: '/socialmedia', name: 'Social Media', element: Socialmedia },
|
||||||
|
{ path: '/address', name: 'Address', element: Address },
|
||||||
|
{ path: '/logo', name: 'Logo', element: Logo },
|
||||||
|
// -------------------------------------------//
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
export default routes
|
export default routes
|
||||||
|
@ -3,7 +3,7 @@ import { CForm, CCol, CFormLabel, CContainer, CRow, CCardGroup, CCard, CCardBody
|
|||||||
|
|
||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { useHistory } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
import { isAutheticated } from 'src/auth'
|
import { isAutheticated } from 'src/auth'
|
||||||
|
|
||||||
const EditProfile = () => {
|
const EditProfile = () => {
|
||||||
@ -19,7 +19,7 @@ const EditProfile = () => {
|
|||||||
phone: ''
|
phone: ''
|
||||||
|
|
||||||
})
|
})
|
||||||
const history = useHistory()
|
const history = useNavigate()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ const EditProfile = () => {
|
|||||||
icon: 'success',
|
icon: 'success',
|
||||||
button: 'Return',
|
button: 'Return',
|
||||||
})
|
})
|
||||||
history.goBack()
|
history(-1)
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -19,13 +19,13 @@ import {
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { isAutheticated } from 'src/auth';
|
import { isAutheticated } from 'src/auth';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
const Profile = () => {
|
const Profile = () => {
|
||||||
// const user = JSON.parse(localStorage.getItem('auth')).user
|
// const user = JSON.parse(localStorage.getItem('auth')).user
|
||||||
const [user, setUser] = useState({});
|
const [user, setUser] = useState({});
|
||||||
const { token } = isAutheticated();
|
const { token } = isAutheticated();
|
||||||
const history = useHistory()
|
const history = useNavigate()
|
||||||
// console.log(token);
|
// console.log(token);
|
||||||
useEffect(async () => {
|
useEffect(async () => {
|
||||||
let res = await axios.get('/owner', {
|
let res = await axios.get('/owner', {
|
||||||
@ -51,7 +51,7 @@ const Profile = () => {
|
|||||||
</CCol>
|
</CCol>
|
||||||
<CCol>
|
<CCol>
|
||||||
<CButton color='dark'
|
<CButton color='dark'
|
||||||
className="float-right" onClick={() => history.push('/edit')}>Edit Profile</CButton>
|
className="float-right" onClick={() => history('/edit')}>Edit Profile</CButton>
|
||||||
</CCol>
|
</CCol>
|
||||||
</CRow>
|
</CRow>
|
||||||
<CCard className="p-4">
|
<CCard className="p-4">
|
||||||
|
292
src/views/configuration/Address.js
Normal file
292
src/views/configuration/Address.js
Normal file
@ -0,0 +1,292 @@
|
|||||||
|
import axios from 'axios'
|
||||||
|
import React, { useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
import ClipLoader from 'react-spinners/ClipLoader'
|
||||||
|
import { Link } from 'react-router-dom'
|
||||||
|
import swal from 'sweetalert'
|
||||||
|
import { isAutheticated } from 'src/auth'
|
||||||
|
|
||||||
|
function Address() {
|
||||||
|
const token = isAutheticated()
|
||||||
|
const [loading, setLoading] = useState(false)
|
||||||
|
const [company, setCompany] = useState('')
|
||||||
|
const [address, setAddress] = useState('')
|
||||||
|
const [city, setCity] = useState('')
|
||||||
|
const [state, setState] = useState('')
|
||||||
|
const [country, setCountry] = useState('')
|
||||||
|
const [pincode, setPincode] = useState('')
|
||||||
|
const [website, setWebsite] = useState('')
|
||||||
|
const [contact, setContact] = useState('')
|
||||||
|
const [email, setEmail] = useState('')
|
||||||
|
const [gstin, setGSTIN] = useState('')
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
async function getConfiguration() {
|
||||||
|
const configDetails = await axios.get(`/api/config`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
configDetails.data.result.map((item) => {
|
||||||
|
item.address.map((el) => {
|
||||||
|
setCompany(el.company)
|
||||||
|
setAddress(el.address)
|
||||||
|
setCity(el.city)
|
||||||
|
setState(el.state)
|
||||||
|
setCountry(el.country)
|
||||||
|
setPincode(el.pincode)
|
||||||
|
setWebsite(el.website)
|
||||||
|
setContact(el.contact)
|
||||||
|
setEmail(el.email)
|
||||||
|
setGSTIN(el?.gstin)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
getConfiguration()
|
||||||
|
}, [])
|
||||||
|
async function handelChange(e) {
|
||||||
|
if (e.target.name.toLowerCase() === 'address') {
|
||||||
|
setAddress(e.target.value)
|
||||||
|
} else if (e.target.name.toLowerCase() === 'company name') {
|
||||||
|
setCompany(e.target.value)
|
||||||
|
} else if (e.target.name.toLowerCase() === 'city') {
|
||||||
|
setCity(e.target.value)
|
||||||
|
} else if (e.target.name.toLowerCase() === 'state') {
|
||||||
|
setState(e.target.value)
|
||||||
|
} else if (e.target.name.toLowerCase() === 'country') {
|
||||||
|
setCountry(e.target.value)
|
||||||
|
} else if (e.target.name.toLowerCase() === 'pincode') {
|
||||||
|
setPincode(e.target.value)
|
||||||
|
} else if (e.target.name.toLowerCase() === 'website') {
|
||||||
|
setWebsite(e.target.value)
|
||||||
|
} else if (e.target.name.toLowerCase() === 'contact number') {
|
||||||
|
setContact(e.target.value)
|
||||||
|
} else if (e.target.name.toLowerCase() === 'email') {
|
||||||
|
setEmail(e.target.value)
|
||||||
|
} else if (e.target.name.toLowerCase() === 'gstin') {
|
||||||
|
setGSTIN(e.target.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function handelSubmit() {
|
||||||
|
if (!/^[0-9A-Za-z]{15}$/.test(gstin)) return swal('Warning!', 'Enter valid GSTIN')
|
||||||
|
setLoading(true)
|
||||||
|
let data = {
|
||||||
|
company,
|
||||||
|
address,
|
||||||
|
city,
|
||||||
|
state,
|
||||||
|
country,
|
||||||
|
pincode,
|
||||||
|
website,
|
||||||
|
contact,
|
||||||
|
email,
|
||||||
|
gstin,
|
||||||
|
}
|
||||||
|
let res = await axios.post(`/api/config/address`, data, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
setLoading(false)
|
||||||
|
console.log(res)
|
||||||
|
swal('Success!', res.data.message, res.data.status)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="main-content">
|
||||||
|
<div className="page-content">
|
||||||
|
<div className="container-fluid">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-lg-12">
|
||||||
|
<div className="card">
|
||||||
|
<div className="card-body">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-md-12 col-lg-6 col-xl-6">
|
||||||
|
<h1 className="text-left head-small">Address</h1>
|
||||||
|
|
||||||
|
<form>
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-lg-12">
|
||||||
|
<div className="form-group">
|
||||||
|
<>
|
||||||
|
<label
|
||||||
|
htmlFor="basicpill-phoneno-input"
|
||||||
|
className="label-100 mt-3"
|
||||||
|
>
|
||||||
|
Company Name
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="company name"
|
||||||
|
value={company}
|
||||||
|
onChange={(e) => handelChange(e)}
|
||||||
|
className="form-control input-field "
|
||||||
|
id="basicpill-phoneno-input"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
htmlFor="basicpill-phoneno-input"
|
||||||
|
className="label-100 mt-3"
|
||||||
|
>
|
||||||
|
Address
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
value={address}
|
||||||
|
type="text"
|
||||||
|
name="address"
|
||||||
|
onChange={(e) => handelChange(e)}
|
||||||
|
className="form-control input-field "
|
||||||
|
id="basicpill-phoneno-input"
|
||||||
|
/>{' '}
|
||||||
|
<label
|
||||||
|
htmlFor="basicpill-phoneno-input"
|
||||||
|
className="label-100 mt-3"
|
||||||
|
>
|
||||||
|
City
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
value={city}
|
||||||
|
type="text"
|
||||||
|
name="city"
|
||||||
|
onChange={(e) => handelChange(e)}
|
||||||
|
className="form-control input-field "
|
||||||
|
id="basicpill-phoneno-input"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
htmlFor="basicpill-phoneno-input"
|
||||||
|
className="label-100 mt-3"
|
||||||
|
>
|
||||||
|
State
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
value={state}
|
||||||
|
type="text"
|
||||||
|
name="state"
|
||||||
|
onChange={(e) => handelChange(e)}
|
||||||
|
className="form-control input-field "
|
||||||
|
id="basicpill-phoneno-input"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
htmlFor="basicpill-phoneno-input"
|
||||||
|
className="label-100 mt-3"
|
||||||
|
>
|
||||||
|
Country
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
value={country}
|
||||||
|
type="text"
|
||||||
|
name="country"
|
||||||
|
onChange={(e) => handelChange(e)}
|
||||||
|
className="form-control input-field "
|
||||||
|
id="basicpill-phoneno-input"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
htmlFor="basicpill-phoneno-input"
|
||||||
|
className="label-100 mt-3"
|
||||||
|
>
|
||||||
|
Pin Code
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
value={pincode}
|
||||||
|
type="text"
|
||||||
|
name="pincode"
|
||||||
|
onChange={(e) => handelChange(e)}
|
||||||
|
className="form-control input-field "
|
||||||
|
id="basicpill-phoneno-input"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
htmlFor="basicpill-phoneno-input"
|
||||||
|
className="label-100 mt-3"
|
||||||
|
>
|
||||||
|
GSTIN
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
value={gstin}
|
||||||
|
type="text"
|
||||||
|
name="gstin"
|
||||||
|
onChange={(e) => handelChange(e)}
|
||||||
|
className="form-control input-field "
|
||||||
|
id="basicpill-phoneno-input"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
htmlFor="basicpill-phoneno-input"
|
||||||
|
className="label-100 mt-3"
|
||||||
|
>
|
||||||
|
Website
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
value={website}
|
||||||
|
type="text"
|
||||||
|
name="website"
|
||||||
|
onChange={(e) => handelChange(e)}
|
||||||
|
className="form-control input-field "
|
||||||
|
id="basicpill-phoneno-input"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
htmlFor="basicpill-phoneno-input"
|
||||||
|
className="label-100 mt-3"
|
||||||
|
>
|
||||||
|
Contact Number
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
value={contact}
|
||||||
|
type="text"
|
||||||
|
name="contact number"
|
||||||
|
onChange={(e) => handelChange(e)}
|
||||||
|
className="form-control input-field "
|
||||||
|
id="basicpill-phoneno-input"
|
||||||
|
/>{' '}
|
||||||
|
<label
|
||||||
|
htmlFor="basicpill-phoneno-input"
|
||||||
|
className="label-100 mt-3"
|
||||||
|
>
|
||||||
|
Email
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
value={email}
|
||||||
|
type="text"
|
||||||
|
name="email"
|
||||||
|
onChange={(e) => handelChange(e)}
|
||||||
|
className="form-control input-field "
|
||||||
|
id="basicpill-phoneno-input"
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="row mt-2">
|
||||||
|
<div className="col-lg-12">
|
||||||
|
<div className="form-group text-left">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={handelSubmit}
|
||||||
|
className="btn btn-success btn-login waves-effect waves-light mr-3 pt-2 pb-2 pr-4 pl-4"
|
||||||
|
>
|
||||||
|
<ClipLoader loading={loading} size={18} />
|
||||||
|
{!loading && 'Save'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* <!-- end table-responsive --> */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* <!-- container-fluid --> */}
|
||||||
|
</div>
|
||||||
|
{/* <!-- End Page-content --> */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Address
|
219
src/views/configuration/Logo.js
Normal file
219
src/views/configuration/Logo.js
Normal file
@ -0,0 +1,219 @@
|
|||||||
|
import React, { useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
import swal from 'sweetalert'
|
||||||
|
import ClipLoader from 'react-spinners/ClipLoader'
|
||||||
|
import { Link } from 'react-router-dom'
|
||||||
|
import axios from 'axios'
|
||||||
|
import { isAutheticated } from 'src/auth'
|
||||||
|
|
||||||
|
function Logo() {
|
||||||
|
const [loading, setLoading] = useState(false)
|
||||||
|
const [Headerlogo, setHeaderlogo] = useState('')
|
||||||
|
const [Footerlogo, setFooterlogo] = useState('')
|
||||||
|
const [Adminlogo, setAdminlogo] = useState('')
|
||||||
|
const [display, setDisplay] = useState(true)
|
||||||
|
const token = isAutheticated()
|
||||||
|
|
||||||
|
// urlcreated images
|
||||||
|
|
||||||
|
const [HeaderlogoUrl, setHeaderlogoUrl] = useState('')
|
||||||
|
const [FooterlogoUrl, setFooterlogoUrl] = useState('')
|
||||||
|
const [AdminlogoUrl, setAdminlogoUrl] = useState('')
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
async function getConfiguration() {
|
||||||
|
const configDetails = await axios.get(`/api/config`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
configDetails.data.result.map((item) => {
|
||||||
|
setHeaderlogo(item?.logo[0]?.Headerlogo)
|
||||||
|
setFooterlogo(item?.logo[0]?.Footerlogo)
|
||||||
|
setAdminlogo(item?.logo[0].Adminlogo)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
getConfiguration()
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
// async function handelChange(e) {
|
||||||
|
// setDisplay(false);
|
||||||
|
// console.log(e.target.name === "Logo htmlFor Website Header(148 x 48 px)");
|
||||||
|
// if (e.target.name === "Logo htmlFor Website Header(148 x 48 px)") {
|
||||||
|
// console.log(e.target.files[0]);
|
||||||
|
// setHeaderlogo(e.target.files[0]);
|
||||||
|
// } else if (e.target.name === "Logo htmlFor Website Footer(148 x 48 px)") {
|
||||||
|
// setFooterlogo(e.target.files[0]);
|
||||||
|
// } else if (e.target.name === "Logo htmlFor Admin Header(148 x 48 px)") {
|
||||||
|
// setAdminlogo(e.target.files[0]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
async function handelSubmit() {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
|
const formdata = new FormData()
|
||||||
|
formdata.append('Headerlogo', Headerlogo)
|
||||||
|
formdata.append('Footerlogo', Footerlogo)
|
||||||
|
formdata.append('Adminlogo', Adminlogo)
|
||||||
|
|
||||||
|
let res = await axios.post(`/api/config/logo`, formdata, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
'Content-Type': 'multipart/formdata',
|
||||||
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if (res) {
|
||||||
|
setLoading(false)
|
||||||
|
swal('Success!', res.data.message, res.data.status)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="main-content">
|
||||||
|
<div className="page-content">
|
||||||
|
<div className="container-fluid">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-lg-12">
|
||||||
|
<div className="card">
|
||||||
|
<div className="card-body">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-md-12 col-lg-6 col-xl-6">
|
||||||
|
<h1 className="text-left head-small">Logo</h1>
|
||||||
|
|
||||||
|
<form>
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-lg-12">
|
||||||
|
<div className="form-group">
|
||||||
|
<>
|
||||||
|
<label
|
||||||
|
htmlFor="basicpill-phoneno-input"
|
||||||
|
className="label-100 mt-3"
|
||||||
|
>
|
||||||
|
Logo htmlFor Website Header(148 x 48 px)
|
||||||
|
</label>
|
||||||
|
<div>
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
name="Logo htmlFor Website Header(148 x 48 px)"
|
||||||
|
onChange={(e) => {
|
||||||
|
setHeaderlogo(e.target.files[0])
|
||||||
|
if (e.target.files && e.target.files[0]) {
|
||||||
|
setHeaderlogoUrl({
|
||||||
|
image: URL.createObjectURL(e.target.files[0]),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="form-control input-field col-md-6 d-inline-block"
|
||||||
|
id="basicpill-phoneno-input"
|
||||||
|
/>
|
||||||
|
{display ? (
|
||||||
|
<img
|
||||||
|
style={{ width: '100px' }}
|
||||||
|
src={HeaderlogoUrl.image ? HeaderlogoUrl.image : Headerlogo}
|
||||||
|
alt="header logo"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
''
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<label
|
||||||
|
htmlFor="basicpill-phoneno-input"
|
||||||
|
className="label-100 mt-3"
|
||||||
|
>
|
||||||
|
Logo htmlFor Website Footer(148 x 48 px)
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
name="Logo htmlFor Website Footer(148 x 48 px)"
|
||||||
|
onChange={(e) => {
|
||||||
|
setFooterlogo(e.target.files[0])
|
||||||
|
|
||||||
|
if (e.target.files && e.target.files[0]) {
|
||||||
|
setFooterlogoUrl({
|
||||||
|
image: URL.createObjectURL(e.target.files[0]),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="form-control input-field col-md-6 d-inline-block"
|
||||||
|
id="basicpill-phoneno-input"
|
||||||
|
/>{' '}
|
||||||
|
{display ? (
|
||||||
|
<img
|
||||||
|
style={{ width: '100px' }}
|
||||||
|
src={FooterlogoUrl.image ? FooterlogoUrl.image : Footerlogo}
|
||||||
|
alt="Footer logo"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
''
|
||||||
|
)}
|
||||||
|
<label
|
||||||
|
htmlFor="basicpill-phoneno-input"
|
||||||
|
className="label-100 mt-2 row ms-1"
|
||||||
|
>
|
||||||
|
Logo htmlFor Admin Header(148 x 48 px)
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
name="Logo htmlFor Admin Header(148 x 48 px)"
|
||||||
|
onChange={(e) => {
|
||||||
|
setAdminlogo(e.target.files[0])
|
||||||
|
|
||||||
|
if (e.target.files && e.target.files[0]) {
|
||||||
|
setAdminlogoUrl({
|
||||||
|
image: URL.createObjectURL(e.target.files[0]),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="form-control input-field col-md-6 d-inline-block"
|
||||||
|
id="basicpill-phoneno-input"
|
||||||
|
/>{' '}
|
||||||
|
{display ? (
|
||||||
|
<img
|
||||||
|
style={{ width: '100px' }}
|
||||||
|
src={AdminlogoUrl.image ? AdminlogoUrl.image : Adminlogo}
|
||||||
|
alt="Admin logo"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
''
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-lg-12">
|
||||||
|
<div className="form-group text-left">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={handelSubmit}
|
||||||
|
className="btn btn-success btn-login waves-effect waves-light mr-3 pt-2 pb-2 pr-4 pl-4"
|
||||||
|
>
|
||||||
|
<ClipLoader loading={loading} size={18} />
|
||||||
|
{!loading && 'Save'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* <!-- end table-responsive --> */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* <!-- container-fluid --> */}
|
||||||
|
</div>
|
||||||
|
{/* <!-- End Page-content --> */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Logo
|
169
src/views/configuration/Socialmedia.js
Normal file
169
src/views/configuration/Socialmedia.js
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
import React, { useEffect, useState } from 'react'
|
||||||
|
import { Link } from 'react-router-dom'
|
||||||
|
import ClipLoader from 'react-spinners/ClipLoader'
|
||||||
|
|
||||||
|
import swal from 'sweetalert'
|
||||||
|
import axios from 'axios'
|
||||||
|
import { isAutheticated } from 'src/auth'
|
||||||
|
|
||||||
|
function Socialmedia() {
|
||||||
|
const [loading, setLoading] = useState(false)
|
||||||
|
const token = isAutheticated()
|
||||||
|
const [facebook, setFacebook] = useState('')
|
||||||
|
const [instagram, setInstagram] = useState('')
|
||||||
|
const [twitter, setTwitter] = useState('')
|
||||||
|
const [linkedin, setLinkedin] = useState('')
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
async function getConfiguration() {
|
||||||
|
const configDetails = await axios.get(`/api/config`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
configDetails.data.result.map((item) => {
|
||||||
|
console.log(item.socialMedia)
|
||||||
|
setFacebook(item?.socialMedia[0]?.facebook)
|
||||||
|
setInstagram(item?.socialMedia[0]?.instagram)
|
||||||
|
setTwitter(item?.socialMedia[0]?.twitter)
|
||||||
|
setLinkedin(item?.socialMedia[0]?.linkedin)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
getConfiguration()
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
async function handelChange(e) {
|
||||||
|
if (e.target.name === 'facebook') {
|
||||||
|
setFacebook(e.target.value)
|
||||||
|
} else if (e.target.name === 'twitter') {
|
||||||
|
setTwitter(e.target.value)
|
||||||
|
} else if (e.target.name === 'instagram') {
|
||||||
|
setInstagram(e.target.value)
|
||||||
|
} else if (e.target.name === 'linkedin') {
|
||||||
|
setLinkedin(e.target.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function handelSubmit() {
|
||||||
|
setLoading(true)
|
||||||
|
let data = {
|
||||||
|
facebook,
|
||||||
|
twitter,
|
||||||
|
instagram,
|
||||||
|
linkedin,
|
||||||
|
}
|
||||||
|
let res = await axios.post(`/api/config/social`, data, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
setLoading(false)
|
||||||
|
console.log(res)
|
||||||
|
swal('Success!', res.data.message, res.data.status)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{/* <Config
|
||||||
|
heading="Social Media"
|
||||||
|
labels={["Facebook", "Twitter", "Instagram", "LinkedIn"]}
|
||||||
|
postUrl="social"
|
||||||
|
/> */}
|
||||||
|
<div className="main-content">
|
||||||
|
<div className="page-content">
|
||||||
|
<div className="container-fluid">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-lg-12">
|
||||||
|
<div className="card">
|
||||||
|
<div className="card-body">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-md-12 col-lg-6 col-xl-6">
|
||||||
|
<h1 className="text-left head-small">Social Media</h1>
|
||||||
|
|
||||||
|
<form>
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-lg-12">
|
||||||
|
<div className="form-group">
|
||||||
|
<>
|
||||||
|
<label for="basicpill-phoneno-input" className="label-100 mt-3">
|
||||||
|
Facebook
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
value={facebook}
|
||||||
|
type="text"
|
||||||
|
name="facebook"
|
||||||
|
onChange={(e) => handelChange(e)}
|
||||||
|
className="form-control input-field "
|
||||||
|
id="basicpill-phoneno-input"
|
||||||
|
/>
|
||||||
|
<label for="basicpill-phoneno-input" className="label-100 mt-3">
|
||||||
|
Twitter
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
value={twitter}
|
||||||
|
type="text"
|
||||||
|
name="twitter"
|
||||||
|
onChange={(e) => handelChange(e)}
|
||||||
|
className="form-control input-field "
|
||||||
|
id="basicpill-phoneno-input"
|
||||||
|
/>{' '}
|
||||||
|
<label for="basicpill-phoneno-input" className="label-100 mt-3">
|
||||||
|
Instagram
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
value={instagram}
|
||||||
|
type="text"
|
||||||
|
name="instagram"
|
||||||
|
onChange={(e) => handelChange(e)}
|
||||||
|
className="form-control input-field "
|
||||||
|
id="basicpill-phoneno-input"
|
||||||
|
/>{' '}
|
||||||
|
<label for="basicpill-phoneno-input" className="label-100 mt-3">
|
||||||
|
Linkedin
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
value={linkedin}
|
||||||
|
type="text"
|
||||||
|
name="linkedin"
|
||||||
|
onChange={(e) => handelChange(e)}
|
||||||
|
className="form-control input-field "
|
||||||
|
id="basicpill-phoneno-input"
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="row mt-1">
|
||||||
|
<div className="col-lg-12">
|
||||||
|
<div className="form-group text-left">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={handelSubmit}
|
||||||
|
className="btn btn-success btn-login waves-effect waves-light me-3 pt-2 pb-2 pr-4 pl-4"
|
||||||
|
>
|
||||||
|
<ClipLoader loading={loading} size={18} />
|
||||||
|
{!loading && 'Save'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* <!-- end table-responsive --> */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* <!-- container-fluid --> */}
|
||||||
|
</div>
|
||||||
|
{/* <!-- End Page-content --> */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Socialmedia
|
217
src/views/configuration/cities/AddCity.js
Normal file
217
src/views/configuration/cities/AddCity.js
Normal file
@ -0,0 +1,217 @@
|
|||||||
|
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 AddCity = () => {
|
||||||
|
const token = isAutheticated();
|
||||||
|
const navigate = useNavigate()
|
||||||
|
const [statesData, setStatesData] = useState([])
|
||||||
|
const [data, setData] = useState({
|
||||||
|
city_name: '',
|
||||||
|
state: '',
|
||||||
|
_id: 'Loading',
|
||||||
|
createdAt: new Date(),
|
||||||
|
})
|
||||||
|
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() === '') {
|
||||||
|
swal({
|
||||||
|
title: 'Warning',
|
||||||
|
text: 'Fill all mandatory fields',
|
||||||
|
icon: 'error',
|
||||||
|
button: 'Close',
|
||||||
|
dangerMode: true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setLoading(true)
|
||||||
|
axios
|
||||||
|
.post(`/api/city`, data, {
|
||||||
|
headers: {
|
||||||
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
swal({
|
||||||
|
title: 'Added',
|
||||||
|
text: 'City added successfully!',
|
||||||
|
icon: 'success',
|
||||||
|
button: 'Return',
|
||||||
|
})
|
||||||
|
setLoading(false)
|
||||||
|
navigate.push('/cities', { 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 City
|
||||||
|
</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="city_name" className="form-label">
|
||||||
|
City Name*
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
id="city_name"
|
||||||
|
value={data.city_name}
|
||||||
|
maxLength="50"
|
||||||
|
onChange={(e) => handleChange(e)}
|
||||||
|
/>
|
||||||
|
<p className="pt-1 pl-2 text-secondary">
|
||||||
|
Remaining characters : {limiter.city_nameHas}
|
||||||
|
</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 />
|
||||||
|
</div>
|
||||||
|
<div className="mb-3">
|
||||||
|
<label>TimeStamp</label>
|
||||||
|
<input type="text" value={data.createdAt} className="form-control" disabled />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AddCity
|
342
src/views/configuration/cities/Cities.js
Normal file
342
src/views/configuration/cities/Cities.js
Normal file
@ -0,0 +1,342 @@
|
|||||||
|
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 Cities = () => {
|
||||||
|
const token = isAutheticated();
|
||||||
|
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
const [success, setSuccess] = useState(true)
|
||||||
|
const [citiesData, setCitiesData] = useState([])
|
||||||
|
|
||||||
|
const [currentPage, setCurrentPage] = useState(1)
|
||||||
|
const [itemPerPage, setItemPerPage] = useState(10)
|
||||||
|
const [showData, setShowData] = useState(citiesData)
|
||||||
|
|
||||||
|
const handleShowEntries = (e) => {
|
||||||
|
setCurrentPage(1)
|
||||||
|
setItemPerPage(e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const getCategories = () => {
|
||||||
|
axios
|
||||||
|
.get(`/api/city`, {
|
||||||
|
headers: { 'Access-Control-Allow-Origin': '*', Authorization: `Bearer ${token}` },
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
setCitiesData(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(citiesData.slice(indexOfFirstPost, indexOfLastPost))
|
||||||
|
}
|
||||||
|
loadData()
|
||||||
|
}, [currentPage, itemPerPage, citiesData])
|
||||||
|
|
||||||
|
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/city/${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">
|
||||||
|
Cities
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="page-title-right">
|
||||||
|
<Link to="/cities/add">
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
style={{
|
||||||
|
fontWeight: 'bold',
|
||||||
|
marginBottom: '1rem',
|
||||||
|
textTransform: 'capitalize',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Add City
|
||||||
|
</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-light" style={{ background: '#ecdddd' }}>
|
||||||
|
<tr>
|
||||||
|
<th className="text-start">City Name</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((city, 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">
|
||||||
|
{new Date(city.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={`/cities/edit/${city._id}`}>
|
||||||
|
<button
|
||||||
|
style={{ color: 'white', margin: '0 1rem' }}
|
||||||
|
type="button"
|
||||||
|
className="
|
||||||
|
btn btn-primary btn-sm
|
||||||
|
waves-effect waves-light
|
||||||
|
btn-table
|
||||||
|
ml-2
|
||||||
|
"
|
||||||
|
>
|
||||||
|
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
|
||||||
|
ml-2
|
||||||
|
|
||||||
|
"
|
||||||
|
onClick={() => {
|
||||||
|
handleDelete(city._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, citiesData.length)} of{' '}
|
||||||
|
{citiesData.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 >
|
||||||
|
citiesData.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 >
|
||||||
|
citiesData.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 Cities
|
230
src/views/configuration/cities/EditCity.js
Normal file
230
src/views/configuration/cities/EditCity.js
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
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 EditCity = () => {
|
||||||
|
const id = useParams()?.id
|
||||||
|
const token = isAutheticated();
|
||||||
|
const navigate = useNavigate()
|
||||||
|
const [statesData, setStatesData] = useState([])
|
||||||
|
const [data, setData] = useState({
|
||||||
|
city_name: '',
|
||||||
|
state: '',
|
||||||
|
_id: 'Loading',
|
||||||
|
createdAt: new Date(),
|
||||||
|
})
|
||||||
|
const [loading, setLoading] = useState(false)
|
||||||
|
const [limiter, setLimiter] = useState({
|
||||||
|
city_name: 30,
|
||||||
|
city_nameHas: 30,
|
||||||
|
})
|
||||||
|
|
||||||
|
const getCategory = () => {
|
||||||
|
axios
|
||||||
|
.get(`$/api/city/${id}`, {
|
||||||
|
headers: {
|
||||||
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
setData((prev) => ({
|
||||||
|
...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(() => {
|
||||||
|
getCategory()
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
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() === '') {
|
||||||
|
swal({
|
||||||
|
title: 'Warning',
|
||||||
|
text: 'Fill all mandatory fields',
|
||||||
|
icon: 'error',
|
||||||
|
button: 'Close',
|
||||||
|
dangerMode: true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setLoading(true)
|
||||||
|
axios
|
||||||
|
.patch(`/api/city/${id}`, data, {
|
||||||
|
headers: {
|
||||||
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
swal({
|
||||||
|
title: 'Updated',
|
||||||
|
text: 'City updated successfully!',
|
||||||
|
icon: 'success',
|
||||||
|
button: 'Close',
|
||||||
|
})
|
||||||
|
setLoading(false)
|
||||||
|
navigate('/cities', { 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 City
|
||||||
|
</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="city_name" className="form-label">
|
||||||
|
City Name*
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
id="city_name"
|
||||||
|
value={data.city_name}
|
||||||
|
maxLength={limiter.city_name}
|
||||||
|
onChange={(e) => handleChange(e)}
|
||||||
|
/>
|
||||||
|
<p className="pt-1 pl-2 text-secondary">
|
||||||
|
Remaining characters : {limiter.city_nameHas}
|
||||||
|
</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 />
|
||||||
|
</div>
|
||||||
|
<div className="mb-3">
|
||||||
|
<label>TimeStamp</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={new Date(data.createdAt)}
|
||||||
|
className="form-control"
|
||||||
|
disabled
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default EditCity
|
172
src/views/configuration/states/AddState.js
Normal file
172
src/views/configuration/states/AddState.js
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
import React, { useEffect, useState } from 'react'
|
||||||
|
import Button from '@material-ui/core/Button'
|
||||||
|
import { Link, useNavigate } from 'react-router-dom'
|
||||||
|
import swal from 'sweetalert'
|
||||||
|
import axios from 'axios'
|
||||||
|
import { isAutheticated } from 'src/auth'
|
||||||
|
|
||||||
|
|
||||||
|
const AddState = () => {
|
||||||
|
const token = isAutheticated()
|
||||||
|
const navigate = useNavigate()
|
||||||
|
const [data, setData] = useState({
|
||||||
|
state_code: '',
|
||||||
|
state_name: '',
|
||||||
|
})
|
||||||
|
const [loading, setLoading] = useState(false)
|
||||||
|
const [limiter, setLimiter] = useState({
|
||||||
|
state_code: 10,
|
||||||
|
state_name: 50,
|
||||||
|
state_codeHas: 10,
|
||||||
|
state_nameHas: 50,
|
||||||
|
})
|
||||||
|
|
||||||
|
const handleChange = (e) => {
|
||||||
|
if (e.target.id === 'state_code' && /^\D+$/.test(e.target.value)) return
|
||||||
|
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.state_code.trim() === '' || data.state_name.trim() === '') {
|
||||||
|
swal({
|
||||||
|
title: 'Warning',
|
||||||
|
text: 'Fill all mandatory fields',
|
||||||
|
icon: 'error',
|
||||||
|
button: 'Close',
|
||||||
|
dangerMode: true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setLoading(true)
|
||||||
|
axios
|
||||||
|
.post(`/api/state`, data, {
|
||||||
|
headers: {
|
||||||
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
swal({
|
||||||
|
title: 'Added',
|
||||||
|
text: 'State added successfully!',
|
||||||
|
icon: 'success',
|
||||||
|
button: 'Return',
|
||||||
|
})
|
||||||
|
setLoading(false)
|
||||||
|
navigate('/states', { 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 State
|
||||||
|
</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="/states">
|
||||||
|
<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="city_name" className="form-label">
|
||||||
|
State Name*
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
id="state_name"
|
||||||
|
value={data.state_name}
|
||||||
|
maxLength={limiter.state_name}
|
||||||
|
onChange={(e) => handleChange(e)}
|
||||||
|
/>
|
||||||
|
<p className="pt-1 pl-2 text-secondary">
|
||||||
|
Remaining characters : {limiter.state_nameHas}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="city_name" className="form-label">
|
||||||
|
State Code (GST)*
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
id="state_code"
|
||||||
|
value={data.state_code}
|
||||||
|
maxLength={limiter.state_code}
|
||||||
|
onChange={(e) => handleChange(e)}
|
||||||
|
/>
|
||||||
|
<p className="pt-1 pl-2 text-secondary">
|
||||||
|
Remaining characters : {limiter.state_codeHas}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AddState
|
199
src/views/configuration/states/EditStates.js
Normal file
199
src/views/configuration/states/EditStates.js
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
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 EditState = () => {
|
||||||
|
const id = useParams()?.id
|
||||||
|
const token = isAutheticated()
|
||||||
|
const navigate = useNavigate()
|
||||||
|
const [data, setData] = useState({
|
||||||
|
state_code: '',
|
||||||
|
state_name: '',
|
||||||
|
})
|
||||||
|
const [loading, setLoading] = useState(false)
|
||||||
|
const [limiter, setLimiter] = useState({
|
||||||
|
state_code: 10,
|
||||||
|
state_name: 50,
|
||||||
|
state_codeHas: 10,
|
||||||
|
state_nameHas: 50,
|
||||||
|
})
|
||||||
|
|
||||||
|
const getCategory = () => {
|
||||||
|
axios
|
||||||
|
.get(`/api/state/${id}`, {
|
||||||
|
headers: {
|
||||||
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
setData((prev) => ({
|
||||||
|
...prev,
|
||||||
|
...res.data?.data,
|
||||||
|
}))
|
||||||
|
setLimiter((prev) => ({
|
||||||
|
...prev,
|
||||||
|
state_nameHas: prev.state_name - res.data?.data?.state_name.length,
|
||||||
|
state_codeHas: prev.state_code - res.data?.data?.state_code?.toString()?.length,
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
.catch((err) => { })
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getCategory()
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const handleChange = (e) => {
|
||||||
|
if (e.target.id === 'state_code' && /^\D+$/.test(e.target.value)) return
|
||||||
|
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.state_code.trim() === '' || data.state_name.trim() === '') {
|
||||||
|
swal({
|
||||||
|
title: 'Warning',
|
||||||
|
text: 'Fill all mandatory fields',
|
||||||
|
icon: 'error',
|
||||||
|
button: 'Close',
|
||||||
|
dangerMode: true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setLoading(true)
|
||||||
|
axios
|
||||||
|
.patch(`/api/state/${id}`, data, {
|
||||||
|
headers: {
|
||||||
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
swal({
|
||||||
|
title: 'Updated',
|
||||||
|
text: 'State updated successfully!',
|
||||||
|
icon: 'success',
|
||||||
|
button: 'Close',
|
||||||
|
})
|
||||||
|
setLoading(false)
|
||||||
|
navigate('/states', { 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 State
|
||||||
|
</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="/states">
|
||||||
|
<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="city_name" className="form-label">
|
||||||
|
State Name*
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
id="state_name"
|
||||||
|
value={data.state_name}
|
||||||
|
maxLength={limiter.state_name}
|
||||||
|
onChange={(e) => handleChange(e)}
|
||||||
|
/>
|
||||||
|
<p className="pt-1 pl-2 text-secondary">
|
||||||
|
Remaining characters : {limiter.state_nameHas}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="city_name" className="form-label">
|
||||||
|
State Code (GST)*
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
id="state_code"
|
||||||
|
value={data.state_code}
|
||||||
|
maxLength={limiter.state_code}
|
||||||
|
onChange={(e) => handleChange(e)}
|
||||||
|
/>
|
||||||
|
<p className="pt-1 pl-2 text-secondary">
|
||||||
|
Remaining characters : {limiter.state_codeHas}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default EditState
|
342
src/views/configuration/states/States.js
Normal file
342
src/views/configuration/states/States.js
Normal file
@ -0,0 +1,342 @@
|
|||||||
|
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 States = () => {
|
||||||
|
const token = isAutheticated()
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
const [success, setSuccess] = useState(true)
|
||||||
|
const [statesData, setStatesData] = useState([])
|
||||||
|
|
||||||
|
const [currentPage, setCurrentPage] = useState(1)
|
||||||
|
const [itemPerPage, setItemPerPage] = useState(10)
|
||||||
|
const [showData, setShowData] = useState(statesData)
|
||||||
|
|
||||||
|
const handleShowEntries = (e) => {
|
||||||
|
setCurrentPage(1)
|
||||||
|
setItemPerPage(e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const getCategories = () => {
|
||||||
|
axios
|
||||||
|
.get(`/api/state`, {
|
||||||
|
headers: { 'Access-Control-Allow-Origin': '*', Authorization: `Bearer ${token}` },
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
setStatesData(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(statesData.slice(indexOfFirstPost, indexOfLastPost))
|
||||||
|
}
|
||||||
|
loadData()
|
||||||
|
}, [currentPage, itemPerPage, statesData])
|
||||||
|
|
||||||
|
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/state/${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">
|
||||||
|
States
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="page-title-right">
|
||||||
|
<Link to="/states/add">
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
style={{
|
||||||
|
fontWeight: 'bold',
|
||||||
|
marginBottom: '1rem',
|
||||||
|
textTransform: 'capitalize',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Add State
|
||||||
|
</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-info" style={{ background: '#ecdddd' }}>
|
||||||
|
<tr>
|
||||||
|
<th className="text-start">State Name</th>
|
||||||
|
<th className="text-start">State Code (GST)</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((city, i) => {
|
||||||
|
return (
|
||||||
|
<tr key={i}>
|
||||||
|
<td className="text-start">{city.state_name}</td>
|
||||||
|
<td className="text-start">{city.state_code}</td>
|
||||||
|
<td className="text-start">
|
||||||
|
{new Date(city.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={`/states/edit/${city._id}`}>
|
||||||
|
<button
|
||||||
|
style={{ color: 'white', margin: '0 1rem' }}
|
||||||
|
type="button"
|
||||||
|
className="
|
||||||
|
btn btn-primary btn-sm
|
||||||
|
waves-effect waves-light
|
||||||
|
btn-table
|
||||||
|
ml-2
|
||||||
|
"
|
||||||
|
>
|
||||||
|
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
|
||||||
|
ml-2
|
||||||
|
|
||||||
|
"
|
||||||
|
onClick={() => {
|
||||||
|
handleDelete(city._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, statesData.length)} of{' '}
|
||||||
|
{statesData.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 >
|
||||||
|
statesData.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 >
|
||||||
|
statesData.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 States
|
@ -25,98 +25,98 @@ const Dashboard = () => {
|
|||||||
|
|
||||||
|
|
||||||
}, [token]);
|
}, [token]);
|
||||||
//2nd
|
// //2nd
|
||||||
const [category, setCategory] = useState([])
|
// const [category, setCategory] = useState([])
|
||||||
const getAllCategory = useCallback(async () => {
|
// const getAllCategory = useCallback(async () => {
|
||||||
let res = await axios.get(
|
// let res = await axios.get(
|
||||||
`/api/category/getAll`,
|
// `/api/category/getAll`,
|
||||||
{
|
// {
|
||||||
headers: {
|
// headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
// Authorization: `Bearer ${token}`,
|
||||||
},
|
// },
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
// console.log(res.data.category[0].image.url)
|
// // console.log(res.data.category[0].image.url)
|
||||||
setCategory(res.data.category)
|
// setCategory(res.data.category)
|
||||||
}, [token]);
|
// }, [token]);
|
||||||
|
|
||||||
//3 requiment
|
// //3 requiment
|
||||||
const [requirement, setRequirement] = useState([])
|
// const [requirement, setRequirement] = useState([])
|
||||||
// console.log(token)
|
// // console.log(token)
|
||||||
const getRequirement = useCallback(async () => {
|
// const getRequirement = useCallback(async () => {
|
||||||
let res = await axios.get(
|
// let res = await axios.get(
|
||||||
`/api/requirement/getAll`,
|
// `/api/requirement/getAll`,
|
||||||
{
|
// {
|
||||||
headers: {
|
// headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
// Authorization: `Bearer ${token}`,
|
||||||
},
|
// },
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
|
|
||||||
setRequirement(res.data.Requirement)
|
// setRequirement(res.data.Requirement)
|
||||||
|
|
||||||
}, [token]);
|
// }, [token]);
|
||||||
//4 news
|
// //4 news
|
||||||
const [news, setNews] = useState([])
|
// const [news, setNews] = useState([])
|
||||||
|
|
||||||
const getNews = useCallback(async () => {
|
// const getNews = useCallback(async () => {
|
||||||
let res = await axios.get(
|
// let res = await axios.get(
|
||||||
`/api/news/getAll`,
|
// `/api/news/getAll`,
|
||||||
{
|
// {
|
||||||
headers: {
|
// headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
// Authorization: `Bearer ${token}`,
|
||||||
},
|
// },
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
|
|
||||||
setNews(res.data.news)
|
// setNews(res.data.news)
|
||||||
|
|
||||||
|
|
||||||
}, [token]);
|
// }, [token]);
|
||||||
//5 offers
|
// //5 offers
|
||||||
const [offer, setOffer] = useState([])
|
// const [offer, setOffer] = useState([])
|
||||||
|
|
||||||
const getOffer = useCallback(async () => {
|
// const getOffer = useCallback(async () => {
|
||||||
let res = await axios.get(
|
// let res = await axios.get(
|
||||||
`/api/offer/getAll`,
|
// `/api/offer/getAll`,
|
||||||
{
|
// {
|
||||||
headers: {
|
// headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
// Authorization: `Bearer ${token}`,
|
||||||
},
|
// },
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
// console.log(res.data)
|
// // console.log(res.data)
|
||||||
setOffer(res.data.offer)
|
// setOffer(res.data.offer)
|
||||||
|
|
||||||
|
|
||||||
}, [token]);
|
// }, [token]);
|
||||||
//6 event
|
// //6 event
|
||||||
const [event, setEvent] = useState([])
|
// const [event, setEvent] = useState([])
|
||||||
const getEvent = useCallback(async () => {
|
// const getEvent = useCallback(async () => {
|
||||||
let res = await axios.get(
|
// let res = await axios.get(
|
||||||
`/api/event/getAll`,
|
// `/api/event/getAll`,
|
||||||
{
|
// {
|
||||||
headers: {
|
// headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
// Authorization: `Bearer ${token}`,
|
||||||
},
|
// },
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
// console.log(res.data)
|
// // console.log(res.data)
|
||||||
setEvent(res.data.Event)
|
// setEvent(res.data.Event)
|
||||||
|
|
||||||
|
|
||||||
}, [token]);
|
// }, [token]);
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
getAllUsers();
|
// getAllUsers();
|
||||||
getAllCategory()
|
// getAllCategory()
|
||||||
getRequirement()
|
// getRequirement()
|
||||||
getNews()
|
// getNews()
|
||||||
getOffer()
|
// getOffer()
|
||||||
getEvent()
|
// getEvent()
|
||||||
}, [getAllUsers, getAllCategory, getRequirement, getNews, getOffer, getEvent]);
|
// }, [getAllUsers, getAllCategory, getRequirement, getNews, getOffer, getEvent]);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<WidgetsDropdown users={users} category={category} requirement={requirement} news={news} offer={offer} event={event} />
|
<WidgetsDropdown users={users} />
|
||||||
|
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect } from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link, useNavigate } from 'react-router-dom'
|
||||||
import {
|
import {
|
||||||
CButton,
|
CButton,
|
||||||
CCard,
|
CCard,
|
||||||
@ -36,7 +36,7 @@ const Login = () => {
|
|||||||
/^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i,
|
/^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i,
|
||||||
)
|
)
|
||||||
const validPasswordRegex = RegExp(/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[^\w\s]).{7,}$/)
|
const validPasswordRegex = RegExp(/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[^\w\s]).{7,}$/)
|
||||||
const history = useHistory();
|
const history = useNavigate();
|
||||||
// const handleChange = (e) => (event) => {
|
// const handleChange = (e) => (event) => {
|
||||||
|
|
||||||
// setAuth({ ...auth, [e]: event.target.value });
|
// setAuth({ ...auth, [e]: event.target.value });
|
||||||
@ -110,7 +110,7 @@ const Login = () => {
|
|||||||
// console.log(response.data)
|
// console.log(response.data)
|
||||||
const data = response.data
|
const data = response.data
|
||||||
if (data.user.role === 'admin') {
|
if (data.user.role === 'admin') {
|
||||||
history.push('/dashboard')
|
history('/dashboard')
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ const Login = () => {
|
|||||||
<br />
|
<br />
|
||||||
|
|
||||||
<CButton color="link" className="px-0">
|
<CButton color="link" className="px-0">
|
||||||
<Link to="/forgot">
|
<Link to="/password/forgot">
|
||||||
Forgot password.?
|
Forgot password.?
|
||||||
</Link>
|
</Link>
|
||||||
</CButton>
|
</CButton>
|
||||||
|
@ -17,12 +17,12 @@ import ClipLoader from "react-spinners/ClipLoader";
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { isAutheticated } from 'src/auth'
|
import { isAutheticated } from 'src/auth'
|
||||||
import Swal from 'sweetalert2'
|
import Swal from 'sweetalert2'
|
||||||
import { useHistory } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
|
|
||||||
const Register = () => {
|
const Register = () => {
|
||||||
|
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const history = useHistory();
|
const history = useNavigate();
|
||||||
const [user, setUser] = useState({
|
const [user, setUser] = useState({
|
||||||
oldPassword: '',
|
oldPassword: '',
|
||||||
newPassword: '',
|
newPassword: '',
|
||||||
@ -107,7 +107,7 @@ const Register = () => {
|
|||||||
confirmButtonColor: '#303c54',
|
confirmButtonColor: '#303c54',
|
||||||
iconColor: '#303c54'
|
iconColor: '#303c54'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
history.push('/dashboard')
|
history('/dashboard')
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,11 @@ import {
|
|||||||
} from '@coreui/react'
|
} from '@coreui/react'
|
||||||
import CIcon from '@coreui/icons-react'
|
import CIcon from '@coreui/icons-react'
|
||||||
import { cilEnvelopeLetter, cilEnvelopeOpen, cilLockLocked, cilUser } from '@coreui/icons'
|
import { cilEnvelopeLetter, cilEnvelopeOpen, cilLockLocked, cilUser } from '@coreui/icons'
|
||||||
import { Link, useHistory } from 'react-router-dom';
|
import { Link, useNavigate } from 'react-router-dom';
|
||||||
import swal from 'sweetalert';
|
import swal from 'sweetalert';
|
||||||
|
|
||||||
const ForgotPassword = () => {
|
const ForgotPassword = () => {
|
||||||
const history = useHistory()
|
const navigate = useNavigate()
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [email, setEmail] = useState()
|
const [email, setEmail] = useState()
|
||||||
// console.log(email)
|
// console.log(email)
|
||||||
@ -36,7 +36,7 @@ const ForgotPassword = () => {
|
|||||||
setLoading(false)
|
setLoading(false)
|
||||||
// alert("Email Send Successfully! please check your mail for reset password")
|
// alert("Email Send Successfully! please check your mail for reset password")
|
||||||
swal("success!", "Email Send Successfully! please check your Email for new password", "success");
|
swal("success!", "Email Send Successfully! please check your Email for new password", "success");
|
||||||
history.push("/");
|
navigate("/");
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -3,7 +3,7 @@ import { CForm, CCol, CFormLabel, CContainer, CRow, CCardGroup, CCard, CCardBody
|
|||||||
import { Country, City } from 'country-state-city'
|
import { Country, City } from 'country-state-city'
|
||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { useHistory } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
const NewRegister = () => {
|
const NewRegister = () => {
|
||||||
const [cities, setCities] = useState([])
|
const [cities, setCities] = useState([])
|
||||||
const [ownerDetails, setOwnerDetails] = useState({
|
const [ownerDetails, setOwnerDetails] = useState({
|
||||||
@ -14,7 +14,7 @@ const NewRegister = () => {
|
|||||||
country: 'India',
|
country: 'India',
|
||||||
city: ''
|
city: ''
|
||||||
})
|
})
|
||||||
const history = useHistory()
|
const history = useNavigate()
|
||||||
const [processing, setProcessing] = useState(false)
|
const [processing, setProcessing] = useState(false)
|
||||||
const countries = Country.getAllCountries()
|
const countries = Country.getAllCountries()
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -48,7 +48,7 @@ const NewRegister = () => {
|
|||||||
|
|
||||||
// token: res.data.token,
|
// token: res.data.token,
|
||||||
// }));
|
// }));
|
||||||
history.push('/')
|
history('/')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,8 +12,10 @@ import { getStyle } from '@coreui/utils'
|
|||||||
import { CChartBar, CChartLine } from '@coreui/react-chartjs'
|
import { CChartBar, CChartLine } from '@coreui/react-chartjs'
|
||||||
import CIcon from '@coreui/icons-react'
|
import CIcon from '@coreui/icons-react'
|
||||||
import { cilArrowBottom, cilArrowTop, cilOptions } from '@coreui/icons'
|
import { cilArrowBottom, cilArrowTop, cilOptions } from '@coreui/icons'
|
||||||
|
import { BeatLoader } from 'react-spinners'
|
||||||
|
{/* <BeatLoader color="#36d7b7" /> */ }
|
||||||
|
|
||||||
const WidgetsDropdown = ({ users, category, requirement, news, offer, event }) => {
|
const WidgetsDropdown = ({ users }) => {
|
||||||
return (
|
return (
|
||||||
<CRow>
|
<CRow>
|
||||||
<CCol sm={6} lg={3}>
|
<CCol sm={6} lg={3}>
|
||||||
@ -22,6 +24,7 @@ const WidgetsDropdown = ({ users, category, requirement, news, offer, event }) =
|
|||||||
color="primary"
|
color="primary"
|
||||||
value={
|
value={
|
||||||
<>
|
<>
|
||||||
|
|
||||||
{users.length}
|
{users.length}
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user