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

update timeBudget field in goalItem to be budget object or undefined #1923

Merged
merged 4 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading