Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jenil's changes #105

Merged
merged 30 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f0be92f
Added Navbar component to Layout
deveshsawant05 Jul 26, 2024
02f20d9
Fixed Navbar overlapping
deveshsawant05 Jul 26, 2024
169ad3b
Test Workflow
deveshsawant05 Jul 26, 2024
dcfb8c0
Merge branch 'iiitv:new' into new
deveshsawant05 Jul 26, 2024
20607ff
Fixed Navbar overlapping
deveshsawant05 Jul 26, 2024
c408ef5
Merge branch 'new' of https://github.com/deveshsawant05/iiitvcc into new
deveshsawant05 Jul 26, 2024
28f64b8
Merge branch 'new' of https://github.com/deveshsawant05/iiitvcc into new
deveshsawant05 Jul 27, 2024
ab26882
added footer to layout. fixed navbar links prefetch
deveshsawant05 Jul 29, 2024
ab6071a
Merge branch 'iiitv:new' into new
deveshsawant05 Jul 29, 2024
d460013
changed title,changed icon
deveshsawant05 Jul 29, 2024
054aa62
Merge branch 'new' of https://github.com/deveshsawant05/iiitvcc into new
deveshsawant05 Jul 30, 2024
a085e1f
Merge branch 'iiitv:new' into new
deveshsawant05 Jul 31, 2024
a7baab9
Merge branch 'iiitv:new' into new
deveshsawant05 Jul 31, 2024
fd4d577
Added Complete Events Page
deveshsawant05 Aug 5, 2024
0704d7b
Merge branch 'iiitv:new' into new
deveshsawant05 Aug 5, 2024
c5faf4c
Added mobile css for events page, added winners sections
deveshsawant05 Aug 6, 2024
0072de6
Merge branch 'iiitv:new' into new
deveshsawant05 Aug 6, 2024
aac4b58
fixed winners section font
deveshsawant05 Aug 6, 2024
37e62e6
fixed
deveshsawant05 Aug 6, 2024
1b2ae78
Merge branch 'iiitv:new' into new
deveshsawant05 Aug 7, 2024
8dbda73
Added Blogs Page
deveshsawant05 Aug 10, 2024
db0af49
Deleted some temporary files
deveshsawant05 Aug 10, 2024
c181f5a
Merge branch 'iiitv:new' into new
deveshsawant05 Aug 10, 2024
7fdad10
Blogs Page Fixes, Changed Projects to Blogs
deveshsawant05 Aug 11, 2024
bf06dde
Merge branch 'iiitv:new' into new
deveshsawant05 Aug 12, 2024
f0e06bc
Merge branch 'iiitv:new' into new
deveshsawant05 Aug 12, 2024
7e376c2
Merge branch 'iiitv:new' into new
deveshsawant05 Aug 13, 2024
38cf1e6
Added Contact Us page
deveshsawant05 Aug 14, 2024
2e360b0
Merge branch 'iiitv:new' into new
deveshsawant05 Aug 14, 2024
8781ee6
Jenil's Changes
deveshsawant05 Aug 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions src/app/events/page.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
"use client";
import { useEffect, useState } from "react";
import EventBox from "../../components/ui/EventBox";
import { getPublicUrl } from "@/lib/utils"
function Page() {
const [events, setEvents] = useState([]);
const [nextPageEvents, setNextPageEvents] = useState([]);
const [pageCount, setPageCount] = useState(1);
const [hasMoreEvents, setHasMoreEvents] = useState(true);
const [columnCount, setColumnCount] = useState(3);

const fetchEvents = async (page) => {
try {
const response = await fetch(`/api/v1/get/events?page=${page}`);
const data = await response.json();
return data;
} catch (error) {
console.error("Error fetching events:", error);
return [];
}
};

const getMoreEvents = async () => {
setEvents((prevEvents) => [...prevEvents, ...nextPageEvents]);
setPageCount((prev) => prev + 1);

const newEvents = await fetchEvents(pageCount + 2);
if (newEvents.length === 0) {
setHasMoreEvents(false);
} else {
setNextPageEvents(newEvents);
}
};

useEffect(() => {
const loadInitialEvents = async () => {
const firstPageEvents = await fetchEvents(pageCount);
const secondPageEvents = await fetchEvents(pageCount + 1);

setEvents(firstPageEvents);
setNextPageEvents(secondPageEvents);

if (secondPageEvents.length === 0) {
setHasMoreEvents(false);
}
};


const handleResize = () => {
if (window.innerWidth < 768) {
setColumnCount(2);
} else {
setColumnCount(3);
}
};

window.addEventListener("resize", handleResize);
handleResize();
loadInitialEvents();

return () => {
window.removeEventListener("resize", handleResize);
};
}, []);

const columns = Array.from({ length: columnCount }, () => []);

events.forEach((event, index) => {
let posterUrl = getPublicUrl(`/events/${event.id}/poster`)

columns[index % columnCount].push(
<EventBox
img={posterUrl}
key={event.id}
caption={event.description}
time={event.date}
category={event.name}
hostLink={event.host_link}
/>
);
});

return (
<div className="flex flex-col w-full h-full">
<div className="self-center h-fit py-2 w-11/12 flex flex-col bg-[#201f31] mt-4">
<p className="md:pl-12 pt-5 text-2xl font-medium mb-7 ">Events Near</p>
<div className="self-center w-full grid grid-flow-row grid-cols-2 md:grid-cols-3">
{columns.map((column, colIndex) => (
<section
key={colIndex}
className={`h-fit w-full gap-8 py-4 grid grid-flow-row md:pl-12 ${
colIndex === 1 && columnCount === 3 ? "mt-32" : ""
}
${
colIndex === 1 && columnCount === 2 ? "mt-20" : ""
}`
}
>
{column}
</section>
))}
</div>
{hasMoreEvents && (
<button
onClick={getMoreEvents}
className="text-sm md:text-xl hover:border-[#e890bd] text-[#FFBADE] border-[#FFBADE] border-[0.5vh] w-fit px-24 md:px-32 active:scale-95 transition-all duration-100 self-center rounded-3xl py-3"
>
Show More
</button>
)}
</div>
</div>
);
}

export default Page;
34 changes: 34 additions & 0 deletions src/components/ui/EventBox.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from "react";

function EventBox({ time, category, caption, secondCat = false, hostLink , img }) {
return (
<div >
<div style={{
backgroundImage:`url(${img})`,
backgroundPosition:"center",
backgroundRepeat:"no-repeat",
backgroundSize:"cover"
}}
className={`w-11/12 ${
secondCat ? "h-24 md:h-40" : "h-40 md:h-60"
} rounded-3xl ${
secondCat ? "border-[0.1vh]" : "border-[0.4vh] md:border-[1vh]"
} border-[#FFBADE]`}
></div>
<p className="text-[#FFBADE] px-2 md:ml-2 font-mono text-xl md:text-2xl">
{time}
</p>
<p className="text-[#FFBADE] px-2 md:ml-2 font-mono text-nowrap text-xs md:text-xl">
{category}
</p>
<a
href={hostLink}
className="text-white md:ml-2 hover:underline text-center self-center text-xs md:text-2xl px-2 font-semibold"
>
{caption}
</a>
</div>
);
}

export default EventBox;
2 changes: 1 addition & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export function cn(...inputs: ClassValue[]) {
}

export const getPublicUrl = (path: string) => {
return `https://${process.env.PROJECT_ID}.supabase.co/storage/v1/object/public/${process.env.BUCKET}${path}`;
return `https://${process.env.NEXT_PUBLIC_PROJECT_ID}.supabase.co/storage/v1/object/public/${process.env.NEXT_PUBLIC_BUCKET}${path}`;
};
Loading