-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(Dashboard): The seller and admin dashboard
- Loading branch information
1 parent
5e6047c
commit 4b6e98c
Showing
26 changed files
with
955 additions
and
124 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import DashNavbar from '@/components/DashNavbar'; | ||
import HeaderDash from '@/components/headerDash'; | ||
import request from '@/utils/axios'; | ||
|
||
function page() { | ||
const [user, setUser] = useState<any>(null); | ||
useEffect(() => { | ||
const categ = async () => { | ||
const responsecat: any = await request.get('/categories'); | ||
const user = localStorage.getItem('profile') || 'no'; | ||
const finalUser = JSON.parse(user); | ||
|
||
setUser(finalUser.User); | ||
}; | ||
categ(); | ||
}, []); | ||
|
||
if (!user) { | ||
return ( | ||
<div className="min-h-screen w-full justify-center items-center flex"> | ||
<div className="border-t-4 border-b-4 border-blue-600 rounded-full w-20 h-20 animate-spin m-auto"></div> | ||
</div> | ||
); | ||
} | ||
return ( | ||
<div className="w-full flex sm:flex-row flex-col"> | ||
<div> | ||
<DashNavbar /> | ||
</div> | ||
<div className="flex-1 sm:pt-5 sm:px-7 "> | ||
<div> | ||
<HeaderDash pageName="Categories Page" /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
'use client'; | ||
import React, { useEffect, useState } from 'react'; | ||
import DashNavbar from '@/components/DashNavbar'; | ||
import HeaderDash from '@/components/headerDash'; | ||
import { unstable_noStore as noStore } from 'next/cache'; | ||
import SellerSummary from '@/components/SellerSummary'; | ||
import Chartssection from '@/components/chartssection'; | ||
import request from '@/utils/axios'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
function page() { | ||
const [categories, setcategoris] = useState([]); | ||
const [user, setUser] = useState<any>(); | ||
const [users, setUsers] = useState<any>(); | ||
|
||
const { data, isLoading, error } = useQuery<any>({ | ||
queryKey: ['data'], | ||
queryFn: async () => { | ||
noStore(); | ||
let data; | ||
const date = new Date(); | ||
const dataDateNow = date | ||
.toLocaleDateString() | ||
.replaceAll('/', '-') | ||
.split('-'); | ||
|
||
const response: any = await request.get( | ||
`http://localhost:5500/api/stats?start=2023-02-06&end=${dataDateNow[2]}-${dataDateNow[0].length > 1 ? dataDateNow[0] : '0' + dataDateNow[0]}-${dataDateNow[1]}`, | ||
); | ||
data = response.data; | ||
|
||
return data; | ||
}, | ||
}); | ||
useEffect(() => { | ||
const categ = async () => { | ||
const responsecat: any = await request.get('/categories'); | ||
const user = localStorage.getItem('profile') || 'no'; | ||
const finalUser = JSON.parse(user); | ||
|
||
setUser(finalUser.User); | ||
if (finalUser.User.Role.name === 'admin') { | ||
const responseUsers: any = await request.get('/users'); | ||
setUsers(responseUsers.users); | ||
} | ||
setcategoris(responsecat.categories); | ||
}; | ||
categ(); | ||
}, []); | ||
if (isLoading) { | ||
return ( | ||
<div className="min-h-screen w-full justify-center items-center flex"> | ||
<div className="border-t-4 border-b-4 border-blue-600 rounded-full w-20 h-20 animate-spin m-auto"></div> | ||
</div> | ||
); | ||
} | ||
return ( | ||
<div className="w-full flex sm:flex-row flex-col fixed "> | ||
<div className="z-10 "> | ||
<DashNavbar role={user.Role.name} /> | ||
</div> | ||
<div className="flex-1 sm:pt-5 sm:px-7 w-full z-10 "> | ||
<div className="mb-3"> | ||
<HeaderDash pageName="Dashboard" /> | ||
</div> | ||
{/* body section */} | ||
<div className="flex justify-center sm:justify-start sm:items-center items-start w-full overflow-auto h-[90vh] fixed sm:relative sm:pb-10 pb-20 z-0"> | ||
{/* Statistic section */} | ||
<div className="w-full flex flex-col gap-5 justify-center items-center sm:justify-start sm:items-start"> | ||
<SellerSummary | ||
user={user} | ||
data={data} | ||
categories={categories} | ||
users={users} | ||
/> | ||
<Chartssection | ||
user={user} | ||
data={data} | ||
categories={categories} | ||
users={users} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use client'; | ||
import React, { useEffect, useState } from 'react'; | ||
import DashNavbar from '@/components/DashNavbar'; | ||
import HeaderDash from '@/components/headerDash'; | ||
import request from '@/utils/axios'; | ||
import ProductsTable from '@/components/Table'; | ||
|
||
function page() { | ||
const [user, setUser] = useState<any>(null); | ||
useEffect(() => { | ||
const categ = async () => { | ||
const responsecat: any = await request.get('/categories'); | ||
const user = localStorage.getItem('profile') || 'no'; | ||
const finalUser = JSON.parse(user); | ||
|
||
setUser(finalUser.User); | ||
}; | ||
categ(); | ||
}, []); | ||
|
||
if (!user) { | ||
return ( | ||
<div className="min-h-screen w-full justify-center items-center flex"> | ||
<div className="border-t-4 border-b-4 border-blue-600 rounded-full w-20 h-20 animate-spin m-auto"></div> | ||
</div> | ||
); | ||
} | ||
return ( | ||
<div className="w-full flex sm:flex-row flex-col"> | ||
<div> | ||
<DashNavbar role={user?.Role?.name} /> | ||
</div> | ||
<div className="flex-1 sm:pt-5 sm:px-7 "> | ||
<div> | ||
<HeaderDash pageName="Products Page" /> | ||
</div> | ||
<div> | ||
<ProductsTable /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use client'; | ||
import React, { useEffect, useState } from 'react'; | ||
import DashNavbar from '@/components/DashNavbar'; | ||
import HeaderDash from '@/components/headerDash'; | ||
import request from '@/utils/axios'; | ||
import ProductPopup from '@/components/AddProducts'; | ||
import { useRouter } from 'next/navigation'; | ||
|
||
function page() { | ||
const [user, setUser] = useState<any>(); | ||
const router = useRouter(); | ||
useEffect(() => { | ||
const categ = async () => { | ||
const responsecat: any = await request.get('/categories'); | ||
const user = localStorage.getItem('profile') || 'no'; | ||
const finalUser = JSON.parse(user); | ||
|
||
setUser(finalUser.User); | ||
if (finalUser?.User.Role.name !== 'seller') { | ||
router.push('/'); | ||
} | ||
}; | ||
categ(); | ||
}, []); | ||
|
||
if (!user) { | ||
return ( | ||
<div className="min-h-screen w-full justify-center items-center flex"> | ||
<div className="border-t-4 border-b-4 border-blue-600 rounded-full w-20 h-20 animate-spin m-auto"></div> | ||
</div> | ||
); | ||
} | ||
return ( | ||
<div className="w-full flex sm:flex-row flex-col fixed"> | ||
<div className="z-10"> | ||
<DashNavbar role={user.Role.name} /> | ||
</div> | ||
<div className="flex-1 sm:pt-5 sm:px-7 h-screen fixed sm:relative w-full z-10 "> | ||
<div className="mb-1"> | ||
<HeaderDash pageName="Create Product Page" /> | ||
</div> | ||
{/* body section */} | ||
<div className="flex justify-center sm:justify-start sm:items-center items-start overflow-auto h-[90vh] fixed sm:relative w-full sm:pb-10 pb-20 z-0"> | ||
{/* Statistic section */} | ||
<div className="w-full relative flex flex-col gap-5 justify-center items-center sm:justify-start sm:items-start"> | ||
<ProductPopup | ||
isOpen={true} | ||
onClose={() => console.log('nothing')} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use client'; | ||
import React, { useEffect, useState } from 'react'; | ||
import DashNavbar from '@/components/DashNavbar'; | ||
import HeaderDash from '@/components/headerDash'; | ||
import request from '@/utils/axios'; | ||
|
||
function page() { | ||
const [user, setUser] = useState<any>(); | ||
useEffect(() => { | ||
const categ = async () => { | ||
const responsecat: any = await request.get('/categories'); | ||
const user = localStorage.getItem('profile') || 'no'; | ||
const finalUser = await JSON.parse(user); | ||
|
||
setUser(finalUser.User); | ||
}; | ||
categ(); | ||
}, []); | ||
if (!user) { | ||
return ( | ||
<div className="min-h-screen w-full justify-center items-center flex"> | ||
<div className="border-t-4 border-b-4 border-blue-600 rounded-full w-20 h-20 animate-spin m-auto"></div> | ||
</div> | ||
); | ||
} | ||
return ( | ||
<div className="w-full flex sm:flex-row flex-col"> | ||
<div> | ||
<DashNavbar role={user?.Role.name} /> | ||
</div> | ||
<div className="flex-1 sm:pt-5 sm:px-7 "> | ||
<div> | ||
<HeaderDash pageName="Profile page" /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use client'; | ||
import React, { use, useEffect, useState } from 'react'; | ||
import DashNavbar from '@/components/DashNavbar'; | ||
import HeaderDash from '@/components/headerDash'; | ||
import request from '@/utils/axios'; | ||
|
||
function page() { | ||
const [user, setUser] = useState<any>(); | ||
useEffect(() => { | ||
const categ = async () => { | ||
const responsecat: any = await request.get('/categories'); | ||
const user = localStorage.getItem('profile') || 'no'; | ||
const finalUser = JSON.parse(user); | ||
|
||
setUser(finalUser.User); | ||
}; | ||
}, []); | ||
return ( | ||
<div className="w-full flex sm:flex-row flex-col"> | ||
<div> | ||
<DashNavbar role={user.Role.name} /> | ||
</div> | ||
<div className="flex-1 sm:pt-5 sm:px-7 "> | ||
<div> | ||
<HeaderDash pageName="Dashboard" /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default page; |
Oops, something went wrong.