From 209d58219ed1c1f412b98f331cd9a4083cd9f701 Mon Sep 17 00:00:00 2001 From: Aswanth Vc Date: Sun, 10 Dec 2023 19:10:12 +0530 Subject: [PATCH 1/3] feat : launch animation and content chaned --- src/pages/launch/Home.tsx | 30 ++++++++++++++++-------- src/pages/launch/LaunchHome.module.css | 32 +++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/src/pages/launch/Home.tsx b/src/pages/launch/Home.tsx index 169e483f..9730fa51 100644 --- a/src/pages/launch/Home.tsx +++ b/src/pages/launch/Home.tsx @@ -1,14 +1,22 @@ import style from "./LaunchHome.module.css"; // import SecondaryButton from '../../components/buttons/secondary_button/SecondaryButton'; import alien from "../../assets/dehill-spacelove-1-dribble.gif"; -import Counter from "../../components/counter/Counter"; -import EventList from "../../components/eventlist/EventList"; -import Footer from "../../components/footer/Footer"; +// import Counter from "../../components/counter/Counter"; +// import EventList from "../../components/eventlist/EventList"; +// import Footer from "../../components/footer/Footer"; import TopBar from "../../components/topbar/topbar"; +import { useState } from "react"; // for build commit interface LaunchHomeProps {} const LaunchHome: React.FC = ({}) => { + var [dots, setDots] = useState("..."); + + setInterval(async () => { + if (dots.length > 2) await setDots(""); + else await setDots(dots + "."); + // setDots(dots); + }, 1000); return (
= ({}) => { NA 2.0 {/* */} - KBM Government College + + KBM Government College Thalassery + - The countdown to awesomeness begins... + Coming Soon + {/* {dots} */} - + /> */}
-
+ {/*

Events


-
+
*/}
); }; diff --git a/src/pages/launch/LaunchHome.module.css b/src/pages/launch/LaunchHome.module.css index 56111b06..ff73b8dd 100644 --- a/src/pages/launch/LaunchHome.module.css +++ b/src/pages/launch/LaunchHome.module.css @@ -1,3 +1,14 @@ +@keyframes blink { + 0% { + opacity: 0; + /* background: red; */ + } + 100% { + opacity: 1; + /* background: green; */ + } +} + @keyframes sparkblink { 0% { opacity: 0; @@ -158,14 +169,29 @@ font-weight: 400; line-height: normal; margin-top: 20px; + text-align: center; } .daysLeft { - /* opacity: 0; */ + opacity: 0; + animation: sparkblink 1s ease-in-out infinite; + animation-delay: 4s; color: var(--color-orange); - font-size: 15px; + font-size: 25px; margin-top: 50px; text-align: center; font-family: Silkscreen; + display: flex; + align-items: center; + justify-content: space-between; + /* width: 300px; */ + & span { + font-family: Silkscreen; + } + .dots { + width: 20px; + display: inline; + text-align: left; + } } } .headerButtons { @@ -236,7 +262,7 @@ } .daysLeft { - font-size: 20px; + font-size: 40px; } } } From 4d2728760e09fcd746741d947220167f2d481d7c Mon Sep 17 00:00:00 2001 From: Aswanth Vc Date: Sun, 10 Dec 2023 23:44:56 +0530 Subject: [PATCH 2/3] feat : admin panel and create event --- src/App.tsx | 5 + src/apis/adminApi.tsx | 35 +++ src/pages/admin/Admin.module.css | 12 + src/pages/admin/Admin.tsx | 42 ++++ .../admin/admin_pages/new_event/NewEvent.tsx | 213 ++++++++++++++++++ src/utils/types.tsx | 14 ++ 6 files changed, 321 insertions(+) create mode 100644 src/apis/adminApi.tsx create mode 100644 src/pages/admin/Admin.module.css create mode 100644 src/pages/admin/Admin.tsx create mode 100644 src/pages/admin/admin_pages/new_event/NewEvent.tsx diff --git a/src/App.tsx b/src/App.tsx index bc03f42b..8776834e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -24,6 +24,8 @@ import { GoogleIdentity, isLoggedIn } from "./utils/utils"; import WhatsappIcon from "./components/whatsapp/Whatsapp"; import Launch from "./pages/launch/launch"; import LaunchHome from "./pages/launch/Home"; +import Admin from "./pages/admin/Admin"; +import NewEvent from "./pages/admin/admin_pages/new_event/NewEvent"; function getTheme() { var theme = localStorage.getItem("theme"); @@ -181,6 +183,9 @@ function App() { // } > + }> + }> + }> diff --git a/src/apis/adminApi.tsx b/src/apis/adminApi.tsx new file mode 100644 index 00000000..bcfacfd4 --- /dev/null +++ b/src/apis/adminApi.tsx @@ -0,0 +1,35 @@ +import { _EventCreateData } from "../utils/types"; +import { + ApiResponse, + ResponseStatus, + ResponseType, + publicRouter, + validateResponse, +} from "./api"; + +export const isAdmin = async (): Promise => { + var res = publicRouter.post("/api/v2/admin/is_admin"); + var val = await validateResponse(res); + if ( + val.status == ResponseStatus.SUCCESS && + val.contentType == ResponseType.DATA + ) { + return (val.data.data as any)["is_admin"] as boolean; + } + return false; +}; + +export const createEvent = async ( + event: _EventCreateData, + setToast: ( + status: boolean, + message: string | null, + hideAfter: number | null + ) => void +): Promise => { + var res = publicRouter.post("/api/v2/events/create", event); + var val = await validateResponse(res); + console.log(val); + setToast(true, val.data.message, 3000); + return val; +}; diff --git a/src/pages/admin/Admin.module.css b/src/pages/admin/Admin.module.css new file mode 100644 index 00000000..eee382c9 --- /dev/null +++ b/src/pages/admin/Admin.module.css @@ -0,0 +1,12 @@ +.admin { + background: wheat; + width: 100vw; + height: 100vh; + padding: 10px; + color: black; + + .content { + height: 100%; + overflow: scroll; + } +} diff --git a/src/pages/admin/Admin.tsx b/src/pages/admin/Admin.tsx new file mode 100644 index 00000000..9f3f7c2e --- /dev/null +++ b/src/pages/admin/Admin.tsx @@ -0,0 +1,42 @@ +import { useEffect, useState } from "react"; +import style from "./Admin.module.css"; +import { Outlet, useNavigate } from "react-router-dom"; +import { isAdmin } from "../../apis/adminApi"; + +interface AdminProps {} + +const Admin: React.FC = ({}) => { + const [admin, setAdmin] = useState(false); + const redirect = useNavigate(); + useEffect(() => { + isAdmin().then((res) => { + setAdmin(res); + if (!res) redirect("/"); + }); + document.head.innerHTML += + ''; + document.head.innerHTML += + ''; + }, []); + return admin ? ( +
+
+

Vijnana Admin

+
    +
  • About Event
  • +
  • Events
  • +
  • Add Event
  • +
  • Add Admin
  • +
  • Users
  • +
+
+
+ +
+
+ ) : ( +
Admin permission required ..
+ ); +}; + +export default Admin; diff --git a/src/pages/admin/admin_pages/new_event/NewEvent.tsx b/src/pages/admin/admin_pages/new_event/NewEvent.tsx new file mode 100644 index 00000000..84186fc5 --- /dev/null +++ b/src/pages/admin/admin_pages/new_event/NewEvent.tsx @@ -0,0 +1,213 @@ +import React, { createElement, useState } from "react"; +import { _Event, _EventCreateData } from "../../../../utils/types"; +import { createEvent } from "../../../../apis/adminApi"; +import { useToast } from "../../../../components/toast/useToast"; + +const NewEvent: React.FC = () => { + const [formData, setFormData] = useState<_EventCreateData>({ + name: "", + description: "", + details: "", + date: "", + type: "", + image: null, + reg_link: null, + venue: "", + gctian_only: false, + is_reg: true, + closed: false, + }); + const { setToastStatus } = useToast(); + const handleChange = ( + e: React.ChangeEvent< + HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement + > + ) => { + console.log(e.target.id, e.target.value); + setFormData({ + ...formData, + [e.target.id]: e.target.value, + }); + }; + + const handleSubmit = async (event: React.FormEvent) => { + event.preventDefault(); + console.log("Form submitted!"); + console.log(formData); + await createEvent(formData, setToastStatus); + }; + + return ( +
+

+ Create New Event +

+
+
+ + +
+
+ +