This commit is contained in:
pawan-dot 2022-08-10 13:55:18 +05:30
parent 023b5113bc
commit d21eb2dc5b
6 changed files with 234 additions and 317 deletions

View File

@ -85,12 +85,12 @@ const _nav = [
icon: <CIcon icon={cilFilterSquare} customClassName="nav-icon" />, icon: <CIcon icon={cilFilterSquare} customClassName="nav-icon" />,
to: '/requirement', to: '/requirement',
}, },
{ // {
component: CNavItem, // component: CNavItem,
name: 'FAQs', // name: 'FAQs',
icon: <CIcon icon={cilFace} customClassName="nav-icon" />, // icon: <CIcon icon={cilFace} customClassName="nav-icon" />,
to: '/FAQs', // to: '/FAQs',
}, // },
{ {
component: CNavItem, component: CNavItem,
name: 'Users', name: 'Users',

View File

@ -12,7 +12,7 @@ import axios from 'axios'
const setupAxios = () => { const setupAxios = () => {
axios.defaults.baseURL = 'https://cms-api-dashboard.herokuapp.com/'; axios.defaults.baseURL = 'https://cms-api-dashboard.herokuapp.com/';
// axios.defaults.baseURL = 'http://localhost:5000' //axios.defaults.baseURL = 'http://localhost:5000'
axios.defaults.headers = { axios.defaults.headers = {
'Cache-Control': 'no-cache,no-store', 'Cache-Control': 'no-cache,no-store',
'Pragma': 'no-cache', 'Pragma': 'no-cache',

View File

@ -1,20 +1,122 @@
import React, { lazy } from 'react' import React, { lazy } from 'react'
import axios from "axios";
import { useEffect, useState, useCallback, useMemo } from "react";
import { isAutheticated } from "../../auth.js";
const WidgetsDropdown = lazy(() => import('../widgets/WidgetsDropdown.js')) const WidgetsDropdown = lazy(() => import('../widgets/WidgetsDropdown.js'))
const WidgetsBrand = lazy(() => import('../widgets/WidgetsBrand.js'))
const Dashboard = () => { const Dashboard = () => {
const random = (min, max) => { //1 st
return Math.floor(Math.random() * (max - min + 1) + min) const [users, setUsers] = useState([])
const token = isAutheticated();
const getAllUsers = useCallback(async () => {
let res = await axios.get(
`/api/v1/admin/users`,
{
headers: {
Authorization: `Bearer ${token}`,
},
} }
);
// console.log(res.data)
setUsers(res.data.users)
}, [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}`,
},
}
);
setRequirement(res.data.Requirement)
}, [token]);
//4 news
const [news, setNews] = useState([])
const getNews = useCallback(async () => {
let res = await axios.get(
`/api/news/getAll`,
{
headers: {
Authorization: `Bearer ${token}`,
},
}
);
setNews(res.data.news)
}, [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)
}, [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]);
return ( return (
<> <>
<WidgetsDropdown /> <WidgetsDropdown users={users} category={category} requirement={requirement} news={news} offer={offer} event={event} />
</> </>
) )

View File

@ -83,7 +83,7 @@ const Register = () => {
<CInputGroupText> <CInputGroupText>
<CIcon icon={cilLockLocked} /> <CIcon icon={cilLockLocked} />
</CInputGroupText> </CInputGroupText>
<CFormInput placeholder="Old Password" autoComplete="email" onChange={(e) => setOldPassword(e.target.value)} /> <CFormInput placeholder="Old Password" type="password" onChange={(e) => setOldPassword(e.target.value)} />
</CInputGroup> </CInputGroup>
<CInputGroup className="mb-3"> <CInputGroup className="mb-3">
<CInputGroupText> <CInputGroupText>

View File

@ -31,7 +31,7 @@ const ForgotPassword = () => {
setLoading(true) setLoading(true)
const res = await axios.post(`/api/v1/user/password/forgot`, { email: email }) const res = await axios.post(`/api/v1/user/password/forgot`, { email: email })
//console.log(res); // console.log(res);
if (res.data.success === true) { if (res.data.success === true) {
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")

View File

@ -13,7 +13,7 @@ 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'
const WidgetsDropdown = () => { const WidgetsDropdown = ({ users, category, requirement, news, offer, event }) => {
return ( return (
<CRow> <CRow>
<CCol sm={6} lg={3}> <CCol sm={6} lg={3}>
@ -22,13 +22,10 @@ const WidgetsDropdown = () => {
color="primary" color="primary"
value={ value={
<> <>
26K{' '} {users.length}
{/* <span className="fs-6 fw-normal">
(-12.4% <CIcon icon={cilArrowBottom} />)
</span> */}
</> </>
} }
title="Users" title="Total Users"
// action={ // action={
// <CDropdown alignment="end"> // <CDropdown alignment="end">
// <CDropdownToggle color="transparent" caret={false} className="p-0"> // <CDropdownToggle color="transparent" caret={false} className="p-0">
@ -42,65 +39,65 @@ const WidgetsDropdown = () => {
// </CDropdownMenu> // </CDropdownMenu>
// </CDropdown> // </CDropdown>
// } // }
chart={ // chart={
<CChartLine // <CChartLine
className="mt-3 mx-3" // className="mt-3 mx-3"
style={{ height: '70px' }} // style={{ height: '70px' }}
data={{ // data={{
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], // labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [ // datasets: [
{ // {
label: 'My First dataset', // label: 'My First dataset',
backgroundColor: 'transparent', // backgroundColor: 'transparent',
borderColor: 'rgba(255,255,255,.55)', // borderColor: 'rgba(255,255,255,.55)',
pointBackgroundColor: getStyle('--cui-primary'), // pointBackgroundColor: getStyle('--cui-primary'),
data: [65, 59, 84, 84, 51, 55, 40], // data: [65, 59, 84, 84, 51, 55, 40],
}, // },
], // ],
}} // }}
options={{ // options={{
plugins: { // plugins: {
legend: { // legend: {
display: false, // display: false,
}, // },
}, // },
maintainAspectRatio: false, // maintainAspectRatio: false,
scales: { // scales: {
x: { // x: {
grid: { // grid: {
display: false, // display: false,
drawBorder: false, // drawBorder: false,
}, // },
ticks: { // ticks: {
display: false, // display: false,
}, // },
}, // },
y: { // y: {
min: 30, // min: 30,
max: 89, // max: 89,
display: false, // display: false,
grid: { // grid: {
display: false, // display: false,
}, // },
ticks: { // ticks: {
display: false, // display: false,
}, // },
}, // },
}, // },
elements: { // elements: {
line: { // line: {
borderWidth: 1, // borderWidth: 1,
tension: 0.4, // tension: 0.4,
}, // },
point: { // point: {
radius: 4, // radius: 4,
hitRadius: 10, // hitRadius: 10,
hoverRadius: 4, // hoverRadius: 4,
}, // },
}, // },
}} // }}
/> // />
} // }
/> />
</CCol> </CCol>
<CCol sm={6} lg={3}> <CCol sm={6} lg={3}>
@ -109,157 +106,25 @@ const WidgetsDropdown = () => {
color="info" color="info"
value={ value={
<> <>
$6.200{' '} {category.length}
{/* <span className="fs-6 fw-normal">
(40.9% <CIcon icon={cilArrowTop} />)
</span> */}
</> </>
} }
title="Income" title="Total Categories"
// action={
// <CDropdown alignment="end">
// <CDropdownToggle color="transparent" caret={false} className="p-0">
// <CIcon icon={cilOptions} className="text-high-emphasis-inverse" />
// </CDropdownToggle>
// <CDropdownMenu>
// <CDropdownItem>Action</CDropdownItem>
// <CDropdownItem>Another action</CDropdownItem>
// <CDropdownItem>Something else here...</CDropdownItem>
// <CDropdownItem disabled>Disabled action</CDropdownItem>
// </CDropdownMenu>
// </CDropdown>
// }
chart={
<CChartLine
className="mt-3 mx-3"
style={{ height: '70px' }}
data={{
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [
{
label: 'My First dataset',
backgroundColor: 'transparent',
borderColor: 'rgba(255,255,255,.55)',
pointBackgroundColor: getStyle('--cui-info'),
data: [1, 18, 9, 17, 34, 22, 11],
},
],
}}
options={{
plugins: {
legend: {
display: false,
},
},
maintainAspectRatio: false,
scales: {
x: {
grid: {
display: false,
drawBorder: false,
},
ticks: {
display: false,
},
},
y: {
min: -9,
max: 39,
display: false,
grid: {
display: false,
},
ticks: {
display: false,
},
},
},
elements: {
line: {
borderWidth: 1,
},
point: {
radius: 4,
hitRadius: 10,
hoverRadius: 4,
},
},
}}
/>
}
/> />
</CCol> </CCol>
{/* <CCol sm={6} lg={3}> <CCol sm={6} lg={3}>
<CWidgetStatsA <CWidgetStatsA
className="mb-4" className="mb-4"
color="warning" color="warning"
value={ value={
<> <>
2.49{' '} {requirement.length}
<span className="fs-6 fw-normal">
(84.7% <CIcon icon={cilArrowTop} />)
</span>
</> </>
} }
title="Conversion Rate" title="Requirements"
action={
<CDropdown alignment="end">
<CDropdownToggle color="transparent" caret={false} className="p-0">
<CIcon icon={cilOptions} className="text-high-emphasis-inverse" />
</CDropdownToggle>
<CDropdownMenu>
<CDropdownItem>Action</CDropdownItem>
<CDropdownItem>Another action</CDropdownItem>
<CDropdownItem>Something else here...</CDropdownItem>
<CDropdownItem disabled>Disabled action</CDropdownItem>
</CDropdownMenu>
</CDropdown>
}
chart={
<CChartLine
className="mt-3"
style={{ height: '70px' }}
data={{
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [
{
label: 'My First dataset',
backgroundColor: 'rgba(255,255,255,.2)',
borderColor: 'rgba(255,255,255,.55)',
data: [78, 81, 80, 45, 34, 12, 40],
fill: true,
},
],
}}
options={{
plugins: {
legend: {
display: false,
},
},
maintainAspectRatio: false,
scales: {
x: {
display: false,
},
y: {
display: false,
},
},
elements: {
line: {
borderWidth: 2,
tension: 0.4,
},
point: {
radius: 0,
hitRadius: 10,
hoverRadius: 4,
},
},
}}
/>
}
/> />
</CCol> </CCol>
<CCol sm={6} lg={3}> <CCol sm={6} lg={3}>
@ -268,92 +133,42 @@ const WidgetsDropdown = () => {
color="danger" color="danger"
value={ value={
<> <>
44K{' '} {news.length}
<span className="fs-6 fw-normal">
(-23.6% <CIcon icon={cilArrowBottom} />)
</span>
</> </>
} }
title="Sessions" title="Total News"
action={
<CDropdown alignment="end">
<CDropdownToggle color="transparent" caret={false} className="p-0">
<CIcon icon={cilOptions} className="text-high-emphasis-inverse" />
</CDropdownToggle>
<CDropdownMenu>
<CDropdownItem>Action</CDropdownItem>
<CDropdownItem>Another action</CDropdownItem>
<CDropdownItem>Something else here...</CDropdownItem>
<CDropdownItem disabled>Disabled action</CDropdownItem>
</CDropdownMenu>
</CDropdown>
}
chart={
<CChartBar
className="mt-3 mx-3"
style={{ height: '70px' }}
data={{
labels: [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
'January',
'February',
'March',
'April',
],
datasets: [
{
label: 'My First dataset',
backgroundColor: 'rgba(255,255,255,.2)',
borderColor: 'rgba(255,255,255,.55)',
data: [78, 81, 80, 45, 34, 12, 40, 85, 65, 23, 12, 98, 34, 84, 67, 82],
barPercentage: 0.6,
},
],
}}
options={{
maintainAspectRatio: false,
plugins: {
legend: {
display: false,
},
},
scales: {
x: {
grid: {
display: false,
drawTicks: false,
},
ticks: {
display: false,
},
},
y: {
grid: {
display: false,
drawBorder: false,
drawTicks: false,
},
ticks: {
display: false,
},
},
},
}}
/> />
</CCol>
<CCol sm={6} lg={3}>
<CWidgetStatsA
className="mb-4"
color="success"
value={
<>
{offer.length}
</>
} }
title="Total Offers"
/> />
</CCol> */} </CCol>
<CCol sm={6} lg={3}>
<CWidgetStatsA
className="mb-4"
color="dark"
value={
<>
{event.length}
</>
}
title="Total Events"
/>
</CCol>
</CRow> </CRow>
) )
} }