Skip to content

Commit

Permalink
feature : dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Atuldubey98 committed Mar 31, 2024
1 parent 2084fbd commit e9346bf
Show file tree
Hide file tree
Showing 21 changed files with 125 additions and 279 deletions.
7 changes: 7 additions & 0 deletions backend/src/controllers/dashboard.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,17 @@ exports.getDashboard = requestAsyncHandler(async (req, res) => {
.populate("party", "name")
.limit(5)
.exec();
const recentPurchases = await Purchase.find({ org: orgId })
.sort({ createdAt: -1 })
.select("name purchaseNo total totalTax status party date")
.populate("party", "name")
.limit(5)
.exec();
return res.status(200).json({
data: {
invoiceThisMonth,
quotesThisMonth,
recentPurchases,
expensesThisMonth,
partysThisMonth,
recentInvoices,
Expand Down
74 changes: 0 additions & 74 deletions backend/src/mock-database/api/bills.js

This file was deleted.

26 changes: 0 additions & 26 deletions backend/src/mock-database/api/customers.js

This file was deleted.

Empty file.
12 changes: 0 additions & 12 deletions backend/src/mock-database/api/organization.js

This file was deleted.

31 changes: 0 additions & 31 deletions backend/src/mock-database/api/products.js

This file was deleted.

27 changes: 0 additions & 27 deletions backend/src/mock-database/api/users.js

This file was deleted.

53 changes: 0 additions & 53 deletions backend/src/mock-database/index.js

This file was deleted.

8 changes: 4 additions & 4 deletions frontend/src/features/common/form-drawer-layout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export default function FormDrawerLayout({
return (
<Drawer size={"md"} isOpen={isOpen} placement="right" onClose={onClose}>
<DrawerOverlay />
<DrawerContent>
<form onSubmit={handleFormSubmit}>
<form onSubmit={handleFormSubmit}>
<DrawerContent>
<DrawerCloseButton />
<DrawerHeader>{formHeading}</DrawerHeader>
<Divider />
Expand All @@ -36,8 +36,8 @@ export default function FormDrawerLayout({
{formBtnLabel}
</Button>
</DrawerFooter>
</form>
</DrawerContent>
</DrawerContent>
</form>
</Drawer>
);
}
2 changes: 1 addition & 1 deletion frontend/src/features/common/main-layout/AvatarProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function AvatarProfile() {
user?.name
} (${role.toLocaleUpperCase()})`}</Text>
</Hide>
<Avatar name={user?.name} />
<Avatar size={"sm"} name={user?.name} />
</Flex>
);
}
12 changes: 10 additions & 2 deletions frontend/src/features/common/main-layout/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Box,
Button,
Flex,
IconButton,
Show,
Text,
useColorMode,
Expand Down Expand Up @@ -33,6 +34,7 @@ export default function Header({ onSideNavOpen }) {
alignItems={"center"}
>
<Button
size={"sm"}
colorScheme="blue"
onClick={() => {
navigate(
Expand All @@ -52,6 +54,7 @@ export default function Header({ onSideNavOpen }) {
</Show>
</Button>
<Button
size={"sm"}
colorScheme="blue"
onClick={openQuickAccess}
variant="outline"
Expand All @@ -61,15 +64,20 @@ export default function Header({ onSideNavOpen }) {
<Text marginLeft={3}>Quick Access</Text>
</Show>
</Button>
{colorMode === "dark" ? (
<IconButton
size={"sm"}
icon={colorMode === "dark" ? <MdOutlineWbSunny /> : <CiDark />}
onClick={toggleColorMode}
/>
{/* {colorMode === "dark" ? (
<MdOutlineWbSunny
onClick={toggleColorMode}
size={28}
cursor={"pointer"}
/>
) : (
<CiDark onClick={toggleColorMode} size={28} cursor={"pointer"} />
)}
)} */}
<Show below="xl">
<AvatarProfileWithOptions />
<MdMenu size={28} cursor={"pointer"} onClick={onSideNavOpen} />
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/common/main-layout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function MainLayout({ children }) {
<Box boxShadow={"md"} p={2}>
<Header onSideNavOpen={onOpen} />
</Box>
<Box minH={"50svh"} overflowY={"auto"}>{children}</Box>
<Box minH={"70svh"} overflowY={"auto"}>{children}</Box>
</Flex>
</Flex>
<NavDrawer isOpen={isOpen} onClose={onClose} />
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/dashboard/DashboardTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function DashboardTable({ heading, tableHeads, tableRows }) {
return (
<Box borderRadius={"md"}>
<Box paddingBlock={5}>
<Heading fontSize={"2xl"}>{heading}</Heading>
<Heading fontSize={"xl"}>{heading}</Heading>
</Box>
<TableContainer>
<Table variant="simple">
Expand Down
24 changes: 23 additions & 1 deletion frontend/src/features/dashboard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Status from "../estimates/list/Status";
import DashboardTable from "./DashboardTable";
import Dashcard from "./Dashcard";
import GuideTourModal from "./GuideTourModal";
import { purchaseStatusList } from "../../constants/purchase";
export default function DashboardPage() {
const [dashboard, setDashboard] = useState({
invoiceThisMonth: 0,
Expand All @@ -28,6 +29,7 @@ export default function DashboardPage() {
expensesThisMonth: 0,
recentInvoices: [],
recentQuotes: [],
recentPurchases: [],
});
const { orgId } = useParams();
const { requestAsyncHandler } = useAsyncCall();
Expand Down Expand Up @@ -80,7 +82,7 @@ export default function DashboardPage() {
return (
<MainLayout>
<Box p={5}>
<Heading>Dashboard</Heading>
<Heading fontSize={"3xl"}>Dashboard</Heading>
<Stack marginBlock={2} spacing={3}>
<Flex justifyContent={"flex-end"} alignItems={"center"}>
<Select
Expand Down Expand Up @@ -166,6 +168,26 @@ export default function DashboardPage() {
tableHeads={["NUM", "Party name", "Total", "Status", "Date"]}
/>
</Skeleton>
<Skeleton isLoaded={!loading}>
<DashboardTable
heading={"Recent Purchases"}
tableRows={dashboard.recentPurchases.map((purchase) => ({
_id: purchase._id,
num: purchase.purchaseNo,
partyName: purchase.party.name,
total: purchase.total,
totalTax: purchase.totalTax,
status: (
<Status
status={purchase.status}
statusList={purchaseStatusList}
/>
),
date: new Date(purchase.date).toISOString().split("T")[0],
}))}
tableHeads={["NUM", "Party name", "Total", "Status", "Date"]}
/>
</Skeleton>
</Stack>
</Stack>
</Box>
Expand Down
Loading

0 comments on commit e9346bf

Please sign in to comment.