Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
32 changes: 25 additions & 7 deletions apps/timo-web/components/timer/TimerExtendModalPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Modal } from "@repo/timo-design-system/ui";
import { Modal, ModalButton } from "@repo/timo-design-system/ui";
import { cn } from "@repo/timo-design-system/utils";
import { useTranslations } from "next-intl";

import { extendTimerBodyExtendMinutesMax } from "@/api/generated/endpoints/timer/timer.zod";

export type ExtendTimePreset = 10 | 30 | 60 | "custom";

type ExtendPresetLabelKey =
Expand All @@ -18,8 +20,6 @@ const PRESET_OPTIONS: {
{ preset: 60, labelKey: "presetOneHour" },
];

const MAX_CUSTOM_MINUTES = 720;

const CHIP_FOCUS_BORDER_CLASS =
"border-2 border-transparent focus-visible:border-timo-blue-300 outline-none";

Expand All @@ -31,6 +31,8 @@ export interface TimerExtendModalPanelProps {
onClose: () => void;
onSubmit: () => void;
canSubmit: boolean;
/** 이전에 노출되던 팝업(End 모달)으로 돌아갈 수 있는 경우에만 true — 이 경우 닫기 버튼이 모달 자체를 닫지 않고 onClose에서 이전 단계로 전환한다 */
canGoBack: boolean;
}

export const TimerExtendModalPanel = ({
Expand All @@ -41,6 +43,7 @@ export const TimerExtendModalPanel = ({
onClose,
onSubmit,
canSubmit,
canGoBack,
}: TimerExtendModalPanelProps) => {
const t = useTranslations("Focus.extendModal");
const isCustomSelected = selectedPreset === "custom";
Expand Down Expand Up @@ -79,7 +82,12 @@ export const TimerExtendModalPanel = ({
const clamped =
digitsOnly === ""
? ""
: String(Math.min(Number(digitsOnly), MAX_CUSTOM_MINUTES));
: String(
Math.min(
Number(digitsOnly),
extendTimerBodyExtendMinutesMax,
),
);

onCustomMinutesChange(clamped);
}}
Expand All @@ -106,9 +114,19 @@ export const TimerExtendModalPanel = ({
</div>

<div className="mt-2.5 flex w-full gap-1.5">
<Modal.BorderButton className="flex-1 px-0" onClick={onClose}>
{t("closeButton")}
</Modal.BorderButton>
{canGoBack ? (
<ModalButton
variant="border"
className="flex-1 px-0"
onClick={onClose}
>
{t("closeButton")}
</ModalButton>
) : (
<Modal.BorderButton className="flex-1 px-0" onClick={onClose}>
{t("closeButton")}
</Modal.BorderButton>
)}
<Modal.FillButton
className={cn(
"flex-1 px-0",
Expand Down
13 changes: 12 additions & 1 deletion apps/timo-web/components/timer/TimerSessionControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const TimerSessionControls = forwardRef<
null,
);
const [customMinutes, setCustomMinutes] = useState("");
const [cameFromEndModal, setCameFromEndModal] = useState(false);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

const resetExtendSelection = () => {
setSelectedPreset(null);
Expand All @@ -71,6 +72,7 @@ export const TimerSessionControls = forwardRef<
if (minutes > 0) onExtend(minutes);

resetExtendSelection();
setCameFromEndModal(false);
};

const canSubmitExtend =
Expand All @@ -85,6 +87,7 @@ export const TimerSessionControls = forwardRef<
onOpenEndModal={() => setStep(isRunning ? "stop" : "end")}
onOpenExtendModal={() => {
resetExtendSelection();
setCameFromEndModal(false);
setStep("extend");
}}
/>
Expand All @@ -100,6 +103,7 @@ export const TimerSessionControls = forwardRef<
<TimerEndModalPanel
onContinue={() => {
resetExtendSelection();
setCameFromEndModal(true);
setStep("extend");
}}
onComplete={() => setStep("complete")}
Expand All @@ -120,9 +124,16 @@ export const TimerSessionControls = forwardRef<
if (preset !== "custom") setCustomMinutes("");
}}
onCustomMinutesChange={setCustomMinutes}
onClose={resetExtendSelection}
onClose={() => {
resetExtendSelection();
if (cameFromEndModal) {
setCameFromEndModal(false);
setStep("end");
}
}}
onSubmit={handleSubmitExtend}
canSubmit={canSubmitExtend}
canGoBack={cameFromEndModal}
/>
)}
{step === "complete" && (
Expand Down
3 changes: 2 additions & 1 deletion apps/timo-web/messages/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@
"title": "지금 멈출까요?",
"description": "지금까지 수행한 <blue>{minutes}</blue>이 타임박스에 기록됩니다.",
"continueButton": "계속 진행",
"switchButton": "전환하기"
"switchButton": "완료하기"
},

"completeModal": {
"title": "태스크가 완료되었어요!",
"defaultFeedback": "이번 작업을 완료했어요. 수고하셨어요!",
Expand Down
Loading