diff --git a/package.json b/package.json index 4c6b5b4..ab6c116 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "@coreui/react": "^4.3.0", "@coreui/react-chartjs": "^2.0.0", "@coreui/utils": "^1.3.1", + "@material-ui/core": "^4.12.4", "@reduxjs/toolkit": "^1.8.2", "@wojtekmaj/enzyme-adapter-react-17": "^0.6.5", "axios": "^0.25.0", @@ -50,14 +51,14 @@ "enzyme": "^3.11.0", "file-saver": "^2.0.5", "prop-types": "^15.7.2", - "react": "^17.0.2", + "react": "18.2", "react-app-polyfill": "^2.0.0", "react-date-picker": "^8.4.0", "react-datepicker": "^4.8.0", "react-dom": "^17.0.2", "react-paginate": "^8.1.3", "react-redux": "^7.2.6", - "react-router-dom": "^5.3.0", + "react-router-dom": "^6.7.0", "react-spinners": "^0.11.0", "react-time-picker": "^4.5.0", "redux": "4.1.2", diff --git a/src/App.js b/src/App.js index 52538b8..2850d67 100644 --- a/src/App.js +++ b/src/App.js @@ -1,6 +1,6 @@ -import React, { Component } from 'react' +import React, { Component, Suspense } from 'react' 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 './scss/style.scss' import ForgotPassword from './views/pages/register/ForgotPassword' @@ -14,7 +14,7 @@ const loading = (
) - +// import EditProducts from './views/Commerce/Editproducts' // Containers const DefaultLayout = React.lazy(() => import('./layout/DefaultLayout')) @@ -64,31 +64,26 @@ const App = () => { }, []) return ( - - - - < Route exact path="/" name="Login Page" render={(props) => } /> - } /> - } /> + + + + } /> + } /> + } /> + } /> + } /> - } /> - } /> + + : + userdata === false ? :
} /> + } /> +
+
+
- ( - userdata?.role === "admin" ? : - userdata === false ? :
- )} /> - - } /> - - - -
-
-
) } export default App diff --git a/src/_nav.js b/src/_nav.js index 86a1747..04cbe08 100644 --- a/src/_nav.js +++ b/src/_nav.js @@ -1,13 +1,17 @@ import React from 'react' import CIcon from '@coreui/icons-react' import { + cilAddressBook, + cilAppsSettings, cilBell, cilCalculator, cilChartPie, + cilCommand, cilCursor, cilDrop, cilFace, cilFilterSquare, + cilMedicalCross, cilMoney, cilNewspaper, cilNotes, @@ -38,6 +42,79 @@ const _nav = [ icon: , to: '/users', }, + { + component: CNavGroup, + name: 'Configuration', + icon: , + items: [ + { + component: CNavItem, + name: 'Cities', + icon: , + to: '/cities', + }, + { + component: CNavItem, + name: 'States', + icon: , + to: '/states', + }, + // { + // component: CNavItem, + // name: 'Standard Shipping', + // icon: , + // to: '/shipping', + // }, + // { + // component: CNavItem, + // name: 'Custom Shipping', + // icon: , + // to: '/custom-shipping', + // }, + // { + // component: CNavItem, + // name: 'Pincode', + // icon: , + // to: '/pincode', + // }, + // { + // component: CNavItem, + // name: 'Tax Rates', + // icon: , + // to: '/tax', + // }, + // { + // component: CNavItem, + // name: 'Pages', + // icon: , + // to: '/page', + // }, + // { + // component: CNavItem, + // name: 'Terms of Use', + // icon: , + // to: '/terms_of_use', + // }, + { + component: CNavItem, + name: 'Social Media', + icon: , + to: '/socialmedia', + }, + { + component: CNavItem, + name: 'Address', + icon: , + to: '/address', + }, + { + component: CNavItem, + name: 'Logos', + icon: , + to: '/logo', + }, + ], + }, diff --git a/src/components/AppContent.js b/src/components/AppContent.js index d048fb8..7a03fe5 100644 --- a/src/components/AppContent.js +++ b/src/components/AppContent.js @@ -1,5 +1,5 @@ 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' // routes config @@ -9,26 +9,22 @@ const AppContent = () => { return ( }> - + {routes.map((route, idx) => { return ( - route.component && ( + route.element && ( ( - <> - - - )} + element={} /> ) ) })} - - + } /> + ) diff --git a/src/components/AppFooter.js b/src/components/AppFooter.js index 1931956..79a0602 100644 --- a/src/components/AppFooter.js +++ b/src/components/AppFooter.js @@ -6,7 +6,7 @@ const AppFooter = () => {
- {new Date().getFullYear()} ©ATP. + {new Date().getFullYear()} © Any Time Prasad ( ATP ) .
diff --git a/src/components/AppHeader.js b/src/components/AppHeader.js index 45d2168..04c70ef 100644 --- a/src/components/AppHeader.js +++ b/src/components/AppHeader.js @@ -32,12 +32,12 @@ const AppHeader = () => { -

ATP

+

Any Time Prasad

- Dashboard + ATP Dashboard {/* diff --git a/src/components/AppSidebar.js b/src/components/AppSidebar.js index c7550af..d49650a 100644 --- a/src/components/AppSidebar.js +++ b/src/components/AppSidebar.js @@ -31,7 +31,7 @@ const AppSidebar = () => { > {/* */} -

ATP

+

ATP Dashboard

{/* */}
diff --git a/src/components/ProtectedRoute.js b/src/components/ProtectedRoute.js index 4bc87db..91ad63a 100644 --- a/src/components/ProtectedRoute.js +++ b/src/components/ProtectedRoute.js @@ -1,11 +1,11 @@ import React, { useEffect, useState, } from "react"; -import { useHistory } from "react-router-dom"; +import { useNavigate } from "react-router-dom"; const ProtectedRoute = (props) => { let Cmp = props; - const history = useHistory(); + const history = useNavigate(); useEffect(() => { if (!localStorage.getItem('authToken')) - history.push('/') + history('/') }, []) return ( <> diff --git a/src/components/header/AppHeaderDropdown.js b/src/components/header/AppHeaderDropdown.js index c871aa8..70b04c1 100644 --- a/src/components/header/AppHeaderDropdown.js +++ b/src/components/header/AppHeaderDropdown.js @@ -27,7 +27,7 @@ import swal from 'sweetalert'; import userImage from './../../assets/images/avatars/1.jpg' import { Link } from 'react-router-dom' // import { signout } from 'src/auth' -import { useHistory } from "react-router-dom"; +import { useNavigate } from "react-router-dom"; import { useEffect } from 'react'; import axios from 'axios'; import { useState } from 'react'; @@ -35,11 +35,11 @@ import { useState } from 'react'; const AppHeaderDropdown = () => { const [userData, setUserData] = useState() - let history = useHistory(); + let history = useNavigate(); const signout = async () => { localStorage.removeItem('authToken') swal("success!", "Logged Out", "success"); - history.push("/"); + history("/"); } //for user image diff --git a/src/routes.js b/src/routes.js index 265fc00..0cea1a3 100644 --- a/src/routes.js +++ b/src/routes.js @@ -8,24 +8,54 @@ const Change_Password = React.lazy(() => import('./views/pages/register/Change_p import Profile from './views/Profile/Profile' import EditProfile from './views/Profile/EditProfile' const Dashboard = React.lazy(() => import('./views/dashboard/Dashboard')) - +/// +//Cities +import Cities from './views/configuration/cities/Cities.js' +import AddCity from './views/configuration/cities/AddCity.js' +import EditCity from './views/configuration/cities/EditCity.js' +//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 = [ { path: '/', exact: true, name: 'Home' }, - { path: '/change_password', name: 'Change Password', component: Change_Password }, - { path: '/profile/edit', name: 'Edit Profile', component: EditProfile }, - // { path: '/profile', name: 'Profile', component: Profile }, - - - - - + { path: '/change_password', name: 'Change Password', element: Change_Password }, + { path: '/profile/edit', name: 'Edit Profile', element: EditProfile }, + // { path: '/profile', name: 'Profile', element: Profile }, //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 diff --git a/src/views/Profile/EditProfile.js b/src/views/Profile/EditProfile.js index c479078..d794c61 100644 --- a/src/views/Profile/EditProfile.js +++ b/src/views/Profile/EditProfile.js @@ -3,7 +3,7 @@ import { CForm, CCol, CFormLabel, CContainer, CRow, CCardGroup, CCard, CCardBody import { useState, useEffect } from 'react' import axios from 'axios' -import { useHistory } from 'react-router-dom' +import { useNavigate } from 'react-router-dom' import { isAutheticated } from 'src/auth' const EditProfile = () => { @@ -19,7 +19,7 @@ const EditProfile = () => { phone: '' }) - const history = useHistory() + const history = useNavigate() @@ -99,7 +99,7 @@ const EditProfile = () => { icon: 'success', button: 'Return', }) - history.goBack() + history(-1) } } catch (error) { diff --git a/src/views/Profile/Profile.js b/src/views/Profile/Profile.js index 880d2bd..19b827a 100644 --- a/src/views/Profile/Profile.js +++ b/src/views/Profile/Profile.js @@ -19,13 +19,13 @@ import { import { useState } from 'react' import axios from 'axios'; import { isAutheticated } from 'src/auth'; -import { useHistory } from 'react-router-dom'; +import { useNavigate } from 'react-router-dom'; const Profile = () => { // const user = JSON.parse(localStorage.getItem('auth')).user const [user, setUser] = useState({}); const { token } = isAutheticated(); - const history = useHistory() + const history = useNavigate() // console.log(token); useEffect(async () => { let res = await axios.get('/owner', { @@ -51,7 +51,7 @@ const Profile = () => { history.push('/edit')}>Edit Profile + className="float-right" onClick={() => history('/edit')}>Edit Profile diff --git a/src/views/configuration/Address.js b/src/views/configuration/Address.js new file mode 100644 index 0000000..9535cf4 --- /dev/null +++ b/src/views/configuration/Address.js @@ -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 ( +
+
+
+
+
+
+
+
+
+
+

Address

+ +
+
+
+
+ <> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + />{' '} + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + />{' '} + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + +
+
+
+
+
+
+ +
+
+
+
+
+
+ + {/* */} +
+
+
+
+
+ {/* */} +
+ {/* */} +
+
+ ) +} + +export default Address diff --git a/src/views/configuration/Logo.js b/src/views/configuration/Logo.js new file mode 100644 index 0000000..f94b75f --- /dev/null +++ b/src/views/configuration/Logo.js @@ -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 ( +
+
+
+
+
+
+
+
+
+
+

Logo

+ +
+
+
+
+ <> + +
+ { + 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 ? ( + header logo + ) : ( + '' + )} +
+ + { + 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 ? ( + Footer logo + ) : ( + '' + )} + + { + 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 ? ( + Admin logo + ) : ( + '' + )} + +
+
+
+
+
+
+ +
+
+
+
+
+
+ + {/* */} +
+
+
+
+
+ {/* */} +
+ {/* */} +
+
+ ) +} + +export default Logo diff --git a/src/views/configuration/Socialmedia.js b/src/views/configuration/Socialmedia.js new file mode 100644 index 0000000..2af69d3 --- /dev/null +++ b/src/views/configuration/Socialmedia.js @@ -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 ( +
+ {/* */} +
+
+
+
+
+
+
+
+
+

Social Media

+ +
+
+
+
+ <> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + />{' '} + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + />{' '} + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + +
+
+
+
+
+
+ +
+
+
+
+
+
+ + {/* */} +
+
+
+
+
+ {/* */} +
+ {/* */} +
+
+ ) +} + +export default Socialmedia diff --git a/src/views/configuration/cities/AddCity.js b/src/views/configuration/cities/AddCity.js new file mode 100644 index 0000000..2cc9eeb --- /dev/null +++ b/src/views/configuration/cities/AddCity.js @@ -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 ( +
+
+
+
+
+ Add City +
+
+

+
+ +
+ + + + +
+
+
+
+
+
+
+
+
+ + handleChange(e)} + /> +

+ Remaining characters : {limiter.city_nameHas} +

+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+ ) +} + +export default AddCity diff --git a/src/views/configuration/cities/Cities.js b/src/views/configuration/cities/Cities.js new file mode 100644 index 0000000..96ad62d --- /dev/null +++ b/src/views/configuration/cities/Cities.js @@ -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 ( +
+
+
+
+
+
+
+ Cities +
+ +
+ + + +
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+ +
+ + + + + + + + + + + {!loading && showData.length === 0 && ( + + + + )} + {loading ? ( + + + + ) : ( + showData.map((city, i) => { + return ( + + + + + + + + ) + }) + )} + +
City NameState NameCreated OnActions
+
No Data Available
+
+ Loading... +
{city.city_name}{city.state?.state_name} + {new Date(city.createdAt).toLocaleString('en-IN', { + weekday: 'short', + month: 'short', + day: 'numeric', + year: 'numeric', + hour: 'numeric', + minute: 'numeric', + hour12: true, + })} + + + + + + + +
+
+ +
+
+
+ Showing {currentPage * itemPerPage - itemPerPage + 1} to{' '} + {Math.min(currentPage * itemPerPage, citiesData.length)} of{' '} + {citiesData.length} entries +
+
+ +
+
+
    +
  • + setCurrentPage((prev) => prev - 1)} + > + Previous + +
  • + + {!(currentPage - 1 < 1) && ( +
  • + setCurrentPage((prev) => prev - 1)} + > + {currentPage - 1} + +
  • + )} + +
  • + + {currentPage} + +
  • + + {!( + (currentPage + 1) * itemPerPage - itemPerPage > + citiesData.length - 1 + ) && ( +
  • + { + setCurrentPage((prev) => prev + 1) + }} + > + {currentPage + 1} + +
  • + )} + +
  • + citiesData.length - 1 + ) + ? 'paginate_button page-item next' + : 'paginate_button page-item next disabled' + } + > + setCurrentPage((prev) => prev + 1)} + > + Next + +
  • +
+
+
+
+
+
+
+
+
+
+
+ ) +} + +export default Cities diff --git a/src/views/configuration/cities/EditCity.js b/src/views/configuration/cities/EditCity.js new file mode 100644 index 0000000..65cc090 --- /dev/null +++ b/src/views/configuration/cities/EditCity.js @@ -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 ( +
+
+
+
+
+ Edit City +
+
+

+
+ +
+ + + + +
+
+
+
+
+
+
+
+
+ + handleChange(e)} + /> +

+ Remaining characters : {limiter.city_nameHas} +

+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+ ) +} + +export default EditCity diff --git a/src/views/configuration/states/AddState.js b/src/views/configuration/states/AddState.js new file mode 100644 index 0000000..d8402c7 --- /dev/null +++ b/src/views/configuration/states/AddState.js @@ -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 ( +
+
+
+
+
+ Add State +
+
+

+
+ +
+ + + + +
+
+
+
+
+
+
+
+
+ + handleChange(e)} + /> +

+ Remaining characters : {limiter.state_nameHas} +

+
+
+ + handleChange(e)} + /> +

+ Remaining characters : {limiter.state_codeHas} +

+
+
+
+
+
+
+ ) +} + +export default AddState diff --git a/src/views/configuration/states/EditStates.js b/src/views/configuration/states/EditStates.js new file mode 100644 index 0000000..f21585b --- /dev/null +++ b/src/views/configuration/states/EditStates.js @@ -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 ( +
+
+
+
+
+ Edit State +
+
+

+
+ +
+ + + + +
+
+
+
+
+
+
+
+
+ + handleChange(e)} + /> +

+ Remaining characters : {limiter.state_nameHas} +

+
+
+ + handleChange(e)} + /> +

+ Remaining characters : {limiter.state_codeHas} +

+
+
+
+
+
+
+ ) +} + +export default EditState diff --git a/src/views/configuration/states/States.js b/src/views/configuration/states/States.js new file mode 100644 index 0000000..ae2404f --- /dev/null +++ b/src/views/configuration/states/States.js @@ -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 ( +
+
+
+
+
+
+
+ States +
+ +
+ + + +
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+ +
+ + + + + + + + + + + {!loading && showData.length === 0 && ( + + + + )} + {loading ? ( + + + + ) : ( + showData.map((city, i) => { + return ( + + + + + + + + ) + }) + )} + +
State NameState Code (GST)Created OnActions
+
No Data Available
+
+ Loading... +
{city.state_name}{city.state_code} + {new Date(city.createdAt).toLocaleString('en-IN', { + weekday: 'short', + month: 'short', + day: 'numeric', + year: 'numeric', + hour: 'numeric', + minute: 'numeric', + hour12: true, + })} + + + + + + + +
+
+ +
+
+
+ Showing {currentPage * itemPerPage - itemPerPage + 1} to{' '} + {Math.min(currentPage * itemPerPage, statesData.length)} of{' '} + {statesData.length} entries +
+
+ +
+
+
    +
  • + setCurrentPage((prev) => prev - 1)} + > + Previous + +
  • + + {!(currentPage - 1 < 1) && ( +
  • + setCurrentPage((prev) => prev - 1)} + > + {currentPage - 1} + +
  • + )} + +
  • + + {currentPage} + +
  • + + {!( + (currentPage + 1) * itemPerPage - itemPerPage > + statesData.length - 1 + ) && ( +
  • + { + setCurrentPage((prev) => prev + 1) + }} + > + {currentPage + 1} + +
  • + )} + +
  • + statesData.length - 1 + ) + ? 'paginate_button page-item next' + : 'paginate_button page-item next disabled' + } + > + setCurrentPage((prev) => prev + 1)} + > + Next + +
  • +
+
+
+
+
+
+
+
+
+
+
+ ) +} + +export default States diff --git a/src/views/dashboard/Dashboard.js b/src/views/dashboard/Dashboard.js index 9aa67bd..aff2ff8 100644 --- a/src/views/dashboard/Dashboard.js +++ b/src/views/dashboard/Dashboard.js @@ -25,98 +25,98 @@ const Dashboard = () => { }, [token]); - //2nd - const [category, setCategory] = useState([]) - const getAllCategory = useCallback(async () => { - let res = await axios.get( - `/api/category/getAll`, - { - headers: { - Authorization: `Bearer ${token}`, - }, - } - ); - // console.log(res.data.category[0].image.url) - setCategory(res.data.category) - }, [token]); + // //2nd + // const [category, setCategory] = useState([]) + // const getAllCategory = useCallback(async () => { + // let res = await axios.get( + // `/api/category/getAll`, + // { + // headers: { + // Authorization: `Bearer ${token}`, + // }, + // } + // ); + // // console.log(res.data.category[0].image.url) + // setCategory(res.data.category) + // }, [token]); - //3 requiment - const [requirement, setRequirement] = useState([]) - // console.log(token) - const getRequirement = useCallback(async () => { - let res = await axios.get( - `/api/requirement/getAll`, - { - headers: { - Authorization: `Bearer ${token}`, - }, - } - ); + // //3 requiment + // const [requirement, setRequirement] = useState([]) + // // console.log(token) + // const getRequirement = useCallback(async () => { + // let res = await axios.get( + // `/api/requirement/getAll`, + // { + // headers: { + // Authorization: `Bearer ${token}`, + // }, + // } + // ); - setRequirement(res.data.Requirement) + // setRequirement(res.data.Requirement) - }, [token]); - //4 news - const [news, setNews] = useState([]) + // }, [token]); + // //4 news + // const [news, setNews] = useState([]) - const getNews = useCallback(async () => { - let res = await axios.get( - `/api/news/getAll`, - { - headers: { - Authorization: `Bearer ${token}`, - }, - } - ); + // const getNews = useCallback(async () => { + // let res = await axios.get( + // `/api/news/getAll`, + // { + // headers: { + // Authorization: `Bearer ${token}`, + // }, + // } + // ); - setNews(res.data.news) + // setNews(res.data.news) - }, [token]); - //5 offers - const [offer, setOffer] = useState([]) + // }, [token]); + // //5 offers + // const [offer, setOffer] = useState([]) - const getOffer = useCallback(async () => { - let res = await axios.get( - `/api/offer/getAll`, - { - headers: { - Authorization: `Bearer ${token}`, - }, - } - ); - // console.log(res.data) - setOffer(res.data.offer) + // const getOffer = useCallback(async () => { + // let res = await axios.get( + // `/api/offer/getAll`, + // { + // headers: { + // Authorization: `Bearer ${token}`, + // }, + // } + // ); + // // console.log(res.data) + // setOffer(res.data.offer) - }, [token]); - //6 event - const [event, setEvent] = useState([]) - const getEvent = useCallback(async () => { - let res = await axios.get( - `/api/event/getAll`, - { - headers: { - Authorization: `Bearer ${token}`, - }, - } - ); - // console.log(res.data) - setEvent(res.data.Event) + // }, [token]); + // //6 event + // const [event, setEvent] = useState([]) + // const getEvent = useCallback(async () => { + // let res = await axios.get( + // `/api/event/getAll`, + // { + // headers: { + // Authorization: `Bearer ${token}`, + // }, + // } + // ); + // // console.log(res.data) + // setEvent(res.data.Event) - }, [token]); - useEffect(() => { - getAllUsers(); - getAllCategory() - getRequirement() - getNews() - getOffer() - getEvent() - }, [getAllUsers, getAllCategory, getRequirement, getNews, getOffer, getEvent]); + // }, [token]); + // useEffect(() => { + // getAllUsers(); + // getAllCategory() + // getRequirement() + // getNews() + // getOffer() + // getEvent() + // }, [getAllUsers, getAllCategory, getRequirement, getNews, getOffer, getEvent]); return ( <> - + ) diff --git a/src/views/pages/login/Login.js b/src/views/pages/login/Login.js index 6ea9d81..71924ef 100644 --- a/src/views/pages/login/Login.js +++ b/src/views/pages/login/Login.js @@ -1,5 +1,5 @@ import React, { useEffect } from 'react' -import { Link } from 'react-router-dom' +import { Link, useNavigate } from 'react-router-dom' import { CButton, CCard, @@ -36,7 +36,7 @@ const Login = () => { /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i, ) const validPasswordRegex = RegExp(/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[^\w\s]).{7,}$/) - const history = useHistory(); + const history = useNavigate(); // const handleChange = (e) => (event) => { // setAuth({ ...auth, [e]: event.target.value }); @@ -110,7 +110,7 @@ const Login = () => { // console.log(response.data) const data = response.data if (data.user.role === 'admin') { - history.push('/dashboard') + history('/dashboard') setLoading(false); window.location.reload() } @@ -188,7 +188,7 @@ const Login = () => {
- + Forgot password.? diff --git a/src/views/pages/register/Change_password.js b/src/views/pages/register/Change_password.js index 115bc9d..121b482 100644 --- a/src/views/pages/register/Change_password.js +++ b/src/views/pages/register/Change_password.js @@ -17,12 +17,12 @@ import ClipLoader from "react-spinners/ClipLoader"; import axios from 'axios' import { isAutheticated } from 'src/auth' import Swal from 'sweetalert2' -import { useHistory } from 'react-router-dom' +import { useNavigate } from 'react-router-dom' const Register = () => { const [loading, setLoading] = useState(false); - const history = useHistory(); + const history = useNavigate(); const [user, setUser] = useState({ oldPassword: '', newPassword: '', @@ -107,7 +107,7 @@ const Register = () => { confirmButtonColor: '#303c54', iconColor: '#303c54' }).then(() => { - history.push('/dashboard') + history('/dashboard') }); } diff --git a/src/views/pages/register/ForgotPassword.js b/src/views/pages/register/ForgotPassword.js index cb1e857..0aecbcd 100644 --- a/src/views/pages/register/ForgotPassword.js +++ b/src/views/pages/register/ForgotPassword.js @@ -17,11 +17,11 @@ import { } from '@coreui/react' import CIcon from '@coreui/icons-react' 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'; const ForgotPassword = () => { - const history = useHistory() + const navigate = useNavigate() const [loading, setLoading] = useState(false); const [email, setEmail] = useState() // console.log(email) @@ -36,7 +36,7 @@ const ForgotPassword = () => { setLoading(false) // alert("Email Send Successfully! please check your mail for reset password") swal("success!", "Email Send Successfully! please check your Email for new password", "success"); - history.push("/"); + navigate("/"); } } catch (e) { diff --git a/src/views/pages/register/NewRegister.js b/src/views/pages/register/NewRegister.js index c1c28b1..bdbb7a6 100644 --- a/src/views/pages/register/NewRegister.js +++ b/src/views/pages/register/NewRegister.js @@ -3,7 +3,7 @@ import { CForm, CCol, CFormLabel, CContainer, CRow, CCardGroup, CCard, CCardBody import { Country, City } from 'country-state-city' import { useState, useEffect } from 'react' import axios from 'axios' -import { useHistory } from 'react-router-dom' +import { useNavigate } from 'react-router-dom' const NewRegister = () => { const [cities, setCities] = useState([]) const [ownerDetails, setOwnerDetails] = useState({ @@ -14,7 +14,7 @@ const NewRegister = () => { country: 'India', city: '' }) - const history = useHistory() + const history = useNavigate() const [processing, setProcessing] = useState(false) const countries = Country.getAllCountries() useEffect(() => { @@ -48,7 +48,7 @@ const NewRegister = () => { // token: res.data.token, // })); - history.push('/') + history('/') } } diff --git a/src/views/widgets/WidgetsDropdown.js b/src/views/widgets/WidgetsDropdown.js index ba45361..6f9636d 100644 --- a/src/views/widgets/WidgetsDropdown.js +++ b/src/views/widgets/WidgetsDropdown.js @@ -12,8 +12,10 @@ import { getStyle } from '@coreui/utils' import { CChartBar, CChartLine } from '@coreui/react-chartjs' import CIcon from '@coreui/icons-react' import { cilArrowBottom, cilArrowTop, cilOptions } from '@coreui/icons' +import { BeatLoader } from 'react-spinners' +{/* */ } -const WidgetsDropdown = ({ users, category, requirement, news, offer, event }) => { +const WidgetsDropdown = ({ users }) => { return ( @@ -22,6 +24,7 @@ const WidgetsDropdown = ({ users, category, requirement, news, offer, event }) = color="primary" value={ <> + {users.length} }