From a91583783145922b8e851b761708433ad5ff38d3 Mon Sep 17 00:00:00 2001 From: Aswanth Vc Date: Tue, 13 Feb 2024 00:22:00 +0530 Subject: [PATCH] feat(admin) : participants list and dowwnload participant list --- firebase.json | 35 +- src/App.tsx | 4 + src/apis/eventApi.tsx | 26 +- src/apis/userApi.tsx | 16 + src/components/counter/Counter.tsx | 13 +- src/main.tsx | 19 +- .../admin/admin_pages/about/AboutVijnana.tsx | 114 +++++++ .../admin_pages/view_events/ViewEvents.tsx | 26 +- .../view_events/participants.module.css | 12 + .../admin_pages/view_events/participants.tsx | 320 ++++++++++++++++++ src/pages/home/Home.tsx | 2 +- src/utils/types.tsx | 10 + 12 files changed, 568 insertions(+), 29 deletions(-) create mode 100644 src/pages/admin/admin_pages/about/AboutVijnana.tsx create mode 100644 src/pages/admin/admin_pages/view_events/participants.module.css create mode 100644 src/pages/admin/admin_pages/view_events/participants.tsx diff --git a/firebase.json b/firebase.json index 158d60d6..9913132e 100644 --- a/firebase.json +++ b/firebase.json @@ -1,13 +1,26 @@ { - "hosting": { - "public": "dist", - "site": "vijnana24", - "ignore": ["firebase.json", "**/.*", "**/node_modules/**"], - "rewrites": [ - { - "source": "**", - "destination": "/index.html" - } - ] - } + "hosting": [ + { + "public": "dist", + "site": "vijnana24", + "ignore": ["firebase.json", "**/.*", "**/node_modules/**"], + "rewrites": [ + { + "source": "**", + "destination": "/index.html" + } + ] + }, + { + "public": "dist", + "site": "vijnana", + "ignore": ["firebase.json", "**/.*", "**/node_modules/**"], + "rewrites": [ + { + "source": "**", + "destination": "/index.html" + } + ] + } + ] } diff --git a/src/App.tsx b/src/App.tsx index 6c96e2e5..92df59a1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -31,6 +31,8 @@ import UserList from "./pages/admin/admin_pages/users_list/UserList"; import RequestLog from "./pages/admin/admin_pages/request_log/RequestLog"; import ErrorLog from "./pages/admin/admin_pages/error_log/ErrorLog"; import AddAdmin from "./pages/admin/admin_pages/add_admin/AddAdmin"; +import AboutVijnana from "./pages/admin/admin_pages/about/AboutVijnana"; +import Participants from "./pages/admin/admin_pages/view_events/participants"; function getTheme() { var theme = localStorage.getItem("theme"); @@ -190,12 +192,14 @@ function App() { > }> }> + }> }> }> }> }> }> }> + }> }> diff --git a/src/apis/eventApi.tsx b/src/apis/eventApi.tsx index 511fcfc7..2e1139d7 100644 --- a/src/apis/eventApi.tsx +++ b/src/apis/eventApi.tsx @@ -1,4 +1,4 @@ -import { _EventInfo } from "../utils/types"; +import { _AboutVijnana, _EventInfo } from "../utils/types"; import { ApiResponse, ResponseStatus, @@ -7,6 +7,30 @@ import { validateResponse, } from "./api"; +/* + + getAboutVijnana() function returns the about vijnana from the backend. + @param setLoading: (status: boolean) => void + @param setToast: (status: boolean, message: string | null, hideAfter: number | null) => void + @returns _EventInfo | null + +*/ + +export const getAboutVijnana = async ( + addLoader: (loader: Promise) => void +): Promise<_AboutVijnana | null> => { + var res = publicRouter.get("/api/v2/events/aboutVijnana"); + addLoader(res); + var val = await validateResponse(res); + if (val.status == ResponseStatus.SUCCESS) { + if (val.contentType == ResponseType.DATA) { + var data = val.data.data as _AboutVijnana; + return data; + } + } + return null; +}; + /* registerEvent() function registers an event to the backend. diff --git a/src/apis/userApi.tsx b/src/apis/userApi.tsx index f57e22a9..8a952ab1 100644 --- a/src/apis/userApi.tsx +++ b/src/apis/userApi.tsx @@ -13,6 +13,22 @@ import { validateResponse, } from "./api"; +export const userDetailsAdmin = async ( + userId: string, + addLoader: (loader: Promise) => void +): Promise<_UserDetails | null> => { + var res = publicRouter.get(`/api/v2/users/user-details/?userId=${userId}`); + addLoader(res); + var val = await validateResponse(res); + if (val.status == ResponseStatus.FAILED) { + return null; + } + if (val.contentType == ResponseType.DATA) { + return val.data.data as _UserDetails; + } + return null; +}; + /* STATUS AND DETAILS ENDPOINT */ export const userDetails = async ( diff --git a/src/components/counter/Counter.tsx b/src/components/counter/Counter.tsx index 79b72ef8..0352573d 100644 --- a/src/components/counter/Counter.tsx +++ b/src/components/counter/Counter.tsx @@ -13,11 +13,14 @@ function calculateTimeDifference( const timeDifference = date2.getTime() - date1.getTime(); // Calculate days, hours, and minutes - const days = Math.floor(timeDifference / (1000 * 60 * 60 * 24)); - const hours = Math.floor( + var days = Math.floor(timeDifference / (1000 * 60 * 60 * 24)); + var hours = Math.floor( (timeDifference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60) ); - const minutes = Math.floor((timeDifference % (1000 * 60 * 60)) / (1000 * 60)); + var minutes = Math.floor((timeDifference % (1000 * 60 * 60)) / (1000 * 60)); + days = days < 0 ? 0 : days; + hours = hours < 0 ? 0 : hours; + minutes = minutes < 0 ? 0 : minutes; return { days, hours, minutes }; } @@ -40,7 +43,7 @@ const Counter: React.FC = ({ date, className }) => { d: days, h: hours, m: minutes, - s: 60 - now.getSeconds(), + s: days == 0 && hours == 0 && minutes == 0 ? 0 : 60 - now.getSeconds(), }); }, []); setTimeout(() => { @@ -51,7 +54,7 @@ const Counter: React.FC = ({ date, className }) => { d: days, h: hours, m: minutes, - s: 60 - now.getSeconds(), + s: days == 0 && hours == 0 && minutes == 0 ? 0 : 60 - now.getSeconds(), }); // console.log(diff); }, 1000); diff --git a/src/main.tsx b/src/main.tsx index 9ed4a519..5ac61319 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,4 +1,3 @@ -import React from "react"; import ReactDOM from "react-dom/client"; import App from "./App.tsx"; import "./index.css"; @@ -7,13 +6,13 @@ import LoaderStateProvider from "./components/toploader/useLoader.tsx"; import ToastStateProvider from "./components/toast/useToast.tsx"; ReactDOM.createRoot(document.getElementById("root")!).render( - - - - - - - - - + // + + + + + + + + // ); diff --git a/src/pages/admin/admin_pages/about/AboutVijnana.tsx b/src/pages/admin/admin_pages/about/AboutVijnana.tsx new file mode 100644 index 00000000..f8d2afb3 --- /dev/null +++ b/src/pages/admin/admin_pages/about/AboutVijnana.tsx @@ -0,0 +1,114 @@ +import React, { useEffect, useState } from "react"; +import { + _AboutVijnana, + _Event, + _EventCreateData, +} from "../../../../utils/types"; +import { getAboutVijnana } from "../../../../apis/eventApi"; +import { useLoader } from "../../../../components/toploader/useLoader"; + +const AboutVijnana: React.FC = () => { + const [formData, setFormData] = useState<_AboutVijnana>({ + name: "", + start: "", + end: "", + about: "", + contact: "", + email: "", + }); + const { addLoader } = useLoader(); + useEffect(() => { + getAboutVijnana(addLoader).then((res) => { + res && setFormData(res); + }); + }, []); + return ( +
+

+ About Vijana +

+ {"" + formData} +

EDIT NOT IMPLEMENTED

+ {/*
+
+ + +
+
+ + +
+
+ + +
+
+ +