Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish project #48

Merged
merged 7 commits into from
Jun 30, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove console.logs and commented-out code
  • Loading branch information
benjaminJohnson2204 committed Jun 30, 2024
commit fda0388b4e6673742c7846ed17a6696fe4d7c7aa
1 change: 0 additions & 1 deletion backend/dist/controllers/eventDetails.js
Original file line number Diff line number Diff line change
@@ -83,7 +83,6 @@ const updateEventDetails = (req, res, next) => __awaiter(void 0, void 0, void 0,
const updatedEventDetails = yield eventDetails_1.default.findById(id);
if (updatedEventDetails === null) {
// No event found, something went wrong
console.log("updatedEventDetails is null");
res.status(404);
}
res.status(200).json(updatedEventDetails);
18 changes: 9 additions & 9 deletions backend/dist/controllers/pageeditor.js
Original file line number Diff line number Diff line change
@@ -18,13 +18,13 @@ const http_errors_1 = __importDefault(require("http-errors"));
const pageeditor_1 = __importDefault(require("../models/pageeditor"));
const validationErrorParser_1 = __importDefault(require("../util/validationErrorParser"));
const getPage = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
const { page } = req.params;
const { name } = req.params;
try {
const pageText = yield pageeditor_1.default.findOne({ page: page });
if (!pageText) {
const page = yield pageeditor_1.default.findOne({ name: name });
if (!page) {
throw (0, http_errors_1.default)(404, "Page not found.");
}
res.status(200).json(pageText);
res.status(200).json(page);
}
catch (error) {
next(error);
@@ -33,19 +33,19 @@ const getPage = (req, res, next) => __awaiter(void 0, void 0, void 0, function*
exports.getPage = getPage;
const updatePageEditor = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
const errors = (0, express_validator_1.validationResult)(req);
const { page } = req.params;
if (page !== req.body.page) {
const { name } = req.params;
if (name !== req.body.name) {
// If the page in the URL does not match the page in the body, bad request
res.status(400);
}
try {
(0, validationErrorParser_1.default)(errors);
const pageText = yield pageeditor_1.default.findOneAndUpdate({ page }, req.body);
if (pageText === null) {
const page = yield pageeditor_1.default.findOneAndUpdate({ name: name }, { $set: req.body });
if (page === null) {
// No page found
res.status(404);
}
const updatedPage = yield pageeditor_1.default.findOne({ page });
const updatedPage = yield pageeditor_1.default.findOne({ name: name });
if (updatedPage === null) {
// No page found after updating, something went wrong
res.status(404);
2 changes: 0 additions & 2 deletions backend/dist/controllers/testimonial.js
Original file line number Diff line number Diff line change
@@ -26,11 +26,9 @@ const createTestimonial = (req, res, next) => __awaiter(void 0, void 0, void 0,
image: image,
type: type,
});
console.log("testimonial: ", testimonial);
res.status(201).json(testimonial);
}
catch (error) {
console.log("erroring here");
next(error);
}
});
11 changes: 9 additions & 2 deletions backend/dist/models/pageeditor.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,14 @@
Object.defineProperty(exports, "__esModule", { value: true });
const mongoose_1 = require("mongoose");
const pageEditorSchema = new mongoose_1.Schema({
page: { type: String, required: true },
pageSections: [{ type: mongoose_1.Schema.Types.Mixed, required: true }],
name: { type: String, required: true },
isEdited: { type: Boolean, required: true },
fields: [
{
name: { type: String, required: true },
type: { type: String, required: true },
data: { type: mongoose_1.Schema.Types.Mixed, required: true },
},
],
});
exports.default = (0, mongoose_1.model)("PageEditor", pageEditorSchema);
4 changes: 2 additions & 2 deletions backend/dist/models/testimonial.js
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ const mongoose_1 = require("mongoose");
const testimonialSchema = new mongoose_1.Schema({
title: { type: String, required: true },
description: { type: String, required: true },
image: { type: String, required: true },
image: { type: String, required: false },
type: { type: String, required: true },
});
exports.default = (0, mongoose_1.model)("testimonial", testimonialSchema);
exports.default = (0, mongoose_1.model)("Testimonial", testimonialSchema);
6 changes: 2 additions & 4 deletions backend/dist/routes/pageeditor.js
Original file line number Diff line number Diff line change
@@ -30,8 +30,6 @@ const express_1 = __importDefault(require("express"));
const PageEditorController = __importStar(require("../controllers/pageeditor"));
const PageEditorValidator = __importStar(require("../validators/pageeditor"));
const router = express_1.default.Router();
router.get("/:page", PageEditorValidator.getPageEditor, PageEditorController.getPage);
router.put("/:page", // getPageEditor validator works to just check page
// PageEditorValidator.getPageEditor,
PageEditorController.updatePageEditor);
router.get("/:name", PageEditorValidator.getPageEditor, PageEditorController.getPage);
router.put("/:name", PageEditorValidator.updatePageEditor, PageEditorController.updatePageEditor);
exports.default = router;
14 changes: 9 additions & 5 deletions backend/dist/services/paypal.js
Original file line number Diff line number Diff line change
@@ -12,7 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.captureOrder = exports.createOrder = void 0;
const PAYPAL_CLIENT_ID = process.env.PAYPAL_CLIENT_ID;
const PAYPAL_CLIENT_SECRET = process.env.PAYPAL_CLIENT_SECRET;
const base = "https://api-m.sandbox.paypal.com";
const ORIGIN_URL = process.env.FRONTEND_ORIGIN;
const base = "https://api-m.paypal.com";
/**
* Generate an OAuth 2.0 token to authenticate with PayPal REST APIs
* @see https://developer.paypal.com/api/rest/authentication/
@@ -23,12 +24,16 @@ const generateAccessToken = () => __awaiter(void 0, void 0, void 0, function* ()
throw new Error("MISSING_PAYPAL_API_CREDENTIALS");
}
const auth = Buffer.from(PAYPAL_CLIENT_ID + ":" + PAYPAL_CLIENT_SECRET).toString("base64");
const headersList = {
Accept: "*/*",
"User-Agent": `4 Future Leaders Of Tomorrow Web App (${ORIGIN_URL})`,
"Content-Type": "application/x-www-form-urlencoded",
Authorization: `Basic ${auth}`,
};
const response = yield fetch(`${base}/v1/oauth2/token`, {
method: "POST",
body: "grant_type=client_credentials",
headers: {
Authorization: `Basic ${auth}`,
},
headers: headersList,
});
const data = yield response.json();
return data.access_token;
@@ -56,7 +61,6 @@ function createOrder(cart) {
return __awaiter(this, void 0, void 0, function* () {
const accessToken = yield generateAccessToken();
const url = `${base}/v2/checkout/orders`;
console.log("shopping cart info", cart);
const payload = {
intent: "CAPTURE",
purchase_units: [
46 changes: 14 additions & 32 deletions backend/dist/validators/pageeditor.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createPageEditor = exports.getPageEditor = void 0;
exports.updatePageEditor = exports.getPageEditor = void 0;
const express_validator_1 = require("express-validator");
const makeIDValidator = () => (0, express_validator_1.body)("_id")
const makeNameValidator = () => (0, express_validator_1.body)("name")
.exists()
.withMessage("_id is required")
.withMessage("name is required")
.bail()
.isString()
.withMessage("_id must be a number");
const makePageValidator = () => (0, express_validator_1.body)("page")
.withMessage("name must be a string");
const makeEditedValidator = () => (0, express_validator_1.body)("isEdited")
.exists()
.withMessage("image is required")
.withMessage("isEdited is required")
.bail()
.isString()
.withMessage("image must be a string");
const makeSubtitleValidator = () => (0, express_validator_1.body)("ph_subtitle")
.exists()
.withMessage("subtitle is required")
.bail()
.isString()
.withMessage("subtitle must be a string");
const makeTitleValidator = () => (0, express_validator_1.body)("s1_title")
.isBoolean()
.withMessage("isEdited must be a boolean");
const makeFieldsValidator = () => (0, express_validator_1.body)("fields")
.exists()
.withMessage("date is required")
.withMessage("fields is required")
.bail()
.isString()
.withMessage("date must be a string");
const makeTextValidator = () => (0, express_validator_1.body)("s1_text")
.exists()
.withMessage("content is required")
.bail()
.isString()
.withMessage("content must be a string");
exports.getPageEditor = [makePageValidator()];
exports.createPageEditor = [
makeIDValidator(),
makePageValidator(),
makeSubtitleValidator(),
makeTitleValidator(),
makeTextValidator(),
];
.isArray()
.withMessage("fields must be an array");
exports.getPageEditor = [makeNameValidator(), makeEditedValidator(), makeFieldsValidator()];
exports.updatePageEditor = [makeNameValidator(), makeEditedValidator(), makeFieldsValidator()];
13 changes: 1 addition & 12 deletions backend/dist/validators/testimonial.js
Original file line number Diff line number Diff line change
@@ -32,18 +32,7 @@ const makeDescriptionValidator = () => (0, express_validator_1.body)("descriptio
.bail()
.notEmpty()
.withMessage("description cannot be empty");
const makeImageValidator = () => (0, express_validator_1.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");
const makeImageValidator = () => (0, express_validator_1.body)("image").optional().isString().withMessage("image must be a string");
exports.createTestimonial = [
makeTitleValidator(),
makeImageValidator(),
3 changes: 0 additions & 3 deletions backend/src/controllers/eventDetails.ts
Original file line number Diff line number Diff line change
@@ -34,7 +34,6 @@ export const getEventDetails: RequestHandler = async (req, res, next) => {
};

export const createEventDetails: RequestHandler = async (req, res, next) => {
console.log("backend createEventDetails. req.body: ", req.body);
const errors = validationResult(req);
const {
name,
@@ -63,7 +62,6 @@ export const createEventDetails: RequestHandler = async (req, res, next) => {
description_short,
});

// console.log("added eventDetails: ", eventDetails);
res.status(201).json(eventDetails);
} catch (error) {
next(error);
@@ -89,7 +87,6 @@ export const updateEventDetails: RequestHandler = async (req, res, next) => {
const updatedEventDetails = await EventDetails.findById(id);
if (updatedEventDetails === null) {
// No event found, something went wrong
console.log("updatedEventDetails is null");
res.status(404);
}
res.status(200).json(updatedEventDetails);
1 change: 0 additions & 1 deletion backend/src/services/paypal.ts
Original file line number Diff line number Diff line change
@@ -61,7 +61,6 @@ async function handleResponse(response: Response) {

export async function createOrder(cart: Cart) {
const accessToken = await generateAccessToken();
console.log("creating order with ", accessToken);
const url = `${base}/v2/checkout/orders`;

const payload = {
1 change: 0 additions & 1 deletion frontend/src/api/requests.ts
Original file line number Diff line number Diff line change
@@ -108,7 +108,6 @@ export async function post(
headers: Record<string, string> = {},
): Promise<Response> {
const response = await fetchRequest("POST", API_BASE_URL + url, body, headers);
console.log("fetch response: ", response);
await assertOk(response);
return response;
}
1 change: 0 additions & 1 deletion frontend/src/app/(web app)/team/page.tsx
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@ export default function Team() {
getAllMembers()
.then((result) => {
if (result.success) {
console.log(result.data);
setMembers(result.data);
} else {
alert(result.error);
1 change: 0 additions & 1 deletion frontend/src/app/(web app)/testimonials/page.tsx
Original file line number Diff line number Diff line change
@@ -30,7 +30,6 @@ export default function Impact() {
const [loading, setLoading] = useState(false);

const loadTestimonials = () => {
console.log("getting from loadTestimonials");
getAllTestimonials()
.then((result) => {
if (result.success) {
5 changes: 0 additions & 5 deletions frontend/src/app/admin/event-creator/page.tsx
Original file line number Diff line number Diff line change
@@ -109,7 +109,6 @@
getAllEventDetails()
.then((result) => {
if (result.success) {
console.log(result.data);
const now = new Date();
const utcDateCurrent = now;

@@ -129,7 +128,6 @@
id: item._id.toString(),
}));

console.log("current: ", formattedCurrentRows);
setCurrentEvents(formattedCurrentRows);

const filteredPast = result.data.filter((item) => {
@@ -147,7 +145,6 @@
id: item._id.toString(),
}));

console.log("past: ", formattedPastRows);
setPastEvents(formattedPastRows);

setRow(formattedCurrentRows);
@@ -209,7 +206,6 @@
useEffect(() => {
// Update total pages when rows change
setTotalPages(Math.ceil(rows.length / 14));
console.log("rows.length: ", rows.length);
}, [rows]);

const handleCellClick: GridEventListener<"rowClick"> = (params) => {
@@ -228,7 +224,6 @@
const handleUpdateEvent = async (eventData: EventDetails) => {
const result = await updateEventDetails(eventData);
if (!result.success) {
console.log("result was not a success");
alert(result.error);
console.error("ERROR:", result.error);
}
@@ -337,7 +332,7 @@
borderRadius: "4px",
}}
>
<img

Check warning on line 335 in frontend/src/app/admin/event-creator/page.tsx

GitHub Actions / Frontend check

Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element
src="/ic_add.svg"
alt="Add Icon"
style={{ width: 24, height: 24, marginRight: 5 }}
3 changes: 0 additions & 3 deletions frontend/src/app/admin/mailing-list/page.tsx
Original file line number Diff line number Diff line change
@@ -39,8 +39,6 @@ export default function MailingList() {
getAllSubscribers()
.then((result) => {
if (result.success) {
console.log("Data:", result.data);

const formattedRows = result.data.map((item) => ({
...item,
id: item._id.toString(),
@@ -158,7 +156,6 @@ export default function MailingList() {
if (selectedRowData) {
setDeletedRow(selectedRowData);

console.log("selectedRowData:", selectedRowData._id);
deleteSubscriber(selectedRowData._id)
.then((response) => {
if (response.success) {
1 change: 0 additions & 1 deletion frontend/src/app/admin/newsletter-creator/page.tsx
Original file line number Diff line number Diff line change
@@ -177,7 +177,6 @@ export default function NewsletterCreator() {
const handleUpdateNewsletter = async (newsletterData: Newsletter) => {
const result = await updateNewsletter(newsletterData);
if (!result.success) {
console.log("result was not a success");
alert(result.error);
console.error("ERROR:", result.error);
}
Loading
Loading