Skip to content

Commit

Permalink
Merge pull request #1923 from tijlleenders/vin/1760/budget_undefined
Browse files Browse the repository at this point in the history
update timeBudget field in goalItem to be budget object or undefined
  • Loading branch information
Tushar-4781 authored May 26, 2024
2 parents 0dee01a + c0f0724 commit e149b37
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/components/GoalsComponents/GoalConfigModal/ConfigGoal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});

Expand Down
4 changes: 0 additions & 4 deletions src/constants/starterGoals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ starterGoals.push(
id: dailyHabitsId,
afterTime: null,
beforeTime: null,
timeBudget: {
perDay: null,
perWeek: null,
},
sublist: [otherGoalIds[5], otherGoalIds[6], otherGoalIds[7], otherGoalIds[8], otherGoalIds[9]],
},
},
Expand Down
12 changes: 6 additions & 6 deletions src/helpers/GoalProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ export const createGoalObjectFromTags = (obj: object) => {
language: "English",
habit: null,
on: null,
timeBudget: {
perDay: null,
perWeek: null,
},
duration: null,
start: null,
due: null,
Expand All @@ -90,8 +86,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;
Expand All @@ -103,7 +102,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",
Expand Down
8 changes: 4 additions & 4 deletions src/models/GoalItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ export interface GoalItem {
link: string | null;
participants: IParticipant[];
rootGoalId: string;
timeBudget: {
perDay: string | null;
perWeek: string | null;
} | null;
timeBudget?: {
perDay: string;
perWeek: string;
};
typeOfGoal: "myGoal" | "shared";
category: TGoalCategory;
newUpdates: boolean;
Expand Down

0 comments on commit e149b37

Please sign in to comment.