Skip to content

Commit 072ba74

Browse files
Links Updated on Navbar Courses Cart
1 parent 35c4880 commit 072ba74

File tree

6 files changed

+227
-404
lines changed

6 files changed

+227
-404
lines changed

components/AdminDashboard.js

+3-231
Original file line numberDiff line numberDiff line change
@@ -1,235 +1,7 @@
1-
import React, { useState } from "react";
2-
import {
3-
Tabs,
4-
Tab,
5-
TabList,
6-
TabPanel,
7-
TabPanels,
8-
TableContainer,
9-
Table,
10-
Thead,
11-
Tr,
12-
Th,
13-
Tbody,
14-
Td,
15-
Button,
16-
Flex,
17-
useToast,
18-
} from "@chakra-ui/react";
19-
import axios from "axios";
20-
import { getItem } from "../redux/localStorage";
1+
import React from "react";
212

22-
const AdminDashboard = (users) => {
23-
const token = getItem("token");
24-
25-
console.log(users);
26-
const toast = useToast();
27-
const handleRequest = (id, status) => {
28-
axios
29-
.patch(
30-
`http://localhost:3000/api/users/${id}`,
31-
{ status: status },
32-
{ headers: { authorization: token } }
33-
)
34-
.then((res) => {
35-
toast({
36-
title: "User Status Updates",
37-
position: "top",
38-
status: "success",
39-
duration: 5000,
40-
isClosable: true,
41-
});
42-
});
43-
};
44-
45-
return (
46-
<Tabs mt="4" colorScheme="pink" isFitted>
47-
<TabList>
48-
<Tab>All Students</Tab>
49-
<Tab>Pending Teachers</Tab>
50-
<Tab>Approved Teachers</Tab>
51-
<Tab>Rejected Teachers</Tab>
52-
</TabList>
53-
<TabPanels>
54-
<TabPanel>
55-
<TableContainer key="4">
56-
<Table variant="striped" colorScheme="pink">
57-
<Thead>
58-
<Tr>
59-
<Th>Name</Th>
60-
<Th>Email</Th>
61-
<Th>Joined on</Th>
62-
</Tr>
63-
</Thead>
64-
<Tbody>
65-
{users.map((ele) => {
66-
let date = new Date(ele.createdAt);
67-
if (ele.role === "student") {
68-
return (
69-
<Tr key={ele.email}>
70-
<Td>{ele.name}</Td>
71-
<Td>{ele.email}</Td>
72-
<Td>{date.toGMTString()}</Td>
73-
</Tr>
74-
);
75-
}
76-
return <Tr key={ele.email}></Tr>;
77-
})}
78-
</Tbody>
79-
</Table>
80-
</TableContainer>
81-
</TabPanel>
82-
83-
<TabPanel>
84-
<TableContainer key="1">
85-
<Table variant="striped" colorScheme="pink">
86-
<Thead>
87-
<Tr>
88-
<Th>Name</Th>
89-
<Th>Email</Th>
90-
<Th>Take Action</Th>
91-
</Tr>
92-
</Thead>
93-
<Tbody>
94-
{data.map((ele) => {
95-
if (ele.role === "teacher" && ele.status === "pending") {
96-
return (
97-
<Tr key={ele.email}>
98-
<Td>{ele.name}</Td>
99-
<Td>{ele.email}</Td>
100-
<Td>
101-
<Flex alignItems={"center"} gap="2">
102-
<Button
103-
variant={"link"}
104-
onClick={() => handleRequest(ele._id, "approved")}
105-
>
106-
Approve
107-
</Button>
108-
{" / "}
109-
<Button
110-
variant={"link"}
111-
onClick={() => handleRequest(ele._id, "rejected")}
112-
>
113-
Reject
114-
</Button>
115-
</Flex>
116-
</Td>
117-
</Tr>
118-
);
119-
}
120-
return <Tr key={ele.email}></Tr>;
121-
})}
122-
</Tbody>
123-
</Table>
124-
</TableContainer>
125-
</TabPanel>
126-
{/* <TabPanel>
127-
<TableContainer key="2">
128-
<Table variant="striped" colorScheme="pink">
129-
<Thead>
130-
<Tr>
131-
<Th>Name</Th>
132-
<Th>Email</Th>
133-
134-
<Th>Take Action</Th>
135-
</Tr>
136-
</Thead>
137-
<Tbody>
138-
{data.map((ele) => {
139-
if (ele.role === "teacher" && ele.status === "approved") {
140-
return (
141-
<Tr key={ele.email}>
142-
<Td>{ele.name}</Td>
143-
<Td>{ele.email}</Td>
144-
<Td>
145-
<Flex alignItems={"center"} gap="2">
146-
<Button
147-
isDisabled
148-
variant={"link"}
149-
onClick={() => handleRequest(ele._id, "approved")}
150-
>
151-
Approve
152-
</Button>
153-
{" / "}
154-
<Button
155-
variant={"link"}
156-
onClick={() => handleRequest(ele._id, "rejected")}
157-
>
158-
Reject
159-
</Button>
160-
</Flex>
161-
</Td>
162-
</Tr>
163-
);
164-
}
165-
return <Tr key={ele.email}></Tr>;
166-
})}
167-
</Tbody>
168-
</Table>
169-
</TableContainer>
170-
</TabPanel>
171-
<TabPanel>
172-
<TableContainer key="3">
173-
<Table variant="striped" colorScheme="pink">
174-
<Thead>
175-
<Tr>
176-
<Th>Name</Th>
177-
<Th>Email</Th>
178-
<Th>Take Action</Th>
179-
</Tr>
180-
</Thead>
181-
<Tbody>
182-
{data.map((ele) => {
183-
if (ele.role === "teacher" && ele.status === "rejected") {
184-
return (
185-
<Tr key={ele.email}>
186-
<Td>{ele.name}</Td>
187-
<Td>{ele.email}</Td>
188-
<Td>
189-
<Flex alignItems={"center"} gap="2">
190-
<Button
191-
variant={"link"}
192-
onClick={() => handleRequest(ele._id, "approved")}
193-
>
194-
Approve
195-
</Button>
196-
{" / "}
197-
<Button
198-
isDisabled
199-
variant={"link"}
200-
onClick={() => handleRequest(ele._id, "rejected")}
201-
>
202-
Reject
203-
</Button>
204-
</Flex>
205-
</Td>
206-
</Tr>
207-
);
208-
}
209-
return <Tr key={ele.email}></Tr>;
210-
})}
211-
</Tbody>
212-
</Table>
213-
</TableContainer>
214-
</TabPanel> */}
215-
</TabPanels>
216-
</Tabs>
217-
);
3+
const AdminDashboard = () => {
4+
return <div>AdminDashboard</div>;
2185
};
2196

2207
export default AdminDashboard;
221-
222-
export async function getServerSideProps(context) {
223-
let res = await axios(`http://localhost:3000/api/users`, {
224-
headers: {
225-
authorization: token,
226-
},
227-
});
228-
let users = res.data;
229-
230-
return {
231-
props: {
232-
users: users,
233-
},
234-
};
235-
}

components/navbar.js

+78-40
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,109 @@
11
import styles from "../styles/Navbar.module.css";
22
import Aos from "aos";
3+
34
import "aos/dist/aos.css";
4-
import { useEffect, useState } from 'react'
5-
import { Drawer, DrawerBody, DrawerContent, DrawerHeader, DrawerOverlay, Link, useDisclosure } from '@chakra-ui/react';
5+
import { useEffect, useState } from "react";
6+
import {
7+
Drawer,
8+
DrawerBody,
9+
DrawerContent,
10+
DrawerHeader,
11+
DrawerOverlay,
12+
Link,
13+
useDisclosure,
14+
} from "@chakra-ui/react";
615
import { FaBars } from "react-icons/fa";
716
import { useRouter } from "next/router";
817

918
export default function Navbar() {
10-
11-
const { isOpen, onOpen, onClose } = useDisclosure()
12-
const [placement, setPlacement] = useState('bottom')
19+
const { isOpen, onOpen, onClose } = useDisclosure();
20+
const [placement, setPlacement] = useState("bottom");
1321
const router = useRouter();
1422

1523
useEffect(() => {
16-
Aos.init({ duration: 2000 })
17-
})
24+
Aos.init({ duration: 2000 });
25+
});
1826

1927
const [text, setText] = useState({
2028
email: "",
21-
password: ""
29+
password: "",
2230
});
2331

2432
const handleForm = (e) => {
2533
setText(e.target.value);
2634
console.log(e.target.value);
27-
}
35+
};
2836

2937
const onClick = () => {
30-
setText("")
31-
}
38+
setText("");
39+
};
3240

3341
return (
3442
<>
35-
3643
<div className={styles.container}>
37-
<div className={styles.box} >
44+
<div className={styles.box}>
3845
<form autoComplete="off" className={styles.form}>
39-
<Link href="/" className={styles.sign}>Home</Link>
40-
<Link href="courses" className={styles.sign}>Courses</Link>
41-
<Link onClick={() => router.push("/signin")} className={styles.sign}>Signin</Link>
42-
<Link onClick={() => router.push("/signup")} className={styles.sign}>Signup</Link>
43-
<Link href="dashboard" className={styles.sign}>Dashboard</Link>
44-
<Link href="cart" className={styles.sign}>Cart</Link>
45-
46-
{/* drawer */}
47-
<FaBars onClick={onOpen} className={styles.bar}/>
48-
<Drawer placement={placement} onClose={onClose} isOpen={isOpen}>
49-
<DrawerOverlay />
50-
<DrawerContent>
51-
52-
<DrawerBody className={styles.draw}>
53-
54-
<Link href="/"><p>Home</p></Link>
55-
<Link href="courses"><p>Courses</p></Link>
56-
<Link onClick={() => router.push("/signin")}><p>Signin</p></Link>
57-
<Link onClick={() => router.push("/signup")}><p>Signup</p></Link>
58-
<Link href="dashboard"><p>Dashboard</p></Link>
59-
<Link href="cart"><p>Cart</p></Link>
60-
</DrawerBody>
61-
</DrawerContent>
62-
</Drawer>
46+
<Link onClick={() => router.push("/")} className={styles.sign}>
47+
Home
48+
</Link>
49+
<Link
50+
onClick={() => router.push("/courses")}
51+
className={styles.sign}
52+
>
53+
Courses
54+
</Link>
55+
<Link
56+
onClick={() => router.push("/signin")}
57+
className={styles.sign}
58+
>
59+
Signin
60+
</Link>
61+
<Link
62+
onClick={() => router.push("/signup")}
63+
className={styles.sign}
64+
>
65+
Signup
66+
</Link>
67+
<Link
68+
onClick={() => router.push("/dashboard")}
69+
className={styles.sign}
70+
>
71+
Dashboard
72+
</Link>
73+
<Link onClick={() => router.push("/cart")} className={styles.sign}>
74+
Cart
75+
</Link>
6376

77+
{/* drawer */}
78+
<FaBars onClick={onOpen} className={styles.bar} />
79+
<Drawer placement={placement} onClose={onClose} isOpen={isOpen}>
80+
<DrawerOverlay />
81+
<DrawerContent>
82+
<DrawerBody className={styles.draw}>
83+
<Link onClick={() => router.push("/")}>
84+
<p>Home</p>
85+
</Link>
86+
<Link onClick={() => router.push("/courses")}>
87+
<p>Courses</p>
88+
</Link>
89+
<Link onClick={() => router.push("/signin")}>
90+
<p>Signin</p>
91+
</Link>
92+
<Link onClick={() => router.push("/signup")}>
93+
<p>Signup</p>
94+
</Link>
95+
<Link onClick={() => router.push("/dashboard")}>
96+
<p>Dashboard</p>
97+
</Link>
98+
<Link onClick={() => router.push("/cart")}>
99+
<p>Cart</p>
100+
</Link>
101+
</DrawerBody>
102+
</DrawerContent>
103+
</Drawer>
64104
</form>
65-
66105
</div>
67106
</div>
68107
</>
69108
);
70-
71-
};
109+
}

0 commit comments

Comments
 (0)