Skip to content

Commit

Permalink
Fix: 명상 종료 버튼 핸들러에 명상 관련 정보 초기화 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
sscoderati committed Jan 9, 2024
1 parent 64e69d3 commit 7008cb0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/pages/meditation/components/MeditationEndButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,28 @@ import { useState } from 'react';
import { Confirm } from '@components/Confirm';
import { Button } from '@components/Button';
import { EndButtonContainer } from './MeditationEndButton.style';
import { MeditationStatusType } from '@pages/meditation/types';
import { intervalId, meditationTime } from '@pages/meditation/states';
import { useRecoilState, useSetRecoilState } from 'recoil';

const MeditationEndButton = () => {
const MeditationEndButton = ({
statusSetter: meditationStatusSetter
}: {
statusSetter: React.Dispatch<React.SetStateAction<MeditationStatusType>>;
}) => {
const [confirmCaptured, setConfirmCaptured] = useState(false);
const setTime = useSetRecoilState(meditationTime);
const [timerId, setTimerId] = useRecoilState(intervalId);

const handleCancelButton = () => {
setConfirmCaptured(false);
};

const handleConfirmButton = () => {
location.reload(); // 리팩토링 전 임시방편
meditationStatusSetter({ started: false, paused: true, ended: false });
clearInterval(timerId);
setTimerId(0);
setTime(0);
};
return (
<>
Expand Down

0 comments on commit 7008cb0

Please sign in to comment.