Skip to content

Commit

Permalink
Update settings for all clubs, include email associations (some clubs…
Browse files Browse the repository at this point in the history
… have non-standard email addresses)
  • Loading branch information
Nalin-Angrish committed Jul 5, 2024
1 parent eec968f commit a0f1ebb
Show file tree
Hide file tree
Showing 19 changed files with 77 additions and 45 deletions.
1 change: 1 addition & 0 deletions src/app/[clubname]/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions src/app/actions/AchievementActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
Expand All @@ -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"),
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions src/app/actions/BlogActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
Expand All @@ -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"),
Expand Down Expand Up @@ -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"),
Expand Down
7 changes: 4 additions & 3 deletions src/app/actions/EventActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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")),
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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();
Expand Down
7 changes: 4 additions & 3 deletions src/app/actions/GalleryActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
Expand All @@ -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"),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions src/app/actions/ProjectActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
Expand All @@ -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"),
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/app/actions/TeamActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
Expand All @@ -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"),
Expand Down Expand Up @@ -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"),
Expand Down
1 change: 0 additions & 1 deletion src/app/api/blogs/[id]/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/dashboard/(overview)/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
3 changes: 2 additions & 1 deletion src/app/dashboard/events/page.jsx
Original file line number Diff line number Diff line change
@@ -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 = [
Expand All @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion src/components/Achievements/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/components/Blog/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion src/components/Gallery/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
40 changes: 22 additions & 18 deletions src/components/Navbar/NavDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
];

Expand Down
3 changes: 2 additions & 1 deletion src/components/Project/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
TableHeader,
TableRow,
} from "@/components/ui/table";
import { clubCodes } from "@/lib/utils";

const statusMap = {
completed: "Completed",
Expand All @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion src/components/Sidenav/Sidenav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className="flex grow flex-row justify-between overflow-hidden space-x-0 md:flex-col md:space-x-0 md:space-y-2">
Expand Down
3 changes: 2 additions & 1 deletion src/components/Team/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import {
TableHeader,
TableRow,
} from "@/components/ui/table";
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 getAllTeamMembers(club);

let header = colData;
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/DashboardHome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const Footer = () => {
<footer className="mt-12">
<p className="text-center text-zinc-400">
Made with ❤️ by{" "}
<Link href="" className="text-primary hover:underline font-bold tracking-widest">
<Link href="/softcom" className="text-primary hover:underline font-bold tracking-widest">
SoftCom
</Link>
</p>
Expand Down
Loading

0 comments on commit a0f1ebb

Please sign in to comment.