Skip to content

Commit

Permalink
Add dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
h0i5 committed May 28, 2024
1 parent 8e127d7 commit 532bbfa
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 0 deletions.
32 changes: 32 additions & 0 deletions app/dashboard/DetailComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import DarkModeStatus from "../redux/status/darkModeStatus";

const DetailComponent = (props: any) => {
const { detail, value } = props;
const dark = DarkModeStatus();
return (
<div>
<div
className={
dark
? "flex flex-col my-2 mx-5 border-2 border-slate-600 rounded-xl sm:py-10 pr-5 pl-3 sm:pl-10 py-5"
: "flex flex-col my-2 mx-5 border-2 border-red-900 rounded-xl sm:py-10 pr-5 pl-3 sm:pl-10 py-5"
}
>
<p
className={
dark
? "sm:text-3xl text-xl font-bold"
: "sm:text-3xl text-xl text-red-900 font-bold"
}
>
{detail}:
</p>
<p className="sm:text-2xl text-xl text-brown-700 break-words">
{value}
</p>
</div>
</div>
);
};

export default DetailComponent;
51 changes: 51 additions & 0 deletions app/dashboard/Details.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import DarkModeStatus from "../redux/status/darkModeStatus";
import DetailComponent from "./DetailComponent";

const Details = () => {
const dark = DarkModeStatus();
const detailArray = [
"Name",
"Age",
"Batch",
"Course",
"Roll No",
"Username",
"Email",
];
const detailValue = [
"John Doe",
"18",
"2023",
"CSE Core",
"2023 BCX 1234",
"JohnDoe",
"john23bcx1234@ iiitkottayam.ac.in",
];

return (
<div>
<div className="flex ">
<div className="flex flex-col justify-center align-center">
<h1
className={
dark ? "text-3xl my-5 ml-5" : "text-3xl my-5 ml-5 text-red-900"
}
>
Your Details
</h1>
<div className="grid xl:grid-cols-5 lg:grid-cols-4 md:grid-cols-3 sm:grid-cols-3 grid-cols-2 ">
{detailArray.map((detail, index) => (
<DetailComponent
key={index}
detail={detail}
value={detailValue[index]}
/>
))}
</div>
</div>
</div>
</div>
);
};

export default Details;
48 changes: 48 additions & 0 deletions app/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"use client";
import NavBar from "../components/NavBar";
import DarkModeStatus from "../redux/status/darkModeStatus";
import Details from "./Details";

const Dashboard = () => {
const name = "John Doe";
const dark = DarkModeStatus();

return (
<div
className={
dark
? "h-screen overflow-auto flex flex-col bg-gradient-to-b from-[#020024] to-[#020024] text-white transition-all duration-500 ease-in"
: "h-screen overflow-auto flex flex-col bg-gradient-to-b from-amber-100 to-white text-black transition-all duration-500 ease-in"
}
>
<NavBar />
<div>
<h1
className={
dark
? "md:text-4xl text-4xl ml-5 my-10 font-extrabold"
: "md:text-4xl text-4xl ml-5 my-10 font-extrabold text-red-900"
}
>
Welcome, {name}
</h1>
<div>
<Details />
<div className="flex justify-center align-center mt-5">
<button
className={
dark
? "text-white text-xl bg-slate-800 border-0 p-2 rounded-lg flex align-center justify-center mb-10"
: "text-xl bg-red hover:bg-beige-800 border border-red-900 p-2 rounded-lg flex align-center justify-center mb-10"
}
>
Edit Details
</button>
</div>
</div>
</div>
</div>
);
};

export default Dashboard;
2 changes: 2 additions & 0 deletions app/redux/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import darkModeReducer from "./darkMode/darkModeReducers";
import emailReducer from "./email/emailReducers";
import { combineReducers } from "redux";
import formDataReducer from "./formData/formDataReducers";
import userDataReducer from "./userData/userDataReducer";

const allReducers = combineReducers({
darkMode: darkModeReducer,
email: emailReducer,
formData: formDataReducer,
userData: userDataReducer,
});

export default allReducers;
10 changes: 10 additions & 0 deletions app/redux/status/userDataStatus.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { useSelector } from "react-redux";
import { RootState } from "../store";

const UserDataStatus = (): object => {
const data = useSelector((state: RootState) => state.userData);
return data;
};

export default UserDataStatus;

8 changes: 8 additions & 0 deletions app/redux/userData/userDataActions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { UPDATE_DATA } from "./userDataTypes";

export const updateData = (data: object) => {
return {
type: UPDATE_DATA,
payload: data,
};
};
39 changes: 39 additions & 0 deletions app/redux/userData/userDataReducer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { UPDATE_DATA } from "./userDataTypes";

const initialState = {
FormData: {
course: "",
year: "",
rollNumber: "",
collegeEmail: "",
lmsPassword: "",
batch: "",
firstName: "",
lastName: "",
personalEmail: "",
phone: "",
state: "",
port0Username: "",
port0Password: "",
},
};

const userDataReducer = (
state = initialState,
action: {
payload: any;
type: any;
}
) => {
switch (action.type) {
case UPDATE_DATA:
return {
...state,
FormData: action.payload,
};
default:
return state;
}
};

export default userDataReducer;
1 change: 1 addition & 0 deletions app/redux/userData/userDataTypes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const UPDATE_DATA = "UPDATE_DATA";
1 change: 1 addition & 0 deletions app/verify/OTPForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const { convertToAES } = require("@harshiyer/json-crypto");
const OTPForm = () => {
const dark = DarkModeStatus();
const data = useSelector((state: RootState) => state.formData);

const handleSubmit = async (event: FormEvent) => {
event.preventDefault();

Expand Down

0 comments on commit 532bbfa

Please sign in to comment.