generated from Ruler45/Next-Template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Ecell-NITS/bishal_backend
Team Management Backend and Metadata addition
- Loading branch information
Showing
20 changed files
with
449 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Feedback from "./Feedback"; | ||
|
||
// Dynamic Metadata | ||
export async function generateMetadata() { | ||
return { | ||
title: "Feedback | Share Your Experience", | ||
description: "We value your feedback! Share your experience with us.", | ||
openGraph: { | ||
title: "Feedback | Share Your Experience", | ||
description: "We value your feedback! Share your experience with us.", | ||
}, | ||
}; | ||
} | ||
|
||
export default function FeedbackPage() { | ||
return <Feedback />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
"use client"; | ||
|
||
import { useEffect, useState } from "react"; | ||
import Image from "next/image"; | ||
import styles from "./team.module.scss"; | ||
import "../../globals.scss"; | ||
|
||
const Team = () => { | ||
const [teamMembers, setTeamMembers] = useState([]); | ||
const [error, setError] = useState(""); | ||
|
||
useEffect(() => { | ||
const fetchTeamMembers = async () => { | ||
try { | ||
const res = await fetch("/api/v1/getAllTeamMembers", { | ||
method: "GET", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
const data = await res.json(); | ||
|
||
if (!res.ok) { | ||
throw new Error(data.message || "Failed to fetch team members"); | ||
} | ||
setTeamMembers(data.teamMembers); | ||
} catch (err) { | ||
console.error(err.message); | ||
setError("Failed to load team members."); | ||
} | ||
}; | ||
fetchTeamMembers(); | ||
}, []); | ||
|
||
if (error) { | ||
return <p>{error}</p>; | ||
} | ||
|
||
return ( | ||
<div className={styles.teamContainer}> | ||
<h1>Team Members</h1> | ||
<div className={styles.teamGrid}> | ||
{teamMembers.map((member) => { | ||
return ( | ||
<div className={styles.teamCard}> | ||
<Image | ||
className={styles.teamImage} | ||
src={member.image || "/images/placeholder_image.jpg"} | ||
alt={member.name} | ||
width={300} | ||
height={300} | ||
></Image> | ||
<h2 className={styles.teamName}>{member.name}</h2> | ||
<p className={styles.teamRole}>{member.designation}</p> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
export default Team; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,16 @@ | ||
/* eslint-disable @next/next/no-img-element */ | ||
import Team from "./TeamMember"; | ||
|
||
/* eslint-disable import/extensions */ | ||
/* eslint-disable no-unused-vars */ | ||
import Image from "next/image"; | ||
import styles from "./team.module.scss"; | ||
import "../../globals.scss"; | ||
import teamMembers from "../../../../public/data/team.json"; | ||
|
||
const Team = () => { | ||
return ( | ||
<div className={styles.teamContainer}> | ||
<h1>Team Members</h1> | ||
<div className={styles.teamGrid}> | ||
{teamMembers.map((member) => { | ||
return ( | ||
<div className={styles.teamCard}> | ||
<Image | ||
className={styles.teamImage} | ||
src={member.image} | ||
alt={member.name} | ||
width={300} | ||
height={300} | ||
></Image> | ||
<h2 className={styles.teamName}>{member.name}</h2> | ||
<p className={styles.teamRole}>{member.role}</p> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
); | ||
export const metadata = { | ||
title: "Meet Our Team | Dedicated Professionals", | ||
description: | ||
"Get to know our team of dedicated professionals committed to delivering excellence.", | ||
openGraph: { | ||
title: "Meet Our Team | Dedicated Professionals", | ||
description: | ||
"Get to know our team of dedicated professionals committed to delivering excellence.", | ||
}, | ||
}; | ||
export default Team; | ||
|
||
export default function TeamPage() { | ||
return <Team />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import jwt from "jsonwebtoken"; | ||
import moment from "moment-timezone"; | ||
import TeamMember from "../../../../model/TeamMember"; | ||
import dbConnect from "../../../../lib/dbConnect"; | ||
|
||
export interface ITeamMember extends Document { | ||
name: string; | ||
designation: string; | ||
email: string; | ||
linkedin?: string; | ||
image?: string; | ||
createdAt: Date; | ||
updatedAt: Date; | ||
} | ||
|
||
export async function POST(req: NextRequest) { | ||
await dbConnect(); | ||
|
||
if (req.method !== "POST") { | ||
return NextResponse.json( | ||
{ message: `Method ${req.method} Not Allowed` }, | ||
{ status: 405 }, | ||
); | ||
} | ||
|
||
const token = req.cookies.get("signInToken")?.value || ""; | ||
|
||
if (!token) { | ||
return NextResponse.json( | ||
{ message: "Unauthorized: No token provided" }, | ||
{ status: 401 }, | ||
); | ||
} | ||
|
||
try { | ||
const decoded = await jwt.verify(token, process.env.JWT_TOKEN_SECRET); | ||
|
||
if (decoded.role !== "admin") { | ||
return NextResponse.json( | ||
{ message: "Forbidden: Admin access required" }, | ||
{ status: 403 }, | ||
); | ||
} | ||
|
||
try { | ||
const { name, designation, email, linkedin, image } = await req.json(); | ||
|
||
if (!name || !designation || !email) { | ||
return NextResponse.json( | ||
{ message: "The fields (name,email,designation) are required" }, | ||
{ status: 400 }, | ||
); | ||
} | ||
|
||
const teamMember: ITeamMember = await TeamMember.create({ | ||
name, | ||
image, | ||
designation, | ||
email, | ||
linkedin, | ||
createdAt: moment().tz("Asia/Kolkata").format(), | ||
updatedAt: moment().tz("Asia/Kolkata").format(), | ||
}); | ||
|
||
return NextResponse.json( | ||
{ message: "Team member added successfully", teamMember }, | ||
{ status: 201 }, | ||
); | ||
} catch (err) { | ||
console.error(err); | ||
return NextResponse.json( | ||
{ message: "Internal Server Error" }, | ||
{ status: 500 }, | ||
); | ||
} | ||
} catch (err) { | ||
return NextResponse.json( | ||
{ message: "Invalid Authorization token" }, | ||
{ status: 401 }, | ||
); | ||
} | ||
} |
Oops, something went wrong.