From 70bf960cc957cf315c6dfa7eca68cd32074a6e0e Mon Sep 17 00:00:00 2001 From: Shivangiyadav1319 <140613007+Shivangiyadav1319@users.noreply.github.com> Date: Thu, 12 Feb 2026 13:47:53 +0530 Subject: [PATCH 1/5] Create models/goal.js --- models/goal.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 models/goal.js diff --git a/models/goal.js b/models/goal.js new file mode 100644 index 0000000..bf88c9b --- /dev/null +++ b/models/goal.js @@ -0,0 +1,39 @@ +const mongoose = require("mongoose"); + +const GoalSchema = new mongoose.Schema({ + name: { + type: String, + required: true + }, + targetAmount: { + type: Number, + required: true + }, + targetDate: { + type: Date, + required: true + }, + balance: { + type: Number, + default: 0 + }, + transactionIds: [{ + type: mongoose.Schema.Types.ObjectId, + ref: "Transaction" + }], + tagIds: [{ + type: mongoose.Schema.Types.ObjectId, + ref: "Tag" + }], + icon: { + type: String, + required: false + }, + userId: { + type: mongoose.Schema.Types.ObjectId, + ref: "User", + required: true + } +}); + +module.exports = mongoose.model("Goal", GoalSchema); \ No newline at end of file From f71d9e3936857a297f4341765668d39fbd24df29 Mon Sep 17 00:00:00 2001 From: Shivangiyadav1319 <140613007+Shivangiyadav1319@users.noreply.github.com> Date: Thu, 12 Feb 2026 14:26:54 +0530 Subject: [PATCH 2/5] Create src/models/goal.model.js --- src/models/goal.model.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/models/goal.model.js diff --git a/src/models/goal.model.js b/src/models/goal.model.js new file mode 100644 index 0000000..bdbee7b --- /dev/null +++ b/src/models/goal.model.js @@ -0,0 +1,13 @@ +// Frontend Goal model (client-side) + +export const Goal = { + id: "1234", + name: "abcd", + targetAmount: 100000, + targetDate: "01 jan - 01 dec", + balance: 0, + transactionIds: [0234], + tagIds: [234], + icon: "", // optional emoji/icon + userId: "" +}; \ No newline at end of file From c47176935f88c5d8eb1902df204e7d9114ad4435 Mon Sep 17 00:00:00 2001 From: Shivangiyadav1319 <140613007+Shivangiyadav1319@users.noreply.github.com> Date: Thu, 12 Feb 2026 14:38:37 +0530 Subject: [PATCH 3/5] Create src/lib/updateGoalIcon.js Add PUT request to update Goal icon --- src/lib/updateGoalIcon.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/lib/updateGoalIcon.js diff --git a/src/lib/updateGoalIcon.js b/src/lib/updateGoalIcon.js new file mode 100644 index 0000000..8668554 --- /dev/null +++ b/src/lib/updateGoalIcon.js @@ -0,0 +1,20 @@ +// Function to update goal icon using PUT request + +export async function updateGoalIcon(goalId, icon) { + const response = await fetch(`/api/goals/${goalId}`, { + method: "PUT", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + icon: icon + }) + }); + + return response.json(); +} + +// Emoji click handler +export function pickEmojiOnClick(goalId, emoji) { + return updateGoalIcon(goalId, emoji); +} \ No newline at end of file From 87c1e1a1b9240bbadf986c44a501b24078dc4ce2 Mon Sep 17 00:00:00 2001 From: Shivangiyadav1319 <140613007+Shivangiyadav1319@users.noreply.github.com> Date: Thu, 12 Feb 2026 14:51:13 +0530 Subject: [PATCH 4/5] Create tests/getGoalsForUser.test.js Add test for GetGoalsForUser --- tests/getGoalsForUser.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/getGoalsForUser.test.js diff --git a/tests/getGoalsForUser.test.js b/tests/getGoalsForUser.test.js new file mode 100644 index 0000000..458e635 --- /dev/null +++ b/tests/getGoalsForUser.test.js @@ -0,0 +1,16 @@ +// Test for GetGoalsForUser route + +describe("GET /goals/user/:userId", () => { + it("should return goals for a given user", () => { + const mockUserId = "12345"; + + // expected behaviour + const expectedResponse = { + status: 200, + body: [] + }; + + expect(expectedResponse.status).toBe(200); + expect(Array.isArray(expectedResponse.body)).toBe(true); + }); +}); \ No newline at end of file From 4baddd64abb68df9d3bd1362ea0515b445f68638 Mon Sep 17 00:00:00 2001 From: Shivangiyadav1319 <140613007+Shivangiyadav1319@users.noreply.github.com> Date: Thu, 12 Feb 2026 15:35:06 +0530 Subject: [PATCH 5/5] Added task 5 file --- task5.txt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 task5.txt diff --git a/task5.txt b/task5.txt new file mode 100644 index 0000000..8ace9f6 --- /dev/null +++ b/task5.txt @@ -0,0 +1,5 @@ +Task 5 – Create a Pull Request + +I created a new branch for Task 5. +I committed this file to my branch. +I will submit this change using a pull request.