Skip to content
Open
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
10 changes: 0 additions & 10 deletions backend/.env.example
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't delete this file this is in the repo for future contributors reference

This file was deleted.

19 changes: 10 additions & 9 deletions backend/controllers/Event.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const createEvent = asyncHandler(async (req, res) => {
const posterLocalPath = req?.files?.poster[0]?.path;

if (!posterLocalPath) {
return res.status(400).json({ message: "poster is required" });
return res.status(400).json({ success : false, message: "poster is required" });
}

const cloudinaryPosterPath = await uploadOnCloudinary(posterLocalPath);
Expand Down Expand Up @@ -83,16 +83,17 @@ export const updateEventById = async (req, res) => {
}

const eventData = req.body;
console.log("New data : ", eventData);

// checking if event name alrady exist in databse (as it is unique)
if (eventData.name) {
const ifExisted = await Event.findOne({ name: eventData.name });
if (ifExisted) {
return res.status(409).json({
message: "Event name already exists try using differnt event name",
});
}
}
// if (eventData.name) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is removed?

// const ifExisted = await Event.findOne({ name: eventData.name });
// if (ifExisted) {
// return res.status(409).json({
// message: "Event name already exists try using differnt event name",
// });
// }
// }

const updatedEvent = await Event.findByIdAndUpdate(eventId, eventData, {
new: true,
Expand Down
2 changes: 1 addition & 1 deletion backend/middlewares/validate.middlewares.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ export const validateCreateEvent =[
body("venue").escape().notEmpty(),
body("description").escape().notEmpty(),
body("numberOfMember").escape().isInt({min:1}),
body("poster").escape().trim().notEmpty(),
(req, res, next) => {
const errors = validationResult(req);
console.log(errors)
if (errors.isEmpty()) {
next();
return ;
Expand Down
22 changes: 4 additions & 18 deletions backend/models/Event.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import User from './User.model.js';
import Team from './Team.model.js';

const EventSchema = new mongoose.Schema({
isWorkshop : {
type: Boolean,
required : true
},
name : {
type: String,
required : true,
Expand Down Expand Up @@ -45,24 +49,6 @@ const EventSchema = new mongoose.Schema({
title:String,
link:String,
}],
leaderboard: [
{
type:mongoose.Schema.Types.ObjectId,
ref: User,
}
],
teams: [
{
type:mongoose.Schema.Types.ObjectId,
ref: Team,
}
],
participants: [
{
type:mongoose.Schema.Types.ObjectId,
ref: User,
}
],
isLive: {
type: Boolean,
default: false,
Expand Down
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to remove the files from the temp folder once it's uploaded on the cloudinary

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't commit these images

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion frontend/.env.example
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this file

This file was deleted.

31 changes: 29 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"react-awesome-button": "^7.0.5",
"react-carousel-minimal": "^1.4.1",
"react-dom": "^18.3.1",
"react-hot-toast": "^2.6.0",
"react-icons": "^5.3.0",
"react-responsive": "^10.0.0",
"react-router-dom": "^6.27.0",
Expand Down
40 changes: 23 additions & 17 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import UserDashboardPage from "./pages/UserDashboardPage";
import EventDetailsPage from "./pages/EventDetailsPage.jsx";
import CreateEventPage from "./pages/CreateEventPage.jsx";
import ManageEventsPage from "./pages/ManageEventsPage.jsx";
import { Toaster } from "./components/ui/toaster";
import { Toaster } from "react-hot-toast";

const App = () => {
return (
Expand All @@ -36,7 +36,23 @@ const App = () => {
<ScrollToTop />
<StarsCanvas />
<UserOptions />
<Toaster/>
<Toaster
position="bottom-right"
toastOptions={{
duration: 4000,
style: {
background: '#050816',
color: '#f3f3f3',
border: '1px solid #aaa6c3',
borderRadius: '12px',
padding: '16px 20px',
fontSize: '16px',
fontWeight: '500',
boxShadow: '0px 35px 120px -15px #211e35',
backdropFilter: 'blur(10px)',
},
}}
/>
<div className="relative z-10">
<Routes>
<Route path="/" element={<Home />} />
Expand Down Expand Up @@ -125,33 +141,23 @@ const App = () => {
<Route
path="/events/create"
element={
<ProtectedRoute>
<VerifiedRoute>
<CreateEventPage />
</VerifiedRoute>
</ProtectedRoute>
<CreateEventPage />

}
/>
<Route
path="/events/manage"
element={
<ProtectedRoute>
<VerifiedRoute>
<ManageEventsPage />
</VerifiedRoute>
</ProtectedRoute>
<ManageEventsPage />
}
/>
<Route
path="/events/manage/event"
element={
<ProtectedRoute>
<VerifiedRoute>
<EventDetailsPage />
</VerifiedRoute>
</ProtectedRoute>
<EventDetailsPage />
}
/>

</Routes>
</div>
</BrowserRouter>
Expand Down
51 changes: 41 additions & 10 deletions frontend/src/api/apiService.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,25 +334,44 @@ export const leaveTeam = async (teamId) => {
// Events

export const createEvent = async (eventData) => {
// Check if eventData is FormData or regular object
const isFormData = eventData instanceof FormData;

const headers = {
Authorization: `Bearer ${localStorage.getItem("token")}`,
};

// Don't set Content-Type for FormData (browser will set it automatically with boundary)
if (!isFormData) {
headers["Content-Type"] = "application/json";
}

const response = await fetch(`${API_BASE_URL}/api/events/`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
body: JSON.stringify(eventData),
headers,
body: isFormData ? eventData : JSON.stringify(eventData),
});
return handleResponse(response);
};

export const updateEvent = async (eventId, eventData) => {
// Check if eventData is FormData or regular object
const isFormData = eventData instanceof FormData;

const headers = {
Authorization: `Bearer ${localStorage.getItem("token")}`,
};

// Don't set Content-Type for FormData (browser will set it automatically with boundary)
if (!isFormData) {
headers["Content-Type"] = "application/json";
}

const response = await fetch(`${API_BASE_URL}/api/events/${eventId}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
body: JSON.stringify(eventData),
credentials: "include",
headers,
body: isFormData ? eventData : JSON.stringify(eventData),
});
return handleResponse(response);
};
Expand All @@ -378,3 +397,15 @@ export const getEventsById = async (eventId) => {
});
return handleResponse(response);
};

export const deleteEvent = async (eventId) => {
const response = await fetch(`${API_BASE_URL}/api/events/${eventId}`, {
method: "DELETE",
credentials: "include",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});
return handleResponse(response);
};
Loading