Skip to content

Commit

Permalink
Merge pull request #25 from lugvitc/main
Browse files Browse the repository at this point in the history
Release results
  • Loading branch information
WizzyGeek authored Jul 9, 2024
2 parents fd2d4ef + 57fd227 commit deeb13a
Show file tree
Hide file tree
Showing 7 changed files with 271 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useEffect, useState } from "react"
import { supabase, SessionContext } from "./supabase"
import Book from "./pages/book"
import Level from "./pages/level"
import Result from "./pages/results"

const router = createBrowserRouter(
createRoutesFromElements(
Expand All @@ -18,6 +19,7 @@ const router = createBrowserRouter(
<Route path="apply" element={<Apply />} />
<Route path="book" element={<Book />} />
<Route path="admin" element={<Level />} />
<Route path="result" element={<Result />} />
</Route>
</>
)
Expand Down
95 changes: 92 additions & 3 deletions src/components/background.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Canvas, useFrame } from "@react-three/fiber";
import { useTransform, useScroll, useTime } from "framer-motion";
import { BufferAttribute, Vector3 } from "three";
import { useMemo } from "react";
import { useTransform, useScroll, useTime, useMotionValue,} from "framer-motion";
import { BufferAttribute, DodecahedronGeometry, Vector3 } from "three";
import { useEffect, useMemo } from "react";

function Icosahedron() {
return (
Expand All @@ -12,6 +12,27 @@ function Icosahedron() {
)
};

function Dodecahedron() {
return (
<>
<mesh rotation-x={0} rotation-z={2 * Math.PI}>
<lineSegments>
<edgesGeometry args={[new DodecahedronGeometry()]}>
</edgesGeometry>
<lineBasicMaterial color={rgb(255, 200, 21)}/>
</lineSegments>
</mesh>
{/* <mesh rotation-x={0} rotation-z={2 * Math.PI} scale={0.5}>
<lineSegments>
<edgesGeometry args={[new OctahedronGeometry()]}>
</edgesGeometry>
<lineBasicMaterial color={rgb(250, 70, 21)} linewidth={1} />
</lineSegments>
</mesh> */}
</>
)
};

function randum(from: number, to: number): number {
return Math.random() * (to - from) + from;
}
Expand Down Expand Up @@ -79,6 +100,74 @@ function Scene() {
)
}

function OrbitScene() {
const _scrollYProgress = useMotionValue(0);
const _scrollX = useMotionValue(0);

useEffect(() => {
let y = 0;
let x = 0;
const listener = (ev: MouseEvent) => {
y = ev.clientY / window.innerHeight;
x = ev.clientX / window.innerWidth;
};

const touch_listener = (ev: TouchEvent) => {
y = ev.touches[0].clientY / window.innerHeight;
x = ev.touches[0].clientX / window.innerWidth;
}

const loop = () => {
_scrollYProgress.set(_scrollYProgress.get() + 0.005 * (y - _scrollYProgress.get()));
_scrollX.set(_scrollX.get() + 0.005 * (x - _scrollX.get()));
raf = requestAnimationFrame(loop);
}

document.addEventListener("touchmove", touch_listener);
document.addEventListener("mousemove", listener);
let raf = requestAnimationFrame(loop);
return () => {document.removeEventListener("touchmove", touch_listener); document.removeEventListener("mousemove", listener); cancelAnimationFrame(raf);}
})
// const gl = useThree((state) => state.gl);
// const scrollYProgress = useTransform(_scrollYProgress, [0, 1], [0, 1], {ease: easeInOut});
const yAngle = useTransform(
_scrollYProgress,
[0, 1],
[Math.PI, 0.0000001],
);
const distance = useTransform(_scrollYProgress, [0, 1], [7, 5]);
const time = useTime();

useFrame(({ camera }) => {
camera.position.setFromSphericalCoords(
distance.get(),
yAngle.get(),
time.get() * 0.0001 + (1 - _scrollX.get()) * Math.PI
);
camera.updateProjectionMatrix();
camera.lookAt(0, 0, 0);
});

// useLayoutEffect(() => gl.setPixelRatio(0.5))

return (
<>
<Dodecahedron />
<Dots />
</>
)
}


export function OrbitBackground() {
return (
<Canvas gl={{antialias: true}}>
<OrbitScene />
{/* <axesHelper></axesHelper> */}
</Canvas>
)
}

export default function Background() {
return (
<Canvas gl={{antialias: true}}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function NavBar() {
</div>
<div className=" flex justify-center items-center gap-4 sm:gap-8">
<Link to="/">Home</Link>
<Link to="/book">Book</Link>
<Link to="/result">Results</Link>
{session !== null ? (
<button
onClick={() =>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/book.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const CountContext = createContext<number>(0);

// const released: Set<string> = new Set(["cont", "mms"]);

const departments = Object.assign({ tech: "Technical" }, _d);
export const departments = Object.assign({ tech: "Technical" }, _d);

interface App {
id: number;
Expand Down
4 changes: 3 additions & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Card from "../components/Card";
import "./index.scss";

export const rec_open = false;
export const results = !rec_open && true;

export default function Root() {
// const txtsh = "0px 0px 2px rgb(250 204 21)";
Expand All @@ -23,7 +24,8 @@ export default function Root() {
Elite
</span>
</div>
{!rec_open ? (<div className=" w-52 font-semibold">Recruitments are closed <br />Join the <a href="https://chat.whatsapp.com/KdZQ7vmM4JSFjTJSx7togp" className=" underline text-blue-500">whatsapp group</a> if you have applied</div>) : null}
{/* <br />Join the <a href="https://chat.whatsapp.com/KdZQ7vmM4JSFjTJSx7togp" className=" underline text-blue-500">whatsapp group</a> if you have applied */}
{!rec_open ? (<div className=" w-52 font-semibold">{results ? ("Results are released!") : ("Recruitments are closed")}</div>) : null}
<Link
aria-disabled="true"
to="/apply"
Expand Down
101 changes: 101 additions & 0 deletions src/pages/results.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { SessionContext, supabase } from "../supabase";

import { useContext, useEffect, useState } from "react";
import { OrbitBackground } from "../components/background";
import { Navigate } from "react-router-dom";
import { departments as deplookup } from "./book";



const lookup = Object.assign(deplookup, {
meda_social: "media",
media_des: "media",
media_photo: "media"
})

interface App {
id: number;
dep: keyof (typeof lookup);
selected: boolean;
};

export default function Result() {
const [loaded, setLoaded] = useState(false);
const session = useContext(SessionContext);
const [dep, setDep] = useState<App[]>([]);

const departments = Array.from((new Set(dep.map((v) => (lookup[v.dep] || "").toLowerCase()))).values());

useEffect(() => {
if (session === null) return
// This stuff should be in a loader
supabase
.from("applicants")
.select("id,dep,selected")
.eq("email", session!.user!.email!)
.then((records) => {
setDep(records.data as App[] || []) // TODO validation
setLoaded(true);
});

}, [session?.user?.email]);

if (session === null) {
localStorage.setItem("redirect", "/result");
return <Navigate to={"/auth"} />
}

return (
<>
<div className="h-screen fixed top-0 -z-10 w-full">
<div className=" h-screen w-full bg-transparent">
<OrbitBackground />
</div>
</div>
<section className="flex justify-center items-center pb-[var(--nav-height)]">
<div className={"p-4 bg-[#000000ab] min-w-44 max-w-[340px]"}>
{loaded ? (
<>
<h1 className="text-5xl uppercase font-mono">
{
departments.length > 0 ? (
<>
You <br />were <br />
<span className=" italic text-yellow-400 font-semibold">
Accepted
</span>
</>
) : (
<>Better Luck <br /><span className=" italic text-yellow-400 font-semibold">next</span> time</>
)
}

</h1>
<div className="text-sm">
{
departments.length > 0 ?
(departments.length > 1 ? (
<>
Congratulations! you were accepted into the <span className=" italic text-yellow-400 font-semibold">{departments.slice(1, -1).reduce((acc, v) => acc + ", " + v, departments[0])}</span> and <span className=" italic text-yellow-400 font-semibold">{departments[departments.length - 1]}</span> department
<br/>We are so excited to have you on board, we will contact you soon!
</>
) : (
<>
Congratulations! you were accepted into the <span className=" italic text-yellow-400 font-semibold">{departments[0]}</span> department.
<br/>We are so excited to have you on board, we will contact you soon!
</>
)) : (
<>Although you were not accepted this time, you still have a long journey ahead of you. <span className="italic">Stay passionate about the things you love &lt;3</span>
{/* <br/><span className="text-xs">And keep following us for more awesome events to come!</span> */}
</>
)
}
</div>
</>) : (
"Loading"
)}
</div>
</section>
</>
)
}
74 changes: 71 additions & 3 deletions src/supabase.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type Database = {
id: number
name: string
regno: string
selected: boolean
shortlisted: boolean
slot: number | null
}
Expand All @@ -31,6 +32,7 @@ export type Database = {
id?: number
name?: string
regno?: string
selected?: boolean
shortlisted?: boolean
slot?: number | null
}
Expand All @@ -43,6 +45,7 @@ export type Database = {
id?: number
name?: string
regno?: string
selected?: boolean
shortlisted?: boolean
slot?: number | null
}
Expand All @@ -56,6 +59,53 @@ export type Database = {
},
]
}
applicants_archive: {
Row: {
contact: string
created_at: string
dep: string
email: string
formdata: Json
id: number
name: string
regno: string
shortlisted: boolean
slot: number | null
}
Insert: {
contact?: string
created_at?: string
dep: string
email?: string
formdata?: Json
id?: number
name?: string
regno?: string
shortlisted?: boolean
slot?: number | null
}
Update: {
contact?: string
created_at?: string
dep?: string
email?: string
formdata?: Json
id?: number
name?: string
regno?: string
shortlisted?: boolean
slot?: number | null
}
Relationships: [
{
foreignKeyName: "applicants_archive_slot_fkey"
columns: ["slot"]
isOneToOne: false
referencedRelation: "slots"
referencedColumns: ["id"]
},
]
}
bookedpvt: {
Row: {
contact: string | null
Expand Down Expand Up @@ -88,22 +138,28 @@ export type Database = {
}
levels: {
Row: {
completed: boolean | null
created_at: string
email: string
id: number
level: number | null
level: number
tg: boolean | null
}
Insert: {
completed?: boolean | null
created_at?: string
email: string
id?: number
level?: number | null
level?: number
tg?: boolean | null
}
Update: {
completed?: boolean | null
created_at?: string
email?: string
id?: number
level?: number | null
level?: number
tg?: boolean | null
}
Relationships: []
}
Expand Down Expand Up @@ -152,6 +208,18 @@ export type Database = {
}
Relationships: []
}
tg: {
Row: {
email: string
}
Insert: {
email: string
}
Update: {
email?: string
}
Relationships: []
}
}
Views: {
[_ in never]: never
Expand Down

0 comments on commit deeb13a

Please sign in to comment.