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

Updates Photos on activities page #185

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
47 changes: 41 additions & 6 deletions app/(default)/api/hustle/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,30 @@ export async function POST() {
process.env.VJUDGE_CONTEST_API ||
"https://vjudge.net/contest/data?draw=2&start=0&length=20&sortDir=desc&sortCol=0&category=mine&running=3&title=&owner=Pbhustle&_=1733642420751";

const { data } = await axios.get(API_URL);
// Add headers to mimic a browser request
const headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'en-US,en;q=0.9',
'Referer': 'https://vjudge.net/',
'Origin': 'https://vjudge.net',
'Cookie': process.env.VJUDGE_COOKIE || 'JSESSlONID=7YP9VCUCK4ZTTTNQO0U0OQFW6ZDHMJXV; _ga=GA1.1.533089565.1728634731; Jax.Q=04yash|PMVRLFQGIPE5GOTC1SGE6B4W785LQJ; __gads=ID=99f1126d6fe46914:T=1728634731:RT=1737718428:S=ALNI_Mb_KPRQ0uquyzQSN44fpJKwUo53GA; __gpi=UID=00000f3e7503e3cd:T=1728634731:RT=1737718428:S=ALNI_Mb0ueGqLg2jRi_frTwTAZsUQqg_wQ; __eoi=ID=9732350f6625bc1b:T=1728634731:RT=1737718428:S=AA-AfjZnX0ZhSiL1BHBPEMWVFpeh; cf_clearance=rHe4M.4i47txtgYJQPXs0a.LnH.QYSRELQUQKvBeHv0-1737728607-1.2.1.1-QS6DaWVn4ZlR0CDzelDl644mlMOCZU1ty_NqdHf68O5PjZEOniNFWXUEEk3GrVQj0CwVlOScM6DpclcDaZKTv39_vxVd.tdzDDdfI3hBk.BKBOopC_pgojfmWDpHxvMqGBJbqfcoq36wQJQchRX4B0.IUalcf8OnqtyKwFa6mOj1a1oNoBst3jz_nVLMzWjzzQsxtJmhLlSGveAigCmovzVeHuJsXGSGifWipcLBKO2U_QCnzDVWlZ5N0Rqs7qlOPhzT9xmvceNQGlIZLoINYpq5_WyfCbumeC6XsX0i.H4; FCNEC=%5B%5B%22AKsRol-aSOdWtkNjxLPUwAZiyc5kmxDI81NA-AWYxiD_dMfHxJZ0hX5MBVRm9H0Pb0bLbRu7vmWOG3ZJAKwynbFz-3CLj98y_Ps-u7uC3PX4myF02jFz23muu0K9r3Xot0YQRKs-gKcJoQetbuaLAVrOLTIdtXKr4w%3D%3D%22%5D%5D; JSESSIONID=E55418E82CB952060BE04F7A459FD1FF; _ga_374JLX1715=GS1.1.1737728605.51.1.1737729138.60.0.0',
};

const { data } = await axios.get(API_URL, { headers });

if (!data || !data.data || !data.data[0]) {
console.error("Invalid response format from VJudge");
return NextResponse.json({
error: "Invalid response from VJudge",
details: "No contest data available"
}, { status: 400 });
}

const ccode = data.data[0][0];
const { data: rankData } = await axios.get(
`https://vjudge.net/contest/rank/single/${ccode}`
`https://vjudge.net/contest/rank/single/${ccode}`,
{ headers }
);

const leaderboardDoc = await LeaderboardModel.findOne({
Expand Down Expand Up @@ -113,8 +133,19 @@ export async function POST() {
message: "Leaderboard updated successfully",
rankings: leaderboardRankings,
});
} catch (error) {
return NextResponse.json({ error: "Failed to update leaderboard" });
} catch (error: any) {
if (axios.isAxiosError(error)) {
console.error("API Error:", error.response?.data || error.message);
} else {
console.error("API Error:", error);
}
return NextResponse.json({
error: "Failed to update leaderboard",
details: error.response?.data || error.message,
status: error.response?.status || 500
}, {
status: error.response?.status || 500
});
}
}

Expand All @@ -133,7 +164,11 @@ export async function GET() {
leaderboard: leaderboardDoc,
},
});
} catch (error) {
return NextResponse.json({ error: "Failed to fetch hustle data" });
} catch (error: any) {
console.error("Database error:", error);
return NextResponse.json({
error: "Failed to fetch hustle data",
details: error.message
}, { status: 500 });
}
}
6 changes: 3 additions & 3 deletions components/activities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ const activityData: ActivityData[] = [
{
Title: "Hackathons",
Subtitle: "Smart India Hackathon",
Image: "/images/hack.jpg",
Image: "/images/SIH_2024.jpg",
Description:
"Each year, we organize the internal round of the Smart India Hackathon. In the 2020 edition, over 300+ individuals from DSCE participated. Two of our teams advanced to the finals, with one emerging as the winner of the software edition. Along with this, teams from Point Blank have won hackathons all across the city and country.",
"Each year, we organize the internal round of the Smart India Hackathon. In the 2024 edition, over 300+ individuals from DSCE participated. Two of our teams advanced to the finals, with one emerging as the winner of the software edition. Along with this, teams from Point Blank have won hackathons all across the city and country.",
},
{
Title: "Cybersecurity",
Subtitle: "PB CTF",
Image: "/images/ctf.jpg",
Image: "/images/ctf2.jpg",
Description:
"We organize workshops and sessions on various topics in cybersecurity, including hands-on practice on different platforms. In 2023, we launched the first in-house Capture The Flag event, PBCTF, which attracted over 70+ participants.",
},
Expand Down
Binary file added public/images/SIH_2024.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/images/ctf.jpg
Binary file not shown.
Binary file added public/images/ctf2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/images/hack.jpg
Binary file not shown.
Loading