From f6c71d1fc8f5a5782e439872e5282c04ff0abe06 Mon Sep 17 00:00:00 2001 From: vinaybadgujar102 Date: Sat, 18 May 2024 12:39:00 +0530 Subject: [PATCH 1/3] update budget field to have value object or undefined --- .../GoalsComponents/GoalConfigModal/ConfigGoal.tsx | 6 +++--- src/models/GoalItem.ts | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/GoalsComponents/GoalConfigModal/ConfigGoal.tsx b/src/components/GoalsComponents/GoalConfigModal/ConfigGoal.tsx index f345176e6..69868259d 100644 --- a/src/components/GoalsComponents/GoalConfigModal/ConfigGoal.tsx +++ b/src/components/GoalsComponents/GoalConfigModal/ConfigGoal.tsx @@ -128,10 +128,10 @@ const ConfigGoal = ({ goal, action }: { action: "Update" | "Create"; goal: GoalI timeBudget: state.goalType === "Budget" ? { - perDay: state.goalType === "Budget" ? perDayHrs.join("-") : null, - perWeek: state.goalType === "Budget" ? perWeekHrs.join("-") : null, + perDay: perDayHrs.join("-"), + perWeek: perWeekHrs.join("-"), } - : null, + : undefined, category: state.goalType === "Budget" ? "Budget" : tags.duration !== "" ? "Standard" : "Cluster", }); diff --git a/src/models/GoalItem.ts b/src/models/GoalItem.ts index 90bd214f9..e3c33ae45 100644 --- a/src/models/GoalItem.ts +++ b/src/models/GoalItem.ts @@ -28,10 +28,12 @@ export interface GoalItem { link: string | null; participants: IParticipant[]; rootGoalId: string; - timeBudget: { - perDay: string | null; - perWeek: string | null; - } | null; + timeBudget: + | { + perDay: string; + perWeek: string; + } + | undefined; typeOfGoal: "myGoal" | "shared"; category: TGoalCategory; newUpdates: boolean; From ba527776d223243c9a34f94bf5da0d8abc2771a2 Mon Sep 17 00:00:00 2001 From: vinaybadgujar102 Date: Sun, 19 May 2024 15:42:41 +0530 Subject: [PATCH 2/3] updated goalprocessor function to support timeBudgets to be undefined and fixed type a error --- src/constants/starterGoals.ts | 5 +---- src/helpers/GoalProcessor.ts | 13 +++++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/constants/starterGoals.ts b/src/constants/starterGoals.ts index 1e864d0dc..aa5c323b7 100644 --- a/src/constants/starterGoals.ts +++ b/src/constants/starterGoals.ts @@ -101,10 +101,7 @@ starterGoals.push( id: dailyHabitsId, afterTime: null, beforeTime: null, - timeBudget: { - perDay: null, - perWeek: null, - }, + timeBudget: undefined, sublist: [otherGoalIds[5], otherGoalIds[6], otherGoalIds[7], otherGoalIds[8], otherGoalIds[9]], }, }, diff --git a/src/helpers/GoalProcessor.ts b/src/helpers/GoalProcessor.ts index 650169089..d9fbb7f58 100644 --- a/src/helpers/GoalProcessor.ts +++ b/src/helpers/GoalProcessor.ts @@ -74,10 +74,7 @@ export const createGoalObjectFromTags = (obj: object) => { language: "English", habit: null, on: null, - timeBudget: { - perDay: null, - perWeek: null, - }, + timeBudget: undefined, duration: null, start: null, due: null, @@ -90,8 +87,11 @@ export const createGoalObjectFromTags = (obj: object) => { sublist: [], goalColor: colorPalleteList[Math.floor(Math.random() * colorPalleteList.length)], typeOfGoal: "myGoal", - ...obj, + createdAt: "", participants: [], + newUpdates: false, + category: "Standard", + ...obj, }; if (newGoal.rootGoalId === "root") { newGoal.rootGoalId = newGoal.id; @@ -103,7 +103,8 @@ export const getHistoryUptoGoal = async (id: string) => { const history = []; let openGoalOfId = id; while (openGoalOfId !== "root") { - const tmpGoal: GoalItem = await getGoal(openGoalOfId); + const tmpGoal: GoalItem | null = await getGoal(openGoalOfId); + if (!tmpGoal) break; history.push({ goalID: tmpGoal.id || "root", goalColor: tmpGoal.goalColor || "#ffffff", From c0f072472f7661514312f23162d0e2e1afdf5c5c Mon Sep 17 00:00:00 2001 From: vinaybadgujar102 Date: Thu, 23 May 2024 14:44:40 +0530 Subject: [PATCH 3/3] make timeBudget field optional --- src/constants/starterGoals.ts | 1 - src/helpers/GoalProcessor.ts | 1 - src/models/GoalItem.ts | 10 ++++------ 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/constants/starterGoals.ts b/src/constants/starterGoals.ts index aa5c323b7..4458491ba 100644 --- a/src/constants/starterGoals.ts +++ b/src/constants/starterGoals.ts @@ -101,7 +101,6 @@ starterGoals.push( id: dailyHabitsId, afterTime: null, beforeTime: null, - timeBudget: undefined, sublist: [otherGoalIds[5], otherGoalIds[6], otherGoalIds[7], otherGoalIds[8], otherGoalIds[9]], }, }, diff --git a/src/helpers/GoalProcessor.ts b/src/helpers/GoalProcessor.ts index d9fbb7f58..eb15d49e5 100644 --- a/src/helpers/GoalProcessor.ts +++ b/src/helpers/GoalProcessor.ts @@ -74,7 +74,6 @@ export const createGoalObjectFromTags = (obj: object) => { language: "English", habit: null, on: null, - timeBudget: undefined, duration: null, start: null, due: null, diff --git a/src/models/GoalItem.ts b/src/models/GoalItem.ts index e3c33ae45..9471c4b96 100644 --- a/src/models/GoalItem.ts +++ b/src/models/GoalItem.ts @@ -28,12 +28,10 @@ export interface GoalItem { link: string | null; participants: IParticipant[]; rootGoalId: string; - timeBudget: - | { - perDay: string; - perWeek: string; - } - | undefined; + timeBudget?: { + perDay: string; + perWeek: string; + }; typeOfGoal: "myGoal" | "shared"; category: TGoalCategory; newUpdates: boolean;