Skip to content

Commit

Permalink
Merge branch 'main' into feature/arnav-jacob/upcoming-events-flow
Browse files Browse the repository at this point in the history
  • Loading branch information
jennymar committed Mar 2, 2024
2 parents 541bea4 + 5c9f4fc commit 71d0fe2
Show file tree
Hide file tree
Showing 43 changed files with 1,256 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,6 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# desktop services store
.DS_Store
Binary file added backend/.DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import subscriberRoutes from "src/routes/subscriber";
import memberRoutes from "src/routes/members";
import eventDetailsRoutes from "./routes/eventDetails";
import volunteerDetailsRoutes from "./routes/volunteerDetails";
import testimonialRoutes from "src/routes/testimonial";

const app = express();

Expand All @@ -32,6 +33,7 @@ app.use("/api/subscribers", subscriberRoutes);
app.use("/api/member", memberRoutes);
app.use("/api/eventDetails", eventDetailsRoutes);
app.use("/api/volunteerDetails", volunteerDetailsRoutes);
app.use("/api/testimonial", testimonialRoutes);
/**
* Error handler; all errors thrown by server are handled here.
* Explicit typings required here because TypeScript cannot infer the argument types.
Expand Down
28 changes: 28 additions & 0 deletions backend/src/controllers/testimonial.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { RequestHandler } from "express";
import TestimonialModel from "src/models/testimonial";

export const createTestimonial: RequestHandler = async (req, res, next) => {
const { title, description, image, type } = req.body;
console.log("here");
try {
const testimonial = await TestimonialModel.create({
title: title,
description: description,
image: image,
type: type,
});
console.log("here");
res.status(201).json(testimonial);
} catch (error) {
next(error);
}
};

export const getAllTestimonials: RequestHandler = async (req, res, next) => {
try {
const testimonials = await TestimonialModel.find({});
res.status(200).json(testimonials);
} catch (error) {
next(error);
}
};
12 changes: 12 additions & 0 deletions backend/src/models/testimonial.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { InferSchemaType, Schema, model } from "mongoose";

const testimonialSchema = new Schema({
title: { type: String, required: true },
description: { type: String, required: true },
image: { type: String, required: true },
type: { type: String, required: true },
});

type testimonial = InferSchemaType<typeof testimonialSchema>;

export default model<testimonial>("testimonial", testimonialSchema);
9 changes: 9 additions & 0 deletions backend/src/routes/testimonial.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import express from "express";
import * as TestimonialController from "src/controllers/testimonial";

const router = express.Router();

router.get("/get", TestimonialController.getAllTestimonials);
router.post("/post", TestimonialController.createTestimonial);

export default router;
63 changes: 63 additions & 0 deletions backend/src/validators/testimonial.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { body } from "express-validator";

const makeIDValidator = () =>
body("_id")
.exists()
.withMessage("_id is required")
.bail()
.isMongoId()
.withMessage("_id must be a MongoDB object ID");

const makeTitleValidator = () =>
body("title")
// title must exist, if not this message will be displayed
.exists()
.withMessage("title is required")
// bail prevents the remainder of the validation chain for this field from being executed if
// there was an error
.bail()
.isString()
.withMessage("title must be a string")
.bail()
.notEmpty()
.withMessage("title cannot be empty");
const makeDescriptionValidator = () =>
body("description")
// title must exist, if not this message will be displayed
.exists()
.withMessage("description is required")
// bail prevents the remainder of the validation chain for this field from being executed if
// there was an error
.bail()
.isString()
.withMessage("description must be a string")
.bail()
.notEmpty()
.withMessage("description cannot be empty");

const makeImageValidator = () =>
body("image")
// title must exist, if not this message will be displayed
.exists()
.withMessage("image is required")
// bail prevents the remainder of the validation chain for this field from being executed if
// there was an error
.bail()
.isString()
.withMessage("image must be a string")
.bail()
.notEmpty()
.withMessage("image cannot be empty");

export const createTestimonial = [
makeTitleValidator(),
makeDescriptionValidator(),
makeImageValidator(),
];

export const updateTestimonial = [
makeIDValidator(),
makeTitleValidator(),
makeDescriptionValidator(),
makeImageValidator(),
];
6 changes: 6 additions & 0 deletions frontend/public/Color=Default.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions frontend/public/handheart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/impact1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/impact2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/impact_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/mission_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/mission_bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/mission_top_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/mission_top_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions frontend/public/newsletter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions frontend/public/ourimpact.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/public/puzzle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions frontend/public/testimonials.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions frontend/public/threepeople.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions frontend/src/api/testimonial.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { get, handleAPIError } from "./requests";

import type { APIResult } from "./requests";
export type Testimonial = {
_id: string;
title: string;
description: string;
image: string;
type: string;
};

export async function getAllTestimonials(): Promise<APIResult<Testimonial[]>> {
try {
const response = await get(`/api/testimonial/get`);
//console.log(response);
const json = (await response.json()) as Testimonial[];
//console.log(json);
return { success: true, data: json };
} catch (error) {
return handleAPIError(error);
}
}
4 changes: 2 additions & 2 deletions frontend/src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
}
}

body {
/*body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(to bottom, transparent, rgb(var(--background-end-rgb)))
rgb(var(--background-start-rgb));
}
}*/
26 changes: 26 additions & 0 deletions frontend/src/app/impact/page.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.cards {
display: flex;
flex-direction: column;
gap: 48px;
margin-left: 202px;
margin-right: 202px;
margin-bottom: 136px;
}

.backgroundImageContainer {
position: relative;
z-index: 0;
background-color: blue;
}

.whiteCardsContainer {
position: absolute;
top: 557px;
/* left: 0; */
z-index: 1;
/* background-color: pink; */
}

.cardsBackground {
height: 866px;
}
Loading

0 comments on commit 71d0fe2

Please sign in to comment.