Skip to content

Commit

Permalink
fix: need to fix continue button, pause music start when clicked even…
Browse files Browse the repository at this point in the history
… if I'm working
  • Loading branch information
mohammed committed Oct 4, 2023
1 parent 881c99b commit 906abde
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"semi": false,
"semi": true,
"tabWidth": 2,
"printWidth": 100,
"singleQuote": true,
Expand Down
27 changes: 18 additions & 9 deletions src/components/Form/TimerFormHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ const TimerFormHandler = () => {

const handleFormSubmit = (event: FormEvent): void => {
event.preventDefault()
setStoreWorkTime(workTime)
setStorePauseTime(pauseTime)
setIsWorkTimerRunning(true)
setIsPauseTimerRunning(false)
setStoreWorkTime(workTime);
setStorePauseTime(pauseTime);
setIsWorkTimerRunning(true);
setIsPauseTimerRunning(false);
}

const handlePauseTimer = (): void => {
setIsWorkTimerRunning(false)
setIsPauseTimerRunning(false)
setStartPauseSound(false)
setIsWorkTimerRunning(false);
setIsPauseTimerRunning(false);
setStartPauseSound(false);
setStartWorkSound([false, false]);
}

const handleResetTimer = (): void => {
Expand All @@ -36,8 +37,11 @@ const TimerFormHandler = () => {
}

const handleContinueTimer = (): void => {
setIsWorkTimerRunning(workTime.toString() != storeWorkTime?.toString())
setIsPauseTimerRunning(pauseTime.toString() != storePauseTime?.toString())
setIsWorkTimerRunning(workTime.toString() != storeWorkTime?.toString());
setStartWorkSound([false, workTime.toString() != storeWorkTime?.toString()]);
setIsPauseTimerRunning(pauseTime.toString() != storePauseTime?.toString());
console.log(pauseTime.toString() != storePauseTime?.toString());
setStartPauseSound(pauseTime.toString() != storePauseTime?.toString());
isWorkTimerRunning ? setStartPauseSound(false) : setStartPauseSound(true)
}

Expand All @@ -54,6 +58,7 @@ const TimerFormHandler = () => {
if (alertNotification) {
setAlertNotification(false)
}

if (isPauseTimerRunning && !alertNotification) {
setAlertNotification(true)
}
Expand All @@ -62,18 +67,22 @@ const TimerFormHandler = () => {
if (isPauseTimerRunning) {
setStartWorkSound([true, false])
}

if (startWorkSound[0] && isWorkTimerRunning) {
setStartWorkSound([true, true])
}

if (totalSeconds <= 0) {
clearInterval(timeInterval)
setIsWorkTimerRunning(!isWorkTimerRunning)
setStartPauseSound(isWorkTimerRunning)
setIsPauseTimerRunning(isWorkTimerRunning)

if (storeWorkTime && storePauseTime) {
setWorkTime(storeWorkTime)
setPauseTime(storePauseTime)
}

} else {
totalSeconds -= 1
const hours: number = Math.floor(totalSeconds / 3600)
Expand Down

0 comments on commit 906abde

Please sign in to comment.