Skip to content

Commit

Permalink
did nec changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sridhar-5 committed Feb 12, 2022
1 parent 69518ef commit e558298
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 55 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const LoginUser = require("./routes/LoginUser");
const RegisterUser = require("./routes/RegisterUser");
const AdminUsersEndpoint = require("./routes/AdminUsersEndpoint");
const allEvent = require("./routes/EventCards");
const ClubEvents = require("./routes/CardClubView");
const CategoryEvents = require("./routes/CardClubView");

const app = Express();

Expand All @@ -21,7 +21,7 @@ app.use("/api/login", LoginUser);
app.use("/api/register", RegisterUser);
app.use("/api/all-events", allEvent);
app.use("/api/admin-users-portal", AdminUsersEndpoint);
app.use("/api/club-events", ClubEvents);
app.use("/api/category-events", ClubEvents);

//Homepage Endpoint
app.get("/", (request, response) => {
Expand Down
32 changes: 16 additions & 16 deletions models/Events.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Joi = require("joi");
const mongoose = require("mongoose");
const { Contacts } = require("../models/ContactDetails");

const EventSchema = mongoose.Schema({
ImageUrl: {
type: String,
Expand All @@ -10,39 +10,39 @@ const EventSchema = mongoose.Schema({
type: String,
required: true,
},
Caption: {
type: String,
required: true,
},
Description: {
type: String,
required: true,
},
OrganizingClub: {
type: String,
required: true,
},
Date: {
type: Date,
default: Date.now,
required: true,
},
Venue: {
location: {
type: String,
required: true,
},
RegistrationLink: {
type: String,
required: true,
},
Note: {
StarCount: {
type: Number,
},
Category: {
type: String,
},
ContactDetails: {
type: [Contacts],
lastedited: {
type: Date,
default: Date.now,
},
Prerequisites: {
type: String,
},
// Status: {
// type: String,
// enum: ["Completed", "Upcoming", "Ongoing"],
// },
// ContactDetails: {
// type: [Contacts],
// },
});

Expand Down
7 changes: 6 additions & 1 deletion models/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ const jwt = require("jsonwebtoken");
require("dotenv").config();

const UserSchema = mongoose.Schema({
ImageProfile: {
type: String,
required: true,
},
Name: {
type: String,
required: true,
Expand All @@ -30,7 +34,8 @@ const UserSchema = mongoose.Schema({
unique: true,
},
phone: String,

StartedEventNames: [String],
RsvpEventNames: [String],
isAdmin: {
type: Boolean,
default: false,
Expand Down
25 changes: 0 additions & 25 deletions models/club.js

This file was deleted.

25 changes: 14 additions & 11 deletions routes/CardClubView.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const { Events } = require("../models/Events");

const { Club } = require("../models/club");

const Express = require("express");
const _ = require("lodash");
const router = Express.Router();
Expand All @@ -11,24 +9,29 @@ const AuthenticateUser = require("../middleware/AuthenticateUser");
const RedirectAdminUser = require("../middleware/RedirectAdminUser");

router.get("/", AuthenticateUser, async (request, response) => {
const Clubs = await Club.find({});
console.log(Clubs);
const Events = await Events.find({});

const cateories = [];
Events.forEach((event) => {
if (!categories.includes(event.Category)) {
clubs.push(event.Category);
}
});

response.status(200).send(Clubs);
response.status(200).send(categories);
});

router.get(
"/fetchEvents/:ClubName",
"/fetchEvents/:Category",
AuthenticateUser,
async (request, response) => {
const ClubName = request.params.ClubName;
const EventsConductedByClub = await Events.find({
OrganizingClub: ClubName,
const Category = request.params.Category;
const EventsConductedCategory = await Events.find({
Category: Category,
});

//for debugging purposes
console.log(EventsConductedByClub);
response.status(200).send(EventsConductedByClub);
response.status(200).send(EventsConductedCategory);
}
);

Expand Down

0 comments on commit e558298

Please sign in to comment.