From 9a35724f7b9f2cc022eb339d0d12b6ab174bca79 Mon Sep 17 00:00:00 2001 From: chex Date: Fri, 20 Oct 2023 00:56:04 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat/#517:=20=EA=B0=95=EC=95=84=EC=A7=80=20?= =?UTF-8?q?=EA=BA=A0=EC=9A=B0=EA=B8=B0=20=EC=9D=B4=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EC=97=90=EA=B7=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/Landing/Landing.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/Landing/Landing.tsx b/frontend/src/pages/Landing/Landing.tsx index 0650c55a..baf7f6d3 100644 --- a/frontend/src/pages/Landing/Landing.tsx +++ b/frontend/src/pages/Landing/Landing.tsx @@ -1,4 +1,4 @@ -import { Suspense, useState } from 'react'; +import { useState } from 'react'; import styled from 'styled-components'; import ZipgoBannerPng from '@/assets/webp/landing_banner.webp'; @@ -9,18 +9,31 @@ import FoodList from '@/components/Food/FoodList/FoodList'; import FoodSelectionGuideBanner from '@/components/FoodSelectionGuideBanner/FoodSelectionGuideBanner'; import { useToast } from '@/context/Toast/ToastContext'; +const TARGET_NUMBER = 100; + +let startTime: Date | undefined; +let endTime: Date | undefined; + const Landing = () => { const { toast } = useToast(); const [dogTouchCount, setDogTouchCount] = useState(1); const onTouchDog = () => { - if (dogTouchCount % 10 === 0) { + if (dogTouchCount === 1) { + startTime = new Date(); + toast.info(`강아지를 ${dogTouchCount}번 쓰다듬었어요.`); + } else if (dogTouchCount === TARGET_NUMBER && startTime) { + endTime = new Date(); + toast.success(`${(+endTime - +startTime) / 1000}초 만에 강아지를 깨웠어요!`); + } else if (TARGET_NUMBER - dogTouchCount === 10) { toast.warning('강아지를 깨우지 않게 조심하세요!'); } else { toast.info(`강아지를 ${dogTouchCount}번 쓰다듬었어요.`); } - setDogTouchCount(prev => prev + 1); + + if (dogTouchCount === TARGET_NUMBER) setDogTouchCount(prev => 1); + else setDogTouchCount(prev => prev + 1); }; return ( From 89cba3d91e7cd6d61b7eac540c9d2ca01060daf6 Mon Sep 17 00:00:00 2001 From: chex Date: Fri, 20 Oct 2023 01:04:01 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feature/#517:=20=EB=AA=A9=ED=91=9C=20?= =?UTF-8?q?=ED=9A=9F=EC=88=98=EC=97=90=20=EB=8F=84=EB=8B=AC=ED=95=98?= =?UTF-8?q?=EB=A9=B4=20=EB=A9=88=EC=B6=94=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/Landing/Landing.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/Landing/Landing.tsx b/frontend/src/pages/Landing/Landing.tsx index baf7f6d3..f2261b18 100644 --- a/frontend/src/pages/Landing/Landing.tsx +++ b/frontend/src/pages/Landing/Landing.tsx @@ -28,12 +28,11 @@ const Landing = () => { toast.success(`${(+endTime - +startTime) / 1000}초 만에 강아지를 깨웠어요!`); } else if (TARGET_NUMBER - dogTouchCount === 10) { toast.warning('강아지를 깨우지 않게 조심하세요!'); - } else { + } else if (dogTouchCount < TARGET_NUMBER) { toast.info(`강아지를 ${dogTouchCount}번 쓰다듬었어요.`); } - if (dogTouchCount === TARGET_NUMBER) setDogTouchCount(prev => 1); - else setDogTouchCount(prev => prev + 1); + if (dogTouchCount <= TARGET_NUMBER) setDogTouchCount(prev => prev + 1); }; return (