Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f117d01
add actions for manager
ArnavSharma005 Jun 3, 2025
0d155d0
Add API actions and DTOs for information part
OjuIsOn Jun 3, 2025
0367ea9
Update app/dtos/event.dto.ts
Debatreya Jun 4, 2025
9a02717
Update app/actions/information.ts
Debatreya Jun 4, 2025
09cb8f7
Update app/actions/information.ts
Debatreya Jun 4, 2025
13aef29
Merge pull request #2 from OjuIsOn/main
Debatreya Jun 4, 2025
e09ddcc
User routes updates as per swagger UI APIs
Agrawal-Vansh Jun 5, 2025
8ea57d1
added user DTO and APIs as per swagger UI docs
Agrawal-Vansh Jun 5, 2025
d5cd0a8
Merge pull request #3 from Agrawal-Vansh/main
Debatreya Jun 6, 2025
1047136
manager routes with dtos
ArnavSharma005 Jun 6, 2025
30400c1
Resolved conflict: kept users.ts file
ArnavSharma005 Jun 6, 2025
3bdf3b6
Merge pull request #4 from ArnavSharma005/main
Debatreya Jun 6, 2025
2575377
Update README.md
Debatreya Jun 6, 2025
02c494b
added actions for manager and required dtos
yash-shakya Jun 6, 2025
620017f
some fixes
yash-shakya Jun 7, 2025
d7d758e
Merge pull request #6 from yash-shakya/admin-action
Debatreya Jun 7, 2025
77a5367
added App actions and authentication dto
yash-shakya Jun 7, 2025
116e37e
some fixes
yash-shakya Jun 7, 2025
7f105b8
added app and web actions along with suitable dtos
OjuIsOn Jun 8, 2025
e557843
Merge pull request #7 from yash-shakya/admin-action
Debatreya Jun 8, 2025
c034c39
Delete app/actions/app.ts
OjuIsOn Jun 8, 2025
a7c320c
Delete app/dtos/user.dto.ts
OjuIsOn Jun 8, 2025
1d3ec7f
Update web.ts
OjuIsOn Jun 8, 2025
486481e
removed app.ts
OjuIsOn Jun 8, 2025
45d7456
Merge branch 'main' of https://github.com/OjuIsOn/AdminPanel
OjuIsOn Jun 8, 2025
ac2048b
finally done resolving
OjuIsOn Jun 8, 2025
b84daea
u -> U
OjuIsOn Jun 8, 2025
bb35f19
Merge pull request #8 from OjuIsOn/main
Debatreya Jun 8, 2025
62df476
feat(api): Added an API layer
Debatreya Jun 8, 2025
e7b370a
added complete api layer
OjuIsOn Jul 5, 2025
779f761
Merge pull request #9 from OjuIsOn/feat/api
Debatreya Sep 13, 2025
fb06214
Worked on valid Copilot suggestions
Agrawal-Vansh Sep 18, 2025
c1915c8
Merge pull request #10 from Agrawal-Vansh/feat/api
Debatreya Sep 20, 2025
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ The easiest way to deploy your Next.js app is to use the [Vercel Platform](https

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

Let's not have an update feature on eventCategory. (updating by name). It is complex to implement and have no need
Let's not have an update feature on eventCategory. (updating by name). It is complex to implement and have no need

![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/Debatreya/AdminPanel?utm_source=oss&utm_medium=github&utm_campaign=Debatreya%2FAdminPanel&labelColor=171717&color=FF570A&link=https%3A%2F%2Fcoderabbit.ai&label=CodeRabbit+Reviews)
91 changes: 91 additions & 0 deletions app/actions/admin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import axios from "axios";

import { Category,SimpleCategoriesResponse } from "../dtos/category.dto";
import { QueryBody } from "../dtos/query.dto";
import { SimpleResponse, UserUpdateBody } from "../dtos/user.dto";
import { MailBody } from "../dtos/mail.dto";
import { NotificationBody } from "../dtos/notification.dto";

export async function addCategory(category:Category, token?: string): Promise<SimpleCategoriesResponse>{
if(!category) throw new Error("Category is required");
try {
const url=`${process.env.SERVER_URL}/events/categories`;
const headers = token ? { Authorization: token } : undefined;

const response = await axios.post(url,{
category:category.categoryName,
imgUrl:category.imgUrl,
icon:category.icon
}, { headers });
return response.data;
} catch (error:any) {
console.error("Error adding category:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed to add category");
}
}

export async function deleteQuery(query: QueryBody, token?: string): Promise<SimpleResponse>{
if(!query) throw new Error("Query required");
try {
const url=`${process.env.SERVER_URL}/admin/query`;
const headers = token ? { Authorization: token } : undefined;
const response = await axios.put(url,query, { headers });
return response.data;
} catch (error:any) {
console.error("Error deleting query:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed delete query");
}
}

export async function sendMailToMultipleUsers(mail:MailBody, token?: string): Promise<SimpleResponse>{
if(!mail) throw new Error("Mail data is required");
try {
const url = `${process.env.SERVER_URL}/admin/mail/list`;
const headers = token ? { Authorization: token } : undefined;
const response=await axios.post(url,mail, { headers });
return response.data;
} catch (error:any) {
console.error("Error sending mail:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed sending mail");
}
}

export async function sendNotification(notification:NotificationBody, token?: string): Promise<SimpleResponse>{
if(!notification) throw new Error("Notification data is required");
try{
const url=`${process.env.SERVER_URL}/admin/mobilenoti`;
const headers = token ? { Authorization: token } : undefined;
const response = await axios.post(url,notification, { headers });
return response.data;
}catch(error:any){
console.error("Error sending notification:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed sending notification");
}
}

export async function updateUser(token?: string): Promise<SimpleResponse> {
try {
const url=`${process.env.SERVER_URL}/updateUsers`;
const headers = token ? { Authorization: token } : undefined;
const response = await axios.post(url, undefined, { headers });
return response.data;
} catch (error:any) {
console.error("Error updating:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed updating");
}
}

export async function updateUserByAdmin(user:UserUpdateBody, token?: string): Promise<SimpleResponse> {
if(!user) throw new Error("User data is required");
try {
const url=`${process.env.SERVER_URL}/admin/user`;
const headers = token ? { Authorization: token } : undefined;
const response = await axios.put(url,user, { headers });

return response.data;
} catch (error:any) {
console.error("Error updating user:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed updating user");
}
}

31 changes: 31 additions & 0 deletions app/actions/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import axios from "axios";

import { UserAuthResponse, UserProfileUpdateSchema } from "../dtos/authentication.dto";

export async function loginUsingOAuth(idToken:string, token?: string): Promise<UserAuthResponse> {
if(!idToken) throw new Error("Id Token required");
try {
const url=`${process.env.SERVER_URL}/loginApp`;
const headers = token ? { Authorization: token } : undefined;
const response = await axios.post(url,idToken, { headers });
return response.data;
} catch (error:any) {
console.error("Error in login:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed to login");
}
}

export async function updateUserProfile(updateSchema:UserProfileUpdateSchema, token?: string) : Promise<UserAuthResponse> {
if(!updateSchema || !updateSchema.year || !updateSchema.college) {
throw new Error("Year and college are required for profile update");
}
try {
const url=`${process.env.SERVER_URL}/signUpApp`;
const headers = token ? { Authorization: token } : undefined;
const response = await axios.put(url,updateSchema, { headers });
return response.data;
} catch (error:any) {
console.error("Error updating user profile:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed to update user profile");
}
}
264 changes: 264 additions & 0 deletions app/actions/information.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
import axios from "axios";
import {
Event,

EventsResponse,TimelineEvent,
TimelineResponse
} from "../dtos/event.dto";


import {
CategoriesResponse,
Category
} from "../dtos/category.dto";


import {
ContactSection,
ContactsResponse
} from "../dtos/contact.dto";


import {
Lecture ,
LecturesResponse
} from "../dtos/lecture.dto";


import {
FoodSponsor,
FoodSponsorsResponse,
SponsorSection,
SponsorsResponse
} from "../dtos/sponsor.dto";

import {
AboutAppDevsResponse,
AboutResponse,
Developer
} from "../dtos/dev.dto";




import {
FactsResponse,
FAQ,
FAQResponse,
NotificationResponse,
Video,
VideosResponse
} from "../dtos/facts_vids_faq_notifc.dto";



export async function getCategoriesName(): Promise<Category[]> {
try {
const url = `${process.env.SERVER_URL}/events/categories`;
const response = await axios.get<CategoriesResponse>(url);
return response.data.data.categories;
}
catch (error: any) {
console.error("Error getting categories name:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed to get the categories name");
}
}

export async function getEventsNames(eventCategory?: string, token?: string): Promise<Event[]> {
try {
let url = `${process.env.SERVER_URL}/events`;
if (eventCategory && eventCategory.trim() !== "") {
url += `?eventCategory=${encodeURIComponent(eventCategory)}`;
}
const headers = token ? { Authorization: token } : undefined;
const response = await axios.get<EventsResponse>(url, { headers });
return response.data.data.events;
}
catch (error: any) {
console.error("Error getting the events names:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed to get the events names");
}
}

export async function getEventsDescriptionByCategory(eventCategory: string, eventName?: string, token?: string): Promise<Event[]> {
if (!eventCategory) {
throw new Error("Event category is required");
}
try {
let url = `${process.env.SERVER_URL}/events/description?eventCategory=${encodeURIComponent(eventCategory)}`;
if (eventName && eventName.trim() !== "") {
url += `&eventName=${encodeURIComponent(eventName)}`;
}
const headers = token ? { Authorization: token } : undefined;
const response = await axios.get<EventsResponse>(url, { headers });
return response.data.data.events;
}
catch (error: any) {
console.error("Error getting the event description", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed to get the Description by category");
}

}



export async function getTimelineEvents(token?: string): Promise<TimelineEvent[]> {
try {
const url = `${process.env.SERVER_URL}/events/timeline`;
const headers = token ? { Authorization: token } : undefined;
const response = await axios.get<TimelineResponse>(url, { headers });
return response.data.data.events;
} catch (error: any) {
console.error("Error getting timeline events:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed to get timeline events");
}
}


export async function getAllContacts(): Promise<ContactSection[]> {
try {
const url = `${process.env.SERVER_URL}/contacts`;

const response = await axios.get<ContactsResponse>(url);

return response.data.data.contacts;
} catch (error: any) {
console.error("Error getting contact sections:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed to get contacts");
}
}



export async function getGuestLectures(): Promise<Lecture[]> {
try {
const url = `${process.env.SERVER_URL}/lectures`;

const response = await axios.get<LecturesResponse>(url);

return response.data.data.lectures;
} catch (error: any) {
console.error("Error getting guest lectures:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed to get guest lectures");
}
}


export async function getSponsors(): Promise<SponsorSection[]> {
try {
const url = `${process.env.SERVER_URL}/sponsors`;

const response = await axios.get<SponsorsResponse>(url);

return response.data.data.paisa;
} catch (error: any) {
console.error("Error getting sponsors:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed to get sponsors");
}
}


export async function getFoodSponsors(): Promise<FoodSponsor[]> {
try {
const url = `${process.env.SERVER_URL}/foodsponsors`;

const response = await axios.get<FoodSponsorsResponse>(url);

return response.data.data.foodSponsors;
} catch (error: any) {
console.error("Error getting food sponsors:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed to get food sponsors");
}
}

export async function getDevelopers(): Promise<Developer[]> {
try {
const url = `${process.env.SERVER_URL}/about`;

const response = await axios.get<AboutResponse>(url);

return response.data.data.devs;
} catch (error: any) {
console.error("Error getting developers info:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed to get developers info");
}
}


export async function getAppDevelopers(): Promise<Developer[]> {
try {
const url = `${process.env.SERVER_URL}/aboutAppDevs`;

const response = await axios.get<AboutAppDevsResponse>(url);

return response.data.data.information;
} catch (error: any) {
console.error("Error getting app developers info:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed to get app developers info");
}
}

export async function getRandomFact(): Promise<string> {
try {
const url = `${process.env.SERVER_URL}/facts`;

const response = await axios.get<FactsResponse>(url);

return response.data.data.message;
} catch (error: any) {
console.error("Error getting random fact:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed to get random fact");
}
}

export async function getVideos(): Promise<Video[]> {
try {
const url = `${process.env.SERVER_URL}/videos`;

const response = await axios.get<VideosResponse>(url);

return response.data.data;
} catch (error: any) {
console.error("Error getting videos:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed to get videos");
}
}

export async function getFAQs(): Promise<FAQ[]> {
try {
const url = `${process.env.SERVER_URL}/faq`;

const response = await axios.get<FAQResponse>(url);

return response.data.data;
} catch (error: any) {
console.error("Error fetching FAQs:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed to fetch FAQs");
}
}


export async function getUpcomingEvents(timestamp?: number, token?: string): Promise<Event[]> {
try {
const url = `${process.env.SERVER_URL}/timestamp/events`;
const headers = token ? { Authorization: token } : undefined;
const response = await axios.get<EventsResponse>(url, {
params: { timestamp },
headers
});
return response.data.data.events;
} catch (error: any) {
console.error("Error fetching upcoming events:", error?.response?.data || error.message || error);
throw new Error(error?.response?.data?.message || "Failed to fetch upcoming events");
}
}

export async function getNotifications(): Promise<NotificationResponse> {
try {
const response = await axios.get<NotificationResponse>(`${process.env.SERVER_URL}/notification`);
return response.data;
} catch (error: any) {
console.error("Error fetching notifications:", error?.response?.data || error.message);
throw new Error(error?.response?.data?.message || "Failed to fetch notifications");
}
}
Loading