diff --git a/src/Interfaces/index.ts b/src/Interfaces/index.ts index 41e81983d..7c0860a4e 100644 --- a/src/Interfaces/index.ts +++ b/src/Interfaces/index.ts @@ -33,3 +33,5 @@ export interface ILocationState { export interface ImpossibleGoal extends GoalItem { impossible: boolean; } + +export type ScheduleStatus = "pending" | "scheduled" | "impossible" | "future" | null; diff --git a/src/components/GoalsComponents/GoalConfigModal/ConfigGoal.scss b/src/components/GoalsComponents/GoalConfigModal/ConfigGoal.scss index d2e654010..89d30f086 100644 --- a/src/components/GoalsComponents/GoalConfigModal/ConfigGoal.scss +++ b/src/components/GoalsComponents/GoalConfigModal/ConfigGoal.scss @@ -160,4 +160,5 @@ .schedule-status { margin-top: 8px; font-size: 14px; + text-align: center; } diff --git a/src/components/GoalsComponents/GoalConfigModal/ConfigGoal.tsx b/src/components/GoalsComponents/GoalConfigModal/ConfigGoal.tsx index cea958c67..2f47f49a5 100644 --- a/src/components/GoalsComponents/GoalConfigModal/ConfigGoal.tsx +++ b/src/components/GoalsComponents/GoalConfigModal/ConfigGoal.tsx @@ -17,7 +17,7 @@ import { useParentGoalContext } from "@src/contexts/parentGoal-context"; import useGoalActions from "@src/hooks/useGoalActions"; import useGoalStore from "@src/hooks/useGoalStore"; import { unarchiveUserGoal } from "@src/api/GoalsAPI"; -import { ILocationState } from "@src/Interfaces"; +import { ILocationState, ScheduleStatus } from "@src/Interfaces"; import { useLocation, useNavigate } from "react-router-dom"; import { suggestedGoalState } from "@src/store/SuggestedGoalState"; import { getHistoryUptoGoal } from "@src/helpers/GoalProcessor"; @@ -49,6 +49,9 @@ const ConfigGoal = ({ type, goal, mode }: { type: TGoalCategory; mode: TGoalConf const location = useLocation(); const navigate = useNavigate(); + const { checkGoalSchedule } = useScheduler(); + const [scheduleStatus, setScheduleStatus] = useState(null); + let defaultColorIndex = Math.floor(Math.random() * colorPalleteList.length - 1) + 1; let defaultAfterTime = isEditMode ? (goal.afterTime ?? 9) : 9; let defaultBeforeTime = isEditMode ? (goal.beforeTime ?? 18) : 18; @@ -279,14 +282,8 @@ const ConfigGoal = ({ type, goal, mode }: { type: TGoalCategory; mode: TGoalConf setHintOption(hint?.hintOptionEnabled || false); }; - const { checkGoalSchedule } = useScheduler(); - const titlePlaceholder = t(`${type !== "Budget" ? "goal" : "budget"}Title`); - type ScheduleStatus = "pending" | "scheduled" | "impossible" | "future" | null; - - const [scheduleStatus, setScheduleStatus] = useState(null); - const checkSchedulingStatus = async (schedulerOutput: ISchedulerOutput | undefined, goalId: string) => { if (!schedulerOutput) return "pending"; @@ -315,12 +312,6 @@ const ConfigGoal = ({ type, goal, mode }: { type: TGoalCategory; mode: TGoalConf }; const checkSchedule = async () => { - // if (t) { - // setScheduleStatus(null); - // console.log("no duration"); - // return; - // } - setScheduleStatus("pending"); const schedulerOutput = await checkGoalSchedule(getFinalTags()); console.log("schedulerOutput", schedulerOutput); @@ -474,10 +465,10 @@ const ConfigGoal = ({ type, goal, mode }: { type: TGoalCategory; mode: TGoalConf - {scheduleStatus && ( -
{getScheduleStatusText(scheduleStatus)}
- )} + {scheduleStatus && ( +
{getScheduleStatusText(scheduleStatus)}
+ )} ) : (
@@ -487,9 +478,6 @@ const ConfigGoal = ({ type, goal, mode }: { type: TGoalCategory; mode: TGoalConf {t(`${action} Goal`)}
- {scheduleStatus && ( -
{getScheduleStatusText(scheduleStatus)}
- )}
{t("duration")}
+ {scheduleStatus && tags.duration && ( +
{getScheduleStatusText(scheduleStatus)}
+ )} )}