diff --git a/src/App.css b/src/App.css index 6bf4289a..44a54270 100644 --- a/src/App.css +++ b/src/App.css @@ -8,12 +8,12 @@ /* width */ ::-webkit-scrollbar { - width: 10px; + width: 5px; } /* Track */ ::-webkit-scrollbar-track { - background: #2f6838; + /* background: #2f6838; */ } /* Handle */ diff --git a/src/apis/eventApi.tsx b/src/apis/eventApi.tsx index 1f3adf15..7ea299db 100644 --- a/src/apis/eventApi.tsx +++ b/src/apis/eventApi.tsx @@ -1,5 +1,32 @@ import { _EventInfo } from "../types"; -import { publicRouter } from "./api"; +import { + ResponseStatus, + ResponseType, + publicRouter, + validateResponse, +} from "./api"; + +export const myEvents = async ( + setLoading: (status: boolean) => void, + setToast: ( + status: boolean, + message: string | null, + hideAfter: number | null + ) => void +): Promise<[] | null> => { + setLoading(true); + var res = publicRouter.post("/api/v2/events/myEvents"); + var val = await validateResponse(res); + if (val.status == ResponseStatus.SUCCESS) { + if (val.contentType == ResponseType.DATA) { + var data = val.data.data; + var events: [] = (data as any)["events"]; + return events; + } + } + setToast(true, val.data.message, 3000); + return null; +}; export const getEvents = async ( eventId: string | null | undefined, diff --git a/src/apis/userApi.tsx b/src/apis/userApi.tsx index f4574caf..8c709e5f 100644 --- a/src/apis/userApi.tsx +++ b/src/apis/userApi.tsx @@ -17,7 +17,7 @@ export const userDetails = async ( message: string | null, hideAfter: number | null ) => void -): Promise<{} | null | undefined> => { +): Promise<_UserDetails | null> => { setLoading(true); var res = publicRouter.post("/api/v2/users/details"); var val = await validateResponse(res); @@ -28,7 +28,7 @@ export const userDetails = async ( var step = (val.data.data as any)["step"] as number; localStorage.setItem("step", step + ""); setLoading(false); - return val.data.data as {} | null | undefined; + return val.data.data as _UserDetails; } setLoading(false); return null; diff --git a/src/assets/frlIf.png b/src/assets/frlIf.png new file mode 100644 index 00000000..7bdd0e0f Binary files /dev/null and b/src/assets/frlIf.png differ diff --git a/src/components/usercard/UserCard.module.css b/src/components/usercard/UserCard.module.css new file mode 100644 index 00000000..4866e668 --- /dev/null +++ b/src/components/usercard/UserCard.module.css @@ -0,0 +1,118 @@ +.userCard { + /* width: calc(100% - 40px); */ + width: calc(100% - 40px); + height: 60vw; + max-width: 500px; + max-height: 300px; + padding: 20px; + border-radius: 20px; + position: relative; + background: var(--color-2); + + .top { + width: 100%; + display: flex; + gap: 50px; + align-items: center; + .img { + width: 60px; + height: 60px; + & img { + width: 60px; + height: 60px; + border-radius: 50%; + border: 5px solid var(--color-4); + } + } + + .details { + & span { + display: block; + } + .name { + font-size: 20px; + } + .college { + font-size: 13px; + color: var(--color-4); + } + .course { + font-size: 10px; + color: var(--color-4); + } + } + } + + .bottom { + margin-top: 20px; + .userId { + position: absolute; + background: var(--color-4); + width: calc(100% - 20px); + bottom: 0; + left: 0; + padding: 10px; + border-radius: 0 0 20px 20px; + display: flex; + justify-content: space-between; + color: var(--color-orange); + font-weight: 600; + + .email { + font-size: 13px; + color: var(--color-3); + } + } + .participate { + width: calc(100% - 0px); + height: 100px; + padding: 10px 0; + /* padding: 10px; */ + border-top: 2px solid var(--color-4); + color: var(--color-black); + & h5 { + font-size: 15px; + } + .events { + display: block; + margin-top: 10px; + font-size: 13px; + color: var(--color-green); + + & span { + display: inline-block; + background: var(--color-3); + padding: 5px 10px; + border-radius: 5px; + margin-right: 10px; + } + } + } + } +} + +@media screen and (min-width: 768px) { + .userCard { + .top { + .img { + width: 100px; + height: 100px; + & img { + width: 100px; + height: 100px; + } + } + .details { + .name { + font-size: 30px; + } + .college { + font-size: 20px; + } + .course { + font-size: 15px; + } + } + } + } +} diff --git a/src/components/usercard/UserCard.tsx b/src/components/usercard/UserCard.tsx new file mode 100644 index 00000000..4babd92c --- /dev/null +++ b/src/components/usercard/UserCard.tsx @@ -0,0 +1,61 @@ +import style from "./UserCard.module.css"; +import { _Event, _UserDetails } from "../../types"; +import { useEffect } from "react"; +import defaultProfile from "../../assets/frlIf.png"; + +interface UserCardProps { + details: _UserDetails; + participations: [] | null; +} + +const UserCard: React.FC = ({ details, participations }) => { + // useEffect(() => {}); + var year: string; + if (details.year == 1) year = "1st Year"; + else if (details.year == 2) year = "2nd Year"; + else if (details.year == 3) year = "3rd Year"; + else year = details.year + " Year"; + console.log(participations); + var pars = ""; + if (!participations || participations!.length < 1) + pars = "Not Registered in any events!"; + else { + for (var i = 0; i < participations!.length; i++) { + pars += "" + (participations![i] as any)["name"] + ""; + // if (i < participations!.length - 1) { + // pars += ", "; + // } + } + } + return ( +
+
+
+ +
+
+

{details.name}

+ {details.college} + + {details.course} - {year} + +
+
+
+ + {details.email} + {details.userId}    + +
+
Registered Events
+
+
+
+
+ ); +}; + +export default UserCard; diff --git a/src/pages/dashboard/Dashboard.module.css b/src/pages/dashboard/Dashboard.module.css index b752023f..c22e341c 100644 --- a/src/pages/dashboard/Dashboard.module.css +++ b/src/pages/dashboard/Dashboard.module.css @@ -2,7 +2,26 @@ width: 100%; height: auto; .page { - width: calc(100% - 100px); - padding: 50px; + width: calc(100% - 30px); + padding: 15px; + + .info { + display: block; + margin: 20px 0; + width: calc(100% - 40px); + padding: 20px; + border-radius: 20px; + text-align: center; + background: var(--color-green); + } + } +} + +@media screen and (min-width: 768px) { + .dashboard { + .page { + width: calc(100% - 100px); + padding: 50px; + } } } diff --git a/src/pages/dashboard/Dashboard.tsx b/src/pages/dashboard/Dashboard.tsx index c0019c8b..af0079c5 100644 --- a/src/pages/dashboard/Dashboard.tsx +++ b/src/pages/dashboard/Dashboard.tsx @@ -1,10 +1,14 @@ import style from "./Dashboard.module.css"; import Footer from "../../components/footer/Footer"; -import { useEffect } from "react"; +import { useEffect, useState } from "react"; import { userDetails } from "../../apis/userApi"; import { useLoader } from "../../components/toploader/useLoader"; import { useToast } from "../../components/toast/useToast"; import { useNavigate } from "react-router-dom"; +import { _UserDetails } from "../../types"; +import UserCard from "../../components/usercard/UserCard"; +import EventList from "../../components/eventlist/EventList"; +import { myEvents } from "../../apis/eventApi"; interface DashboardProps { // Dashboard: _Dashboard; } @@ -12,15 +16,19 @@ interface DashboardProps { const Dashboard: React.FC = ({}) => { var { setLoaderStatus } = useLoader(); var { setToastStatus } = useToast(); + const [user, setUserDetails] = useState<_UserDetails | null>(); + const [parEvents, setParEvents] = useState<[] | null>(null); var redirect = useNavigate(); + useEffect(() => { userDetails(setLoaderStatus, setToastStatus).then( - (val: {} | null | undefined) => { + (val: _UserDetails | null) => { + setUserDetails(val); if (!val) { setToastStatus(true, "Please login to continue!", 3000); redirect("/register"); return; - } else if (((val as any)["step"] as number) < 2) { + } else if (val.step < 2) { setToastStatus( true, "Your registration is not complete! Please complete the registration to contine", @@ -29,13 +37,21 @@ const Dashboard: React.FC = ({}) => { redirect("/register/details"); return; } + myEvents(setLoaderStatus, setToastStatus).then((pars) => { + setParEvents(pars); + }); } ); }, []); return (
- Dashboard + {/* Dashboard */} + {user && } + + Please click 'Register' on the events you wish to participate + +
diff --git a/src/pages/event/Event.module.css b/src/pages/event/Event.module.css index ba9e38e8..a33377e1 100644 --- a/src/pages/event/Event.module.css +++ b/src/pages/event/Event.module.css @@ -1,7 +1,7 @@ .event { .page { - width: calc(100% - 100px); - padding: 50px; + width: calc(100% - 30px); + padding: 15px; .image { width: 100%; @@ -42,3 +42,12 @@ } } } + +@media screen and (min-width: 768px) { + .event { + .page { + width: calc(100% - 100px); + padding: 50px; + } + } +} diff --git a/src/types.tsx b/src/types.tsx index a52bfa8a..0c288d63 100644 --- a/src/types.tsx +++ b/src/types.tsx @@ -23,17 +23,17 @@ export type _EventInfo = { teams: any[]; } & _Event; -export type _UserDetails = { - name: string | undefined; - email: string | undefined; - phone: string | undefined; - college: string | undefined; - course: string | undefined; - year: string | undefined; - password: string | undefined; - // dob: Date, - // picture: string | null, -}; +// export type _UserDetails = { +// name: string | undefined; +// email: string | undefined; +// phone: string | undefined; +// college: string | undefined; +// course: string | undefined; +// year: string | undefined; +// password: string | undefined; +// // dob: Date, +// // picture: string | null, +// }; export type _User = { userId: string | null; @@ -50,6 +50,20 @@ export type _User = { expiry: string; }; +/* User Details */ + +export type _UserDetails = { + userId: string; + name: string; + email: string; + picture: string | null; + gctian: boolean; + college: string; + course: string; + year: number; + step: number; +}; + /* User Login Data */ export type _UserLogin = {