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" />,
to: '/requirement',
},
{
component: CNavItem,
name: 'FAQs',
icon: <CIcon icon={cilFace} customClassName="nav-icon" />,
to: '/FAQs',
},
// {
// component: CNavItem,
// name: 'FAQs',
// icon: <CIcon icon={cilFace} customClassName="nav-icon" />,
// to: '/FAQs',
// },
{
component: CNavItem,
name: 'Users',

View File

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

View File

@ -1,20 +1,122 @@
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 WidgetsBrand = lazy(() => import('../widgets/WidgetsBrand.js'))
const Dashboard = () => {
const random = (min, max) => {
return Math.floor(Math.random() * (max - min + 1) + min)
}
//1 st
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 (
<>
<WidgetsDropdown />
<WidgetsDropdown users={users} category={category} requirement={requirement} news={news} offer={offer} event={event} />
</>
)

View File

@ -83,7 +83,7 @@ const Register = () => {
<CInputGroupText>
<CIcon icon={cilLockLocked} />
</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 className="mb-3">
<CInputGroupText>

View File

@ -31,7 +31,7 @@ const ForgotPassword = () => {
setLoading(true)
const res = await axios.post(`/api/v1/user/password/forgot`, { email: email })
//console.log(res);
// console.log(res);
if (res.data.success === true) {
setLoading(false)
// 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 { cilArrowBottom, cilArrowTop, cilOptions } from '@coreui/icons'
const WidgetsDropdown = () => {
const WidgetsDropdown = ({ users, category, requirement, news, offer, event }) => {
return (
<CRow>
<CCol sm={6} lg={3}>
@ -22,85 +22,82 @@ const WidgetsDropdown = () => {
color="primary"
value={
<>
26K{' '}
{/* <span className="fs-6 fw-normal">
(-12.4% <CIcon icon={cilArrowBottom} />)
</span> */}
{users.length}
</>
}
title="Users"
// 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-primary'),
data: [65, 59, 84, 84, 51, 55, 40],
},
],
}}
options={{
plugins: {
legend: {
display: false,
},
},
maintainAspectRatio: false,
scales: {
x: {
grid: {
display: false,
drawBorder: false,
},
ticks: {
display: false,
},
},
y: {
min: 30,
max: 89,
display: false,
grid: {
display: false,
},
ticks: {
display: false,
},
},
},
elements: {
line: {
borderWidth: 1,
tension: 0.4,
},
point: {
radius: 4,
hitRadius: 10,
hoverRadius: 4,
},
},
}}
/>
}
title="Total Users"
// 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-primary'),
// data: [65, 59, 84, 84, 51, 55, 40],
// },
// ],
// }}
// options={{
// plugins: {
// legend: {
// display: false,
// },
// },
// maintainAspectRatio: false,
// scales: {
// x: {
// grid: {
// display: false,
// drawBorder: false,
// },
// ticks: {
// display: false,
// },
// },
// y: {
// min: 30,
// max: 89,
// display: false,
// grid: {
// display: false,
// },
// ticks: {
// display: false,
// },
// },
// },
// elements: {
// line: {
// borderWidth: 1,
// tension: 0.4,
// },
// point: {
// radius: 4,
// hitRadius: 10,
// hoverRadius: 4,
// },
// },
// }}
// />
// }
/>
</CCol>
<CCol sm={6} lg={3}>
@ -109,157 +106,25 @@ const WidgetsDropdown = () => {
color="info"
value={
<>
$6.200{' '}
{/* <span className="fs-6 fw-normal">
(40.9% <CIcon icon={cilArrowTop} />)
</span> */}
{category.length}
</>
}
title="Income"
// 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,
},
},
}}
/>
}
title="Total Categories"
/>
</CCol>
{/* <CCol sm={6} lg={3}>
<CCol sm={6} lg={3}>
<CWidgetStatsA
className="mb-4"
color="warning"
value={
<>
2.49{' '}
<span className="fs-6 fw-normal">
(84.7% <CIcon icon={cilArrowTop} />)
</span>
{requirement.length}
</>
}
title="Conversion Rate"
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,
},
},
}}
/>
}
title="Requirements"
/>
</CCol>
<CCol sm={6} lg={3}>
@ -268,92 +133,42 @@ const WidgetsDropdown = () => {
color="danger"
value={
<>
44K{' '}
<span className="fs-6 fw-normal">
(-23.6% <CIcon icon={cilArrowBottom} />)
</span>
{news.length}
</>
}
title="Sessions"
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,
},
},
},
}}
/>
}
title="Total News"
/>
</CCol> */}
</CCol>
<CCol sm={6} lg={3}>
<CWidgetStatsA
className="mb-4"
color="success"
value={
<>
{offer.length}
</>
}
title="Total Offers"
/>
</CCol>
<CCol sm={6} lg={3}>
<CWidgetStatsA
className="mb-4"
color="dark"
value={
<>
{event.length}
</>
}
title="Total Events"
/>
</CCol>
</CRow>
)
}