diff --git a/src/app/[clubname]/page.jsx b/src/app/[clubname]/page.jsx index 7da68f0..5bd1834 100644 --- a/src/app/[clubname]/page.jsx +++ b/src/app/[clubname]/page.jsx @@ -4,6 +4,7 @@ import OurTeam from "@/components/ClubPageComponents/OurTeam"; import OurBlogs from "@/components/ClubPageComponents/OurBlogs"; import Gallery from "@/components/ClubPageComponents/Gallery"; import OurSchedule from "@/components/ClubPageComponents/OurSchedule"; +import { clubCodes } from "@/lib/utils"; const page = ({ params }) => { const club = params.clubname; diff --git a/src/app/actions/AchievementActions.js b/src/app/actions/AchievementActions.js index 30a6177..1c2be5b 100644 --- a/src/app/actions/AchievementActions.js +++ b/src/app/actions/AchievementActions.js @@ -6,6 +6,7 @@ import Achievement from "@/models/achievement"; import { redirect } from "next/navigation"; import { auth } from "@/auth"; import { revalidatePath } from "next/cache"; +import { clubCodes } from "@/lib/utils"; const AchievementSchema = z.object({ title: z.string().min(1, "Title is required."), @@ -15,7 +16,7 @@ const AchievementSchema = z.object({ // Server action to add an achievement export async function addAchievement(prevState, formData) { const session = await auth(); - const club = session?.user.email.split("@")[0]; + const club = clubCodes[session?.user.email.split("@")[0]]; const validatedFields = AchievementSchema.safeParse({ title: formData.get("title"), @@ -63,7 +64,7 @@ export async function addAchievement(prevState, formData) { export async function updateAchievement(prevState, formData) { // Get the user's session and club const session = await auth(); - const club = session?.user.email.split("@")[0]; + const club = clubCodes[session?.user.email.split("@")[0]]; // Extract the achievement ID (assuming it's passed in formData) const achievementId = formData.get("id"); @@ -133,7 +134,7 @@ export async function updateAchievement(prevState, formData) { export async function deleteAchievementById(id) { const session = await auth(); - const club = session?.user.email.split("@")[0]; + const club = clubCodes[session?.user.email.split("@")[0]]; // Connect to the database try { diff --git a/src/app/actions/BlogActions.js b/src/app/actions/BlogActions.js index c84b24e..e8014ea 100644 --- a/src/app/actions/BlogActions.js +++ b/src/app/actions/BlogActions.js @@ -5,6 +5,7 @@ import Blog from "@/models/blog"; import { revalidatePath } from "next/cache"; import { redirect } from "next/navigation"; import { auth } from "@/auth"; +import { clubCodes } from "@/lib/utils"; const FormSchema = z.object({ title: z.string().min(1, "Title is required."), @@ -16,7 +17,7 @@ const FormSchema = z.object({ export async function createBlog(prevState, formData) { const session = await auth(); - const _club = session?.user.email.split("@")[0]; + const _club = clubCodes[session?.user.email.split("@")[0]]; // Validate form using Zod const validatedFields = FormSchema.safeParse({ title: formData.get("title"), @@ -57,7 +58,7 @@ export async function createBlog(prevState, formData) { // here this _id is passed through binding and not directly as it is a sensitive information that may be used mischeviously export async function updateBlog(_id, prevState, formData) { const session = await auth(); - const _club = session?.user.email.split("@")[0]; + const _club = clubCodes[session?.user.email.split("@")[0]]; // Validate form using Zod const validatedFields = FormSchema.safeParse({ title: formData.get("title"), diff --git a/src/app/actions/EventActions.js b/src/app/actions/EventActions.js index cea9187..cee78a8 100644 --- a/src/app/actions/EventActions.js +++ b/src/app/actions/EventActions.js @@ -5,6 +5,7 @@ import Event from "@/models/events"; import { revalidatePath } from "next/cache"; import { redirect } from "next/navigation"; import { auth } from "@/auth"; +import { clubCodes } from "@/lib/utils"; // Define the schema for event validation const EventSchema = z.object({ @@ -18,7 +19,7 @@ const EventSchema = z.object({ // Server action to add an event export async function addEvent(prevState, formData) { const session = await auth(); - const club = session?.user.email.split("@")[0]; + const club = clubCodes[session?.user.email.split("@")[0]]; const validatedFields = EventSchema.safeParse({ date: parseInt(formData.get("date")), @@ -74,7 +75,7 @@ export async function addEvent(prevState, formData) { export async function updateEvent(prevState, formData) { // Get the user's session and club const session = await auth(); - const club = session?.user.email.split("@")[0]; + const club = clubCodes[session?.user.email.split("@")[0]]; // Extract the event index and updated fields from form data @@ -127,7 +128,7 @@ export async function updateEvent(prevState, formData) { export async function deleteEventByDate(date) { const session = await auth(); - const club = session?.user.email.split("@")[0]; + const club = clubCodes[session?.user.email.split("@")[0]]; try { await connectMongoDB(); diff --git a/src/app/actions/GalleryActions.js b/src/app/actions/GalleryActions.js index 369a86b..90396a0 100644 --- a/src/app/actions/GalleryActions.js +++ b/src/app/actions/GalleryActions.js @@ -6,6 +6,7 @@ import { revalidatePath } from "next/cache"; import { redirect } from "next/navigation"; import { auth } from "@/auth"; import { v4 as uuidv4 } from "uuid"; // To generate unique IDs +import { clubCodes } from "@/lib/utils"; const ImageSchema = z.object({ image: z.string().min(1, "Image is required."), @@ -14,7 +15,7 @@ const ImageSchema = z.object({ // Server action to add an image export async function addImage(prevState, formData) { const session = await auth(); - const club = session?.user.email.split("@")[0]; + const club = clubCodes[session?.user.email.split("@")[0]]; const validatedFields = ImageSchema.safeParse({ image: formData.get("image"), @@ -64,7 +65,7 @@ export async function addImage(prevState, formData) { export async function updateGalleryImageURL(prevState, formData) { // Get the user's session and club const session = await auth(); - const club = session?.user.email.split("@")[0]; + const club = clubCodes[session?.user.email.split("@")[0]]; // Extract the image name (UUID) and new URL from form data @@ -119,7 +120,7 @@ export async function updateGalleryImageURL(prevState, formData) { export async function deleteImageByName(imageName) { const session = await auth(); - const club = session?.user.email.split("@")[0]; + const club = clubCodes[session?.user.email.split("@")[0]]; // Connect to the database try { diff --git a/src/app/actions/ProjectActions.js b/src/app/actions/ProjectActions.js index c7c962c..c057c4b 100644 --- a/src/app/actions/ProjectActions.js +++ b/src/app/actions/ProjectActions.js @@ -5,6 +5,7 @@ import Project from "@/models/project"; import { revalidatePath } from "next/cache"; import { redirect } from "next/navigation"; import { auth } from "@/auth"; +import { clubCodes } from "@/lib/utils"; const FormSchema = z.object({ title: z.string().min(1, "Title is required."), @@ -19,7 +20,7 @@ const FormSchema = z.object({ export async function createProject(prevState, formData) { const session = await auth(); - const _club = session?.user.email.split("@")[0]; + const _club = clubCodes[session?.user.email.split("@")[0]]; const validatedFields = FormSchema.safeParse({ title: formData.get("title"), @@ -72,7 +73,7 @@ export async function createProject(prevState, formData) { // here this _id is passed through binding and not directly as it is a sensitive information that may be used mischeviously export async function updateProject(_id, prevState, formData) { const session = await auth(); - const _club = session?.user.email.split("@")[0]; + const _club = clubCodes[session?.user.email.split("@")[0]]; // Validate form using Zod diff --git a/src/app/actions/TeamActions.js b/src/app/actions/TeamActions.js index 0974cee..2d1aa75 100644 --- a/src/app/actions/TeamActions.js +++ b/src/app/actions/TeamActions.js @@ -5,6 +5,7 @@ import TeamMember from "@/models/teamMember"; import { revalidatePath } from "next/cache"; import { redirect } from "next/navigation"; import { auth } from "@/auth"; +import { clubCodes } from "@/lib/utils"; const FormSchema = z.object({ name: z.string().min(1, "Name is required."), @@ -16,7 +17,7 @@ const FormSchema = z.object({ export async function createTeamMember(prevState, formData) { const session = await auth(); - const _club = session?.user.email.split("@")[0]; + const _club = clubCodes[session?.user.email.split("@")[0]]; // Validate form using Zod const validatedFields = FormSchema.safeParse({ name: formData.get("name"), @@ -57,7 +58,7 @@ export async function createTeamMember(prevState, formData) { // Here this _id is passed through binding and not directly as it is a sensitive information that may be used mischievously export async function updateTeamMember(_id, prevState, formData) { const session = await auth(); - const _club = session?.user.email.split("@")[0]; + const _club = clubCodes[session?.user.email.split("@")[0]]; // Validate form using Zod const validatedFields = FormSchema.safeParse({ name: formData.get("name"), diff --git a/src/app/api/blogs/[id]/route.js b/src/app/api/blogs/[id]/route.js index 2549b04..7fd346f 100644 --- a/src/app/api/blogs/[id]/route.js +++ b/src/app/api/blogs/[id]/route.js @@ -13,7 +13,6 @@ export async function PUT(request,{params}){ if (newTitle !== undefined) updatedData.title = newTitle; if (newContent !== undefined) updatedData.content = newContent; if (newAuthor !== undefined) updatedData.author = newAuthor; - if (newClub !== undefined) updatedData.club = newClub; await Blog.findByIdAndUpdate(id, updatedData); return NextResponse.json({message:"blog updated"},{status:200}) } diff --git a/src/app/dashboard/(overview)/page.jsx b/src/app/dashboard/(overview)/page.jsx index 3348ba7..8cf9bad 100644 --- a/src/app/dashboard/(overview)/page.jsx +++ b/src/app/dashboard/(overview)/page.jsx @@ -2,10 +2,11 @@ import React from 'react' import { auth } from '@/auth' import { redirect } from 'next/navigation' import { DashboardHome } from '@/components/ui/DashboardHome' +import { clubCodes } from "@/lib/utils"; const page = async() => { const session=await auth() - const club = session?.user.email.split("@")[0]; + const club = clubCodes[session?.user.email.split("@")[0]]; const isSuperAdmin = process.env.SUPER_ADMIN === club; if(!session){ diff --git a/src/app/dashboard/events/page.jsx b/src/app/dashboard/events/page.jsx index 46464be..06a370a 100644 --- a/src/app/dashboard/events/page.jsx +++ b/src/app/dashboard/events/page.jsx @@ -1,6 +1,7 @@ import { MonthCalendar } from "@/components/Events/Calendar"; import { auth } from "@/auth"; import { getEventsForClub } from "@/app/actions/EventData"; +import { clubCodes } from "@/lib/utils"; const Page = async () => { const monthNames = [ @@ -21,7 +22,7 @@ const Page = async () => { const year = new Date().getFullYear(); const monthName = monthNames[month]; const session = await auth(); - const club = session?.user.email.split("@")[0]; + const club = clubCodes[session?.user.email.split("@")[0]]; const events = await getEventsForClub(club); // console.log(events) diff --git a/src/components/Achievements/table.jsx b/src/components/Achievements/table.jsx index 5c3f10f..290d246 100644 --- a/src/components/Achievements/table.jsx +++ b/src/components/Achievements/table.jsx @@ -12,10 +12,11 @@ import { IconSearch, IconPlus } from "@tabler/icons-react"; // importing Icons f import { getAllAchievements } from "@/app/actions/AchievementData"; import { auth } from "@/auth"; import { DeleteAchievementBtn, UpdateAchievementBtn } from "./buttons"; +import { clubCodes } from "@/lib/utils"; export default async function Table(props) { const session = await auth(); - const club = session?.user.email.split("@")[0]; + const club = clubCodes[session?.user.email.split("@")[0]]; let Achievements = await getAllAchievements(club); let header = props.colData; diff --git a/src/components/Blog/table.jsx b/src/components/Blog/table.jsx index b8370b9..6dcf1ff 100644 --- a/src/components/Blog/table.jsx +++ b/src/components/Blog/table.jsx @@ -12,10 +12,11 @@ import { TableHeader, TableRow, } from "@/components/ui/table"; +import { clubCodes } from "@/lib/utils"; export default async function Table(props) { const session = await auth(); - const club = session?.user.email.split("@")[0]; + const club = clubCodes[session?.user.email.split("@")[0]]; let UserData = await getAllBlogs(club); let header = props.colData; diff --git a/src/components/Gallery/table.jsx b/src/components/Gallery/table.jsx index 76fa826..b2c44eb 100644 --- a/src/components/Gallery/table.jsx +++ b/src/components/Gallery/table.jsx @@ -14,10 +14,11 @@ import Link from "next/link"; import { getAllImages } from "@/app/actions/GalleryData"; import { DeleteGalleryImageBtn, UpdateGalleryImageBtn } from "./buttons"; import { auth } from "@/auth"; +import { clubCodes } from "@/lib/utils"; export default async function Table({ colData }) { const session = await auth(); - const club = session?.user.email.split("@")[0]; + const club = clubCodes[session?.user.email.split("@")[0]]; let UserData = await getAllImages(club); let header = colData; diff --git a/src/components/Navbar/NavDropdown.jsx b/src/components/Navbar/NavDropdown.jsx index eb917bd..5c9de47 100644 --- a/src/components/Navbar/NavDropdown.jsx +++ b/src/components/Navbar/NavDropdown.jsx @@ -2,45 +2,49 @@ import React, { useState } from "react"; import { AnimatePresence, motion } from "framer-motion"; import Link from "next/link"; const NavDropDownData = [ - { - text: "Softcom", - link: "/softcom", - }, { text: "Aeromodelling", link: "/aeromodelling", }, { text: "Automotive", - link: "/automotiveclub ", + link: "/automotive", }, { text: "CIM", - link: "/cimclub", + link: "/cim", }, { - text: "Monochrome", - link: "/monochromeclub", + text: "Coding Club", + link: "/codingclub", }, { - text: "Robotics", - link: "/robotics", + text: "Esportz", + link: "/esportz", }, { - text: "Coding", - link: "/codingclub", + text: "FinCOM", + link: "/fincom", }, { - text: "FINCOM", - link: "/fincom", + text: "Iota Cluster", + link: "/iotacluster", }, { - text: "Zenith", - link: "/zenithclub", + text: "Monochrome", + link: "/monochrome", + }, + { + text: "Robotics", + link: "/robotics", }, { - text: "meadityaraj0001", - link: "/meadityaraj0001", + text: "SoftCom", + link: "/softcom", + }, + { + text: "Zenith", + link: "/zenith", }, ]; diff --git a/src/components/Project/table.jsx b/src/components/Project/table.jsx index 0d6f1cf..89bb787 100644 --- a/src/components/Project/table.jsx +++ b/src/components/Project/table.jsx @@ -14,6 +14,7 @@ import { TableHeader, TableRow, } from "@/components/ui/table"; +import { clubCodes } from "@/lib/utils"; const statusMap = { completed: "Completed", @@ -23,7 +24,7 @@ const statusMap = { export default async function Table(props) { const session = await auth(); - const club = session?.user.email.split("@")[0]; + const club = clubCodes[session?.user.email.split("@")[0]]; let UserData = await getAllProjects(club); let header = props.colData; diff --git a/src/components/Sidenav/Sidenav.jsx b/src/components/Sidenav/Sidenav.jsx index e2ca339..875a0f3 100644 --- a/src/components/Sidenav/Sidenav.jsx +++ b/src/components/Sidenav/Sidenav.jsx @@ -3,9 +3,10 @@ import { handleLogout } from "@/app/actions/authentication"; import Navlinks from "./Navlinks"; import { auth } from "@/auth"; import { IconLogout } from "@tabler/icons-react"; +import { clubCodes } from "@/lib/utils"; const Sidenav = async () => { const session = await auth(); - const club = session?.user.email.split("@")[0]; + const club = clubCodes[session?.user.email.split("@")[0]]; const isSuperAdmin = process.env.SUPER_ADMIN === club; return (