Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 강아지 깨우기 이스터에그 추가 #518

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Changes from all 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
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