Skip to content

Commit

Permalink
feat: 강아지 깨우기 이스터에그 추가 (#518)
Browse files Browse the repository at this point in the history
* feat/#517: 강아지 꺠우기 이스터에그 추가

* feature/#517: 목표 횟수에 도달하면 멈추도록 수정
  • Loading branch information
HyeryongChoi authored Oct 19, 2023
1 parent c19ecfc commit b7d4558
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions frontend/src/pages/Landing/Landing.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -9,18 +9,30 @@ 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<number>(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 {
} else if (dogTouchCount < TARGET_NUMBER) {
toast.info(`강아지를 ${dogTouchCount}번 쓰다듬었어요.`);
}
setDogTouchCount(prev => prev + 1);

if (dogTouchCount <= TARGET_NUMBER) setDogTouchCount(prev => prev + 1);
};

return (
Expand Down

0 comments on commit b7d4558

Please sign in to comment.