From 2044afe79368c9067c818b171857b009dc283a41 Mon Sep 17 00:00:00 2001 From: yheseul Date: Thu, 25 Jul 2024 15:56:22 +0900 Subject: [PATCH 01/52] =?UTF-8?q?=F0=9F=90=9B=20Fix:=20=ED=99=94=EB=A9=B4?= =?UTF-8?q?=20=EA=B9=9C=EB=B9=A1=EA=B1=B0=EB=A6=BC=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(test)/test/questions/[questionId]/page.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/(test)/test/questions/[questionId]/page.tsx b/src/app/(test)/test/questions/[questionId]/page.tsx index 75b1dba..e749d31 100644 --- a/src/app/(test)/test/questions/[questionId]/page.tsx +++ b/src/app/(test)/test/questions/[questionId]/page.tsx @@ -86,6 +86,7 @@ export default function Questions({ params }: TQuestionsProps) { sessionStorage.removeItem('questions'); sessionStorage.removeItem('positionArr'); } + setLoading(false); }; const progress = ((questionIndex + 1) / totalQuestions) * 100; From f1d78547d0b5c9b8c5510d6c11070d99f48d6567 Mon Sep 17 00:00:00 2001 From: yheseul Date: Fri, 26 Jul 2024 10:50:10 +0900 Subject: [PATCH 02/52] =?UTF-8?q?=F0=9F=8E=A8=20Style:=20=EC=9D=98?= =?UTF-8?q?=EB=AF=B8=EC=97=86=EB=8A=94=20=EC=BD=94=EB=93=9C=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 --- src/app/(main)/@modal/default.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/(main)/@modal/default.tsx b/src/app/(main)/@modal/default.tsx index a56c3ba..2aacd05 100644 --- a/src/app/(main)/@modal/default.tsx +++ b/src/app/(main)/@modal/default.tsx @@ -8,7 +8,6 @@ import ModalWrapper from '@/components/test/ModalWrapper'; export default function Default() { const pathname = usePathname(); - console.log(pathname); return ( <> From a60675288ece89f8842227e169eb159c52709386 Mon Sep 17 00:00:00 2001 From: yheseul Date: Fri, 26 Jul 2024 10:50:32 +0900 Subject: [PATCH 03/52] =?UTF-8?q?=F0=9F=8E=A8=20Style:=20=EC=9D=98?= =?UTF-8?q?=EB=AF=B8=EC=97=86=EB=8A=94=20=EC=BD=94=EB=93=9C=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 --- src/app/(main)/layout.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/(main)/layout.tsx b/src/app/(main)/layout.tsx index 02fb65a..73c248b 100644 --- a/src/app/(main)/layout.tsx +++ b/src/app/(main)/layout.tsx @@ -1,5 +1,4 @@ import Header from '@/components/Header'; -import ModalWrapper from '@/components/test/ModalWrapper'; export default function MainLayout({ children, From 9534917bb5b290e5ff2717a4616ce9996debf317 Mon Sep 17 00:00:00 2001 From: yheseul Date: Fri, 26 Jul 2024 10:51:30 +0900 Subject: [PATCH 04/52] =?UTF-8?q?=F0=9F=8E=A8=20Style:=20=ED=94=84?= =?UTF-8?q?=EB=A6=AC=ED=8B=B0=EC=96=B4=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(main)/@modal/(.)testModal/page.tsx | 74 ++++++++++----------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/app/(main)/@modal/(.)testModal/page.tsx b/src/app/(main)/@modal/(.)testModal/page.tsx index a347b59..9497d10 100644 --- a/src/app/(main)/@modal/(.)testModal/page.tsx +++ b/src/app/(main)/@modal/(.)testModal/page.tsx @@ -7,46 +7,46 @@ export default function Modal() { <>
-
-
- 야구 입문자를 위한 +
+
+ 야구 입문자를 위한 +
+ watermark +
+ 궁합테스트 +
+
+ 나와 어울리는 KT Wiz 선수 알아보기! +
+ emblem +
- watermark -
- 궁합테스트 -
-
- 나와 어울리는 KT Wiz 선수 알아보기! -
- emblem - -
-
-
- kt wiz는 2013년, 제 10구단에 대한 국민들의 강한 열망, -
경기도 및 수원시 그리고 KT그룹의 뜨거운 유치 열정으로 -
비상한 솜씨와 비범한 재능을 가진 마법사, -
- wiz라는 이름으로 신비롭고 강력한 힘으로 상상의 야구를 -
실현하겠다는 의지를 가지고 새롭게 출범하였습니다. +
+
+ kt wiz는 2013년, 제 10구단에 대한 국민들의 강한 열망, +
경기도 및 수원시 그리고 KT그룹의 뜨거운 유치 열정으로 +
비상한 솜씨와 비범한 재능을 가진 마법사, +
+ wiz라는 이름으로 신비롭고 강력한 힘으로 상상의 야구를 +
실현하겠다는 의지를 가지고 새롭게 출범하였습니다. +
-
- + ); } From 55e854611cca7463ccdd83300b2c8aa109a3e88c Mon Sep 17 00:00:00 2001 From: yheseul Date: Fri, 26 Jul 2024 10:52:23 +0900 Subject: [PATCH 05/52] =?UTF-8?q?=F0=9F=A4=96=20Refactor:=20=EB=AA=A8?= =?UTF-8?q?=EB=8B=AC=20=EB=A1=9C=EB=94=A9=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../questions/[questionId]/page.tsx | 28 ++++---- src/components/test/ModalLoading.tsx | 70 +++++++++++++++++++ 2 files changed, 85 insertions(+), 13 deletions(-) create mode 100644 src/components/test/ModalLoading.tsx diff --git a/src/app/(main)/@questions/(.)testModal/questions/[questionId]/page.tsx b/src/app/(main)/@questions/(.)testModal/questions/[questionId]/page.tsx index 99b869a..01f93cf 100644 --- a/src/app/(main)/@questions/(.)testModal/questions/[questionId]/page.tsx +++ b/src/app/(main)/@questions/(.)testModal/questions/[questionId]/page.tsx @@ -7,7 +7,7 @@ import ProgressBar from '@/components/test/ProgressBar'; import TestAnswer from '@/components/test/TestAnswer'; import { IoIosArrowBack } from 'react-icons/io'; import { TQuestionHandlerProps } from '@/types'; -import Loading from '@/app/(test)/test/loading'; +import ModalLoading from '@/components/test/ModalLoading'; type TQuestionsProps = { params: { @@ -24,18 +24,15 @@ export default function Questions({ params }: TQuestionsProps) { useEffect(() => { const fetchQuestions = async () => { try { - const cachedQuestions = sessionStorage.getItem('questions'); - if (cachedQuestions) { - setQuestions(JSON.parse(cachedQuestions)); + sessionStorage.removeItem('questions'); + sessionStorage.removeItem('positionArr'); + const response = await fetch('/api/questions'); + if (response.ok) { + const data = await response.json(); + setQuestions(data); + sessionStorage.setItem('questions', JSON.stringify(data)); } else { - const response = await fetch('/api/questions'); - if (response.ok) { - const data = await response.json(); - setQuestions(data); - sessionStorage.setItem('questions', JSON.stringify(data)); - } else { - console.error('Failed to fetch questions'); - } + console.error('Failed to fetch questions'); } } catch (error) { console.error('Failed to fetch questions', error); @@ -53,7 +50,11 @@ export default function Questions({ params }: TQuestionsProps) { }, []); if (loading) { - return ; + return ( + + + + ); } const questionIndex = parseInt(params.questionId, 10) - 1; @@ -92,6 +93,7 @@ export default function Questions({ params }: TQuestionsProps) { sessionStorage.removeItem('questions'); sessionStorage.removeItem('positionArr'); } + setLoading(false); }; const progress = ((questionIndex + 1) / totalQuestions) * 100; diff --git a/src/components/test/ModalLoading.tsx b/src/components/test/ModalLoading.tsx new file mode 100644 index 0000000..6affcb3 --- /dev/null +++ b/src/components/test/ModalLoading.tsx @@ -0,0 +1,70 @@ +'use client'; + +import { useEffect, useState } from 'react'; + +const images = [ + '/svgs/test/loading/0.svg', + '/svgs/test/loading/1.svg', + '/svgs/test/loading/2.svg', + '/svgs/test/loading/3.svg', + '/svgs/test/loading/4.svg', + '/svgs/test/loading/5.svg', + '/svgs/test/loading/6.svg', + '/svgs/test/loading/7.svg', +]; + +const texts = ['야구 데이터 분석중', '성향 분석중', 'AI 퀴즈 생성중']; + +export default function ModalLoading() { + const [currentImageIndex, setCurrentImageIndex] = useState(0); + const [dots, setDots] = useState(''); + const [text, setText] = useState(0); + + useEffect(() => { + const imageInterval = setInterval(() => { + setCurrentImageIndex((prevIndex) => (prevIndex + 1) % images.length); + }, 300); + + return () => clearInterval(imageInterval); + }, []); + + useEffect(() => { + const dotInterval = setInterval(() => { + setDots((prevDots) => (prevDots.length === 6 ? '' : prevDots + '.')); + }, 400); + + return () => clearInterval(dotInterval); + }, []); + + useEffect(() => { + const textInterval = setInterval(() => { + setText((prevIndex) => { + setDots(''); + return (prevIndex + 1) % texts.length; + }); + }, 5000); + + return () => clearInterval(textInterval); + }, []); + + return ( +
+
+ {images.map((image, index) => ( + {`슬라이드 + ))} +
+
+ {texts[text]} + {dots} +
+
+ ); +} From c31628a75cfa0a0ba00c0183f09b281ff41bbce1 Mon Sep 17 00:00:00 2001 From: yheseul Date: Fri, 26 Jul 2024 10:52:55 +0900 Subject: [PATCH 06/52] =?UTF-8?q?=F0=9F=A4=96=20Refactor:=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/questions/[questionId]/page.tsx | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/app/(test)/test/questions/[questionId]/page.tsx b/src/app/(test)/test/questions/[questionId]/page.tsx index e749d31..9be7a7e 100644 --- a/src/app/(test)/test/questions/[questionId]/page.tsx +++ b/src/app/(test)/test/questions/[questionId]/page.tsx @@ -23,18 +23,15 @@ export default function Questions({ params }: TQuestionsProps) { useEffect(() => { const fetchQuestions = async () => { try { - const cachedQuestions = sessionStorage.getItem('questions'); - if (cachedQuestions) { - setQuestions(JSON.parse(cachedQuestions)); + sessionStorage.removeItem('questions'); + sessionStorage.removeItem('positionArr'); + const response = await fetch('/api/questions'); + if (response.ok) { + const data = await response.json(); + setQuestions(data); + sessionStorage.setItem('questions', JSON.stringify(data)); } else { - const response = await fetch('/api/questions'); - if (response.ok) { - const data = await response.json(); - setQuestions(data); - sessionStorage.setItem('questions', JSON.stringify(data)); - } else { - console.error('Failed to fetch questions'); - } + console.error('Failed to fetch questions'); } } catch (error) { console.error('Failed to fetch questions', error); From 815cb8b9f9e98f78066d85d17951c4574a89c2a6 Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sat, 27 Jul 2024 11:04:50 +0900 Subject: [PATCH 07/52] =?UTF-8?q?=F0=9F=92=84=20Design:=20=ED=98=B8?= =?UTF-8?q?=EB=B2=84=20=EC=8B=9C=20box-shadow=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/wiznews/NewsBalloon.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/wiznews/NewsBalloon.tsx b/src/components/wiznews/NewsBalloon.tsx index ddcad7f..4aeb464 100644 --- a/src/components/wiznews/NewsBalloon.tsx +++ b/src/components/wiznews/NewsBalloon.tsx @@ -21,7 +21,7 @@ export default function NewsBalloon({ >
{ai && (
From 94e5f8271c4219c193ed74c162c40417798caf71 Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sat, 27 Jul 2024 11:05:19 +0900 Subject: [PATCH 08/52] =?UTF-8?q?=F0=9F=92=84=20Design:=20=ED=8C=A8?= =?UTF-8?q?=EB=94=A9=EC=9D=84=20=EC=82=AC=EC=9A=A9=ED=95=B4=20=EB=89=B4?= =?UTF-8?q?=EC=8A=A4=20=EB=A7=90=ED=92=8D=EC=84=A0=EC=9D=98=20=ED=98=B8?= =?UTF-8?q?=EB=B2=84=20=ED=9A=A8=EA=B3=BC=EB=A5=BC=20=EC=9C=84=ED=95=9C=20?= =?UTF-8?q?=EA=B3=B5=EA=B0=84=20=ED=99=95=EB=B3=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/wiznews/NewsArea.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/wiznews/NewsArea.tsx b/src/components/wiznews/NewsArea.tsx index 81ebbe3..465e939 100644 --- a/src/components/wiznews/NewsArea.tsx +++ b/src/components/wiznews/NewsArea.tsx @@ -56,7 +56,7 @@ export default function NewsArea() { }, []); return ( <> -
+
{newsList.length && newsList.map( (news, index) => From 7c10d7f866fe1c5af0f5c2e1e829395adcd786ae Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sat, 27 Jul 2024 12:29:10 +0900 Subject: [PATCH 09/52] =?UTF-8?q?=F0=9F=8E=A8=20Style:=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20=EC=BD=98=EC=86=94=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/wiznews/NewsLoader.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/wiznews/NewsLoader.tsx b/src/components/wiznews/NewsLoader.tsx index d5441d8..72bffae 100644 --- a/src/components/wiznews/NewsLoader.tsx +++ b/src/components/wiznews/NewsLoader.tsx @@ -15,7 +15,6 @@ export default function NewsLoader() { fetchNews(idRef.current++).then((res) => { setNewsList(res); }); - console.log(idRef.current, ':idRef'); setTimeout(() => { setLoading(false); }, 300); From 5d3daae16d7e71f7f3f040a5db5a1ed6401be305 Mon Sep 17 00:00:00 2001 From: yheseul Date: Sat, 27 Jul 2024 21:54:10 +0900 Subject: [PATCH 10/52] =?UTF-8?q?=F0=9F=94=A7=20Modify:=20=EC=BA=A1?= =?UTF-8?q?=EC=B3=90=20=EB=A1=9C=EC=A7=81=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/captureResult.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/utils/captureResult.ts diff --git a/src/utils/captureResult.ts b/src/utils/captureResult.ts new file mode 100644 index 0000000..592fcfe --- /dev/null +++ b/src/utils/captureResult.ts @@ -0,0 +1,25 @@ +import { useCallback, RefObject } from 'react'; +import { toPng } from 'html-to-image'; + +const captureResult = (ref: RefObject) => { + const handleCapture = useCallback(() => { + if (ref.current === null) { + return; + } + + toPng(ref.current, { cacheBust: true }) + .then((dataUrl) => { + const link = document.createElement('a'); + link.download = 'vicddory.png'; + link.href = dataUrl; + link.click(); + }) + .catch((err) => { + console.error('Failed to download image', err); + }); + }, [ref]); + + return handleCapture; +}; + +export default captureResult; From f11838a6bfb800826b008cab31f216e28ebf26c6 Mon Sep 17 00:00:00 2001 From: yheseul Date: Sat, 27 Jul 2024 21:56:58 +0900 Subject: [PATCH 11/52] =?UTF-8?q?=F0=9F=9A=9A=20Chore:=20=EB=A6=AC?= =?UTF-8?q?=EC=95=A1=ED=8A=B8=20=EC=95=84=EC=9D=B4=EC=BD=98=20=EB=9D=BC?= =?UTF-8?q?=EC=9D=B4=EB=B8=8C=EB=9F=AC=EB=A6=AC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 9 --------- package.json | 1 - 2 files changed, 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 803dfe0..38ca95f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,6 @@ "react": "^18", "react-datepicker": "^7.3.0", "react-dom": "^18", - "react-icons": "^5.2.1", "react-intersection-observer": "^9.13.0", "zustand": "^4.5.4" }, @@ -5838,14 +5837,6 @@ "react": "^18.3.1" } }, - "node_modules/react-icons": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.2.1.tgz", - "integrity": "sha512-zdbW5GstTzXaVKvGSyTaBalt7HSfuK5ovrzlpyiWHAFXndXTdd/1hdDHI4xBM1Mn7YriT6aqESucFl9kEXzrdw==", - "peerDependencies": { - "react": "*" - } - }, "node_modules/react-intersection-observer": { "version": "9.13.0", "resolved": "https://registry.npmjs.org/react-intersection-observer/-/react-intersection-observer-9.13.0.tgz", diff --git a/package.json b/package.json index 4ab35ac..a9e9eb1 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,6 @@ "react": "^18", "react-datepicker": "^7.3.0", "react-dom": "^18", - "react-icons": "^5.2.1", "react-intersection-observer": "^9.13.0", "zustand": "^4.5.4" }, From 990d9cd1c30a10d6258a744c4e0c8a67909b2ce4 Mon Sep 17 00:00:00 2001 From: yheseul Date: Sat, 27 Jul 2024 21:57:52 +0900 Subject: [PATCH 12/52] =?UTF-8?q?=F0=9F=92=84=20Design:=20=EC=95=84?= =?UTF-8?q?=EC=9D=B4=EC=BD=98=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/svgs/test/result/capture.svg | 1 + public/svgs/test/result/urlCopy.svg | 1 + src/components/test/result/TestShare.tsx | 19 ++++++++++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 public/svgs/test/result/capture.svg create mode 100644 public/svgs/test/result/urlCopy.svg diff --git a/public/svgs/test/result/capture.svg b/public/svgs/test/result/capture.svg new file mode 100644 index 0000000..0b7e577 --- /dev/null +++ b/public/svgs/test/result/capture.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/svgs/test/result/urlCopy.svg b/public/svgs/test/result/urlCopy.svg new file mode 100644 index 0000000..ab9054e --- /dev/null +++ b/public/svgs/test/result/urlCopy.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/test/result/TestShare.tsx b/src/components/test/result/TestShare.tsx index 7cc64e9..91d21cd 100644 --- a/src/components/test/result/TestShare.tsx +++ b/src/components/test/result/TestShare.tsx @@ -1,11 +1,10 @@ import KakaoShare from './KakaoShare'; -import { PiPaperclipLight } from 'react-icons/pi'; import UrlCopy from './UrlCopy'; import React from 'react'; -import { CiCamera } from 'react-icons/ci'; +import Image from 'next/image'; type TTestShareProps = { - onClick(): void; + onClick: () => void; }; export default function TestShare({ onClick }: TTestShareProps) { @@ -17,13 +16,23 @@ export default function TestShare({ onClick }: TTestShareProps) { onClick={UrlCopy} className="flex justify-center items-center border border-black rounded-full w-14 h-14 text-4xl bg-white hover:bg-gray-100 hover:border-0" > - + urlCopy
From bdfdc0f5f1b9ad63fda13603e607d185ed9b6ef8 Mon Sep 17 00:00:00 2001 From: yheseul Date: Sat, 27 Jul 2024 22:00:38 +0900 Subject: [PATCH 13/52] =?UTF-8?q?=F0=9F=A4=96=20Refactor:=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(test)/test/result/page.tsx | 36 +++++++++-------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/src/app/(test)/test/result/page.tsx b/src/app/(test)/test/result/page.tsx index 7ea79f5..90ffcbb 100644 --- a/src/app/(test)/test/result/page.tsx +++ b/src/app/(test)/test/result/page.tsx @@ -1,35 +1,20 @@ 'use client'; -import Button from '@/components/test/Button'; import CaptureArea from '@/components/test/result/CaptureArea'; -import { toPng } from 'html-to-image'; -import ResultPosition from '@/components/test/result/ResultPosition'; -import TestShare from '@/components/test/result/TestShare'; -import React, { useEffect, useState, useCallback, useRef } from 'react'; +import { useRef, useEffect, useState } from 'react'; import positionDetails from '@/data/positionDetails'; import { TPositionStatisticProps } from '@/types'; +import captureResult from '@/utils/captureResult'; +import dynamic from 'next/dynamic'; + +const Button = dynamic(() => import('@/components/test/Button'), { ssr: false }); +const ResultPosition = dynamic(() => import('@/components/test/result/ResultPosition'), { ssr: false }); +const TestShare = dynamic(() => import('@/components/test/result/TestShare'), { ssr: false }); const Page: React.FC = () => { const ref = useRef(null); - - const onButtonClick = useCallback(() => { - if (ref.current === null) { - return; - } - - toPng(ref.current, { cacheBust: true }) - .then((dataUrl) => { - const link = document.createElement('a'); - link.download = 'vicddory.png'; - link.href = dataUrl; - link.click(); - }) - .catch((err) => { - console.log(err); - }); - }, [ref]); - const [statistics, setStatistics] = useState([]); + const handleCapture = captureResult(ref); useEffect(() => { const fetchStatistics = async () => { @@ -47,6 +32,7 @@ const Page: React.FC = () => { }; fetchStatistics(); + sessionStorage.removeItem('testResult'); }, []); return ( @@ -78,7 +64,7 @@ const Page: React.FC = () => { 테스트 공유하기
- +
- + menu
From c9c02e722779300df1878f27176d4b5e35d19686 Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sat, 27 Jul 2024 22:16:17 +0900 Subject: [PATCH 15/52] =?UTF-8?q?=F0=9F=92=84=20Design:=20=EB=AA=A8?= =?UTF-8?q?=EB=B0=94=EC=9D=BC=20=EB=A9=94=EB=89=B4=EC=9D=98=20=EB=8B=AB?= =?UTF-8?q?=EA=B8=B0=20=EB=B2=84=ED=8A=BC=EC=9D=84=20react-icons=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EB=A1=9C=EC=BB=AC=20=ED=8C=8C=EC=9D=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/images/mobileHeader/close.svg | 1 + src/components/mobile/MobileMenu.tsx | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 public/images/mobileHeader/close.svg diff --git a/public/images/mobileHeader/close.svg b/public/images/mobileHeader/close.svg new file mode 100644 index 0000000..d7c1edc --- /dev/null +++ b/public/images/mobileHeader/close.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/mobile/MobileMenu.tsx b/src/components/mobile/MobileMenu.tsx index 96e32c4..0dd6a7e 100644 --- a/src/components/mobile/MobileMenu.tsx +++ b/src/components/mobile/MobileMenu.tsx @@ -1,7 +1,7 @@ 'use client'; +import Image from 'next/image'; import MobileMenuBtn from './MobileMenuBtn'; -import { IoCloseOutline } from 'react-icons/io5'; type handleMobileType = { handleMobileOpen: () => void; @@ -76,9 +76,12 @@ export default function MobileMenu({ onClick={handleMobileOpen} className={`absolute top-0 right-0 transition-opacity duration-300 ${isAnimated ? 'opacity-100' : 'opacity-0'}`} > -
From c4beb4e80fd6b6d0c34bdcc3021fd07708d08f76 Mon Sep 17 00:00:00 2001 From: SNXWXH Date: Sun, 28 Jul 2024 00:27:18 +0900 Subject: [PATCH 16/52] =?UTF-8?q?=F0=9F=90=9B=20Fix:=20build=20=EC=8B=9C?= =?UTF-8?q?=20=EC=98=A4=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit location undefined 오류를 useEffect 적용하여 해결 --- src/app/(main)/player/batter/page.tsx | 6 +++++- src/app/(main)/player/page.tsx | 6 +++++- src/app/(main)/ranking/page.tsx | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/app/(main)/player/batter/page.tsx b/src/app/(main)/player/batter/page.tsx index a17076a..4b65c07 100644 --- a/src/app/(main)/player/batter/page.tsx +++ b/src/app/(main)/player/batter/page.tsx @@ -1,8 +1,12 @@ 'use client'; import { useRouter } from 'next/navigation'; +import { useEffect } from 'react'; export default function BatterMain() { const router = useRouter(); - router.replace('/player/batter/catcher'); + + useEffect(() => { + router.replace('/player/batter/catcher'); + }, []); return null; } diff --git a/src/app/(main)/player/page.tsx b/src/app/(main)/player/page.tsx index 3b2673c..588b6c0 100644 --- a/src/app/(main)/player/page.tsx +++ b/src/app/(main)/player/page.tsx @@ -1,9 +1,13 @@ 'use client'; import { useRouter } from 'next/navigation'; +import { useEffect } from 'react'; export default function PlayerMain() { const router = useRouter(); - router.replace('/player/pitcher'); + + useEffect(() => { + router.replace('/player/pitcher'); + }, []); return null; } diff --git a/src/app/(main)/ranking/page.tsx b/src/app/(main)/ranking/page.tsx index 0f03d9c..7331c9e 100644 --- a/src/app/(main)/ranking/page.tsx +++ b/src/app/(main)/ranking/page.tsx @@ -1,9 +1,13 @@ 'use client'; import { useRouter } from 'next/navigation'; +import { useEffect } from 'react'; export default function RankingMain() { const router = useRouter(); - router.replace('/ranking/ai'); + useEffect(() => { + router.replace('/ranking/ai'); + }, []); + return null; } From 9a48e78ea897a5f2df0aadeb2348f554a7a0d29d Mon Sep 17 00:00:00 2001 From: SNXWXH Date: Sun, 28 Jul 2024 00:45:18 +0900 Subject: [PATCH 17/52] =?UTF-8?q?=F0=9F=A4=96=20Refactor:=20error.tsx=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EC=97=90=EB=9F=AC=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(main)/@modal/(.)testModal/page.tsx | 74 +++++++++---------- .../questions/[questionId]/page.tsx | 9 +-- src/app/(main)/error.tsx | 30 ++++++++ src/app/(test)/error.tsx | 30 ++++++++ .../test/questions/[questionId]/page.tsx | 8 +- src/app/(test)/test/result/page.tsx | 4 +- src/app/api/ainews/route.ts | 6 +- src/app/api/detailednews/route.ts | 6 +- src/app/api/news/route.ts | 6 +- src/app/api/playerPredict/route.ts | 9 +-- src/app/api/positionStatistics/route.ts | 5 +- src/app/api/predict/route.ts | 6 +- src/app/api/predictStats/route.ts | 6 +- src/app/api/questions/route.ts | 5 +- src/app/api/startingPitcher/route.ts | 6 +- src/app/api/testResult/route.ts | 12 +-- src/app/api/todayGame/route.ts | 6 +- src/components/wiznews/NewsArea.tsx | 3 +- src/components/wiznews/NewsLoader.tsx | 1 - src/components/wiznews/NewsTTS.tsx | 2 +- 20 files changed, 130 insertions(+), 104 deletions(-) create mode 100644 src/app/(main)/error.tsx create mode 100644 src/app/(test)/error.tsx diff --git a/src/app/(main)/@modal/(.)testModal/page.tsx b/src/app/(main)/@modal/(.)testModal/page.tsx index a347b59..7ec57fa 100644 --- a/src/app/(main)/@modal/(.)testModal/page.tsx +++ b/src/app/(main)/@modal/(.)testModal/page.tsx @@ -7,46 +7,46 @@ export default function Modal() { <>
-
-
- 야구 입문자를 위한 +
+
+ 야구 입문자를 위한 +
+ watermark +
+ 궁합테스트 +
+
+ 나와 어울리는 KT Wiz 선수 알아보기! +
+ emblem +
- watermark -
- 궁합테스트 -
-
- 나와 어울리는 KT Wiz 선수 알아보기! -
- emblem - -
-
-
- kt wiz는 2013년, 제 10구단에 대한 국민들의 강한 열망, -
경기도 및 수원시 그리고 KT그룹의 뜨거운 유치 열정으로 -
비상한 솜씨와 비범한 재능을 가진 마법사, -
- wiz라는 이름으로 신비롭고 강력한 힘으로 상상의 야구를 -
실현하겠다는 의지를 가지고 새롭게 출범하였습니다. +
+
+ kt wiz는 2013년, 제 10구단에 대한 국민들의 강한 열망, +
경기도 및 수원시 그리고 KT그룹의 뜨거운 유치 열정으로 +
비상한 솜씨와 비범한 재능을 가진 마법사, +
+ wiz라는 이름으로 신비롭고 강력한 힘으로 상상의 야구를 +
실현하겠다는 의지를 가지고 새롭게 출범하였습니다. +
-
- + ); } diff --git a/src/app/(main)/@questions/(.)testModal/questions/[questionId]/page.tsx b/src/app/(main)/@questions/(.)testModal/questions/[questionId]/page.tsx index 99b869a..ff35070 100644 --- a/src/app/(main)/@questions/(.)testModal/questions/[questionId]/page.tsx +++ b/src/app/(main)/@questions/(.)testModal/questions/[questionId]/page.tsx @@ -34,11 +34,11 @@ export default function Questions({ params }: TQuestionsProps) { setQuestions(data); sessionStorage.setItem('questions', JSON.stringify(data)); } else { - console.error('Failed to fetch questions'); + throw new Error('Server-Failed to fetch question Data'); } } } catch (error) { - console.error('Failed to fetch questions', error); + throw new Error('Server-Failed to fetch question Data'); } setLoading(false); }; @@ -83,11 +83,10 @@ export default function Questions({ params }: TQuestionsProps) { router.push('/testModal/result'); } else { const errorText = await response.text(); - console.error('Failed to fetch test result:', errorText); + throw new Error(errorText); } } catch (error) { - 2; - console.error('Failed to fetch test result:', error); + throw new Error('Server-Failed to fetch testResult Data'); } sessionStorage.removeItem('questions'); sessionStorage.removeItem('positionArr'); diff --git a/src/app/(main)/error.tsx b/src/app/(main)/error.tsx new file mode 100644 index 0000000..28c80b2 --- /dev/null +++ b/src/app/(main)/error.tsx @@ -0,0 +1,30 @@ +'use client'; // Error components must be Client Components + +import { useEffect } from 'react'; + +export default function Error({ + error, + reset, +}: { + error: Error & { digest?: string }; + reset: () => void; +}) { + useEffect(() => { + // Log the error to an error reporting service + console.error(error); + }, [error]); + + return ( +
+

Something went wrong!

+ +
+ ); +} diff --git a/src/app/(test)/error.tsx b/src/app/(test)/error.tsx new file mode 100644 index 0000000..28c80b2 --- /dev/null +++ b/src/app/(test)/error.tsx @@ -0,0 +1,30 @@ +'use client'; // Error components must be Client Components + +import { useEffect } from 'react'; + +export default function Error({ + error, + reset, +}: { + error: Error & { digest?: string }; + reset: () => void; +}) { + useEffect(() => { + // Log the error to an error reporting service + console.error(error); + }, [error]); + + return ( +
+

Something went wrong!

+ +
+ ); +} diff --git a/src/app/(test)/test/questions/[questionId]/page.tsx b/src/app/(test)/test/questions/[questionId]/page.tsx index 75b1dba..bcf07e1 100644 --- a/src/app/(test)/test/questions/[questionId]/page.tsx +++ b/src/app/(test)/test/questions/[questionId]/page.tsx @@ -33,11 +33,11 @@ export default function Questions({ params }: TQuestionsProps) { setQuestions(data); sessionStorage.setItem('questions', JSON.stringify(data)); } else { - console.error('Failed to fetch questions'); + throw new Error('Server-Failed to fetch question Data'); } } } catch (error) { - console.error('Failed to fetch questions', error); + throw new Error('Server-Failed to fetch question Data'); } setLoading(false); }; @@ -78,10 +78,10 @@ export default function Questions({ params }: TQuestionsProps) { router.push('/test/result'); } else { const errorText = await response.text(); - console.error('Failed to fetch test result:', errorText); + throw new Error(errorText); } } catch (error) { - console.error('Failed to fetch test result:', error); + throw new Error('Server-Failed to fetch testResult Data'); } sessionStorage.removeItem('questions'); sessionStorage.removeItem('positionArr'); diff --git a/src/app/(test)/test/result/page.tsx b/src/app/(test)/test/result/page.tsx index 7ea79f5..3fabbd2 100644 --- a/src/app/(test)/test/result/page.tsx +++ b/src/app/(test)/test/result/page.tsx @@ -39,10 +39,10 @@ const Page: React.FC = () => { const data: TPositionStatisticProps[] = await response.json(); setStatistics(data); } else { - console.error('Failed to fetch position statistics'); + throw new Error('Server-Failed to fetch positionStatistics Data'); } } catch (error) { - console.error('Failed to fetch position statistics', error); + throw new Error('Server-Failed to fetch positionStatistics Data'); } }; diff --git a/src/app/api/ainews/route.ts b/src/app/api/ainews/route.ts index 3e39ad7..49bbf20 100644 --- a/src/app/api/ainews/route.ts +++ b/src/app/api/ainews/route.ts @@ -11,12 +11,10 @@ export async function GET(req: NextRequest) { headers: { 'Content-Type': 'application/json' }, }, ); + const aiNews = await response.json(); return NextResponse.json(aiNews, { status: 200 }); } catch (error) { - return NextResponse.json( - { error: 'Failed to fetch AI news' }, - { status: 500 }, - ); + throw new Error('Server-Failed to fetch aiNews Data'); } } diff --git a/src/app/api/detailednews/route.ts b/src/app/api/detailednews/route.ts index 865496f..dd53f5e 100644 --- a/src/app/api/detailednews/route.ts +++ b/src/app/api/detailednews/route.ts @@ -11,12 +11,10 @@ export async function GET(req: NextRequest) { headers: { 'Content-Type': 'application/json' }, }, ); + const detailedNews = await response.json(); return NextResponse.json(detailedNews.data.article, { status: 200 }); } catch (error) { - return NextResponse.json( - { error: 'Failed to fetch news' }, - { status: 500 }, - ); + throw new Error('Server-Failed to fetch detailedNews Data'); } } diff --git a/src/app/api/news/route.ts b/src/app/api/news/route.ts index 4890dd1..e964ae7 100644 --- a/src/app/api/news/route.ts +++ b/src/app/api/news/route.ts @@ -13,12 +13,10 @@ export async function GET(req: NextRequest) { headers: { 'Content-Type': 'application/json' }, }, ); + const news = await response.json(); return NextResponse.json(news.data.list, { status: 200 }); } catch (error) { - return NextResponse.json( - { error: 'Failed to fetch news' }, - { status: 500 }, - ); + throw new Error('Server-Failed to fetch News Data'); } } diff --git a/src/app/api/playerPredict/route.ts b/src/app/api/playerPredict/route.ts index 8121cd8..ef86bd6 100644 --- a/src/app/api/playerPredict/route.ts +++ b/src/app/api/playerPredict/route.ts @@ -15,15 +15,10 @@ export async function POST(req: NextRequest) { }), }, ); - if (!response.ok) { - throw new Error('Server-Failed to fetch player data'); - } + const expectedMetric = await response.json(); return NextResponse.json(expectedMetric, { status: 200 }); } catch (error) { - return NextResponse.json( - { error: 'Server-Failed to fetch player stats' }, - { status: 500 }, - ); + throw new Error('Server-Failed to fetch playerPredict Data'); } } diff --git a/src/app/api/positionStatistics/route.ts b/src/app/api/positionStatistics/route.ts index 2b044d6..3c8d47f 100644 --- a/src/app/api/positionStatistics/route.ts +++ b/src/app/api/positionStatistics/route.ts @@ -24,9 +24,6 @@ export async function GET() { return NextResponse.json(statistics); } catch (error) { - return NextResponse.json( - { error: 'Failed to fetch position statistics' }, - { status: 500 }, - ); + throw new Error('Server-Failed to fetch positionStatistics Data'); } } diff --git a/src/app/api/predict/route.ts b/src/app/api/predict/route.ts index 84101b1..e02353d 100644 --- a/src/app/api/predict/route.ts +++ b/src/app/api/predict/route.ts @@ -24,12 +24,10 @@ export async function GET(req: NextRequest) { }, }), }); + const data = await response.json(); return NextResponse.json(data.predictWinRate, { status: 200 }); } catch (error) { - return NextResponse.json( - { error: 'Failed at /api/predict' }, - { status: 500 }, - ); + throw new Error('Server-Failed to fetch predict Data'); } } diff --git a/src/app/api/predictStats/route.ts b/src/app/api/predictStats/route.ts index b9856d5..5c23817 100644 --- a/src/app/api/predictStats/route.ts +++ b/src/app/api/predictStats/route.ts @@ -17,12 +17,10 @@ export async function GET(req: NextRequest) { }), }, ); + const data = await response.json(); return NextResponse.json(data, { status: 200 }); } catch (error) { - return NextResponse.json( - { error: 'Failed at /api/predictStats' }, - { status: 500 }, - ); + throw new Error('Server-Failed to fetch predictStats Data'); } } diff --git a/src/app/api/questions/route.ts b/src/app/api/questions/route.ts index 361f075..c87f3ff 100644 --- a/src/app/api/questions/route.ts +++ b/src/app/api/questions/route.ts @@ -1,12 +1,13 @@ -import { NextRequest, NextResponse } from 'next/server'; +import { NextResponse } from 'next/server'; import { TQuestionHandlerProps } from '@/types'; -export async function GET(req: NextRequest) { +export async function GET() { try { const response = await fetch(`${process.env.API_URL}/generate_questions`, { method: 'POST', cache: 'no-store', }); + const questions: TQuestionHandlerProps[] = await response.json(); return NextResponse.json(questions, { status: 200 }); } catch (error) { diff --git a/src/app/api/startingPitcher/route.ts b/src/app/api/startingPitcher/route.ts index 515772a..6f4e6dc 100644 --- a/src/app/api/startingPitcher/route.ts +++ b/src/app/api/startingPitcher/route.ts @@ -10,12 +10,10 @@ export async function GET(req: NextRequest) { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ day_num }), }); + const data = await response.json(); return NextResponse.json(data, { status: 200 }); } catch (error) { - return NextResponse.json( - { error: 'Failed at /api/startingPitcher' }, - { status: 500 }, - ); + throw new Error('Server-Failed to fetch starting Data'); } } diff --git a/src/app/api/testResult/route.ts b/src/app/api/testResult/route.ts index 48ce92d..3ba45c9 100644 --- a/src/app/api/testResult/route.ts +++ b/src/app/api/testResult/route.ts @@ -19,21 +19,11 @@ export async function GET(req: NextRequest) { body: JSON.stringify({ positions: arr }), }); - if (!response.ok) { - return NextResponse.json( - { error: 'Failed to fetch evaluation result' }, - { status: response.status }, - ); - } - const result = await response.json(); await collection.insertOne(result); return NextResponse.json(result, { status: 200 }); } catch (error) { - return NextResponse.json( - { error: 'Failed to save result' }, - { status: 500 }, - ); + throw new Error('Server-Failed to fetch testResult Data'); } } diff --git a/src/app/api/todayGame/route.ts b/src/app/api/todayGame/route.ts index ffef741..fc5260c 100644 --- a/src/app/api/todayGame/route.ts +++ b/src/app/api/todayGame/route.ts @@ -10,12 +10,10 @@ export async function GET(req: NextRequest) { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ yearmonth }), }); + const data = await response.json(); return NextResponse.json(data.data, { status: 200 }); } catch (error) { - return NextResponse.json( - { error: 'Failed at /api/todayGame' }, - { status: 500 }, - ); + throw new Error('Server-Failed to fetch todayGame Data'); } } diff --git a/src/components/wiznews/NewsArea.tsx b/src/components/wiznews/NewsArea.tsx index 81ebbe3..53b9f83 100644 --- a/src/components/wiznews/NewsArea.tsx +++ b/src/components/wiznews/NewsArea.tsx @@ -46,10 +46,9 @@ export default function NewsArea() { const getNews = async () => { try { const result = await fetchNews(1); - console.log(result, '리절트 뭐야'); setNewsList(result); } catch (e) { - console.log('Error:', e); + throw new Error('Server-Failed to fetch fetchNews Data'); } }; getNews(); diff --git a/src/components/wiznews/NewsLoader.tsx b/src/components/wiznews/NewsLoader.tsx index d5441d8..72bffae 100644 --- a/src/components/wiznews/NewsLoader.tsx +++ b/src/components/wiznews/NewsLoader.tsx @@ -15,7 +15,6 @@ export default function NewsLoader() { fetchNews(idRef.current++).then((res) => { setNewsList(res); }); - console.log(idRef.current, ':idRef'); setTimeout(() => { setLoading(false); }, 300); diff --git a/src/components/wiznews/NewsTTS.tsx b/src/components/wiznews/NewsTTS.tsx index 49df528..54063b5 100644 --- a/src/components/wiznews/NewsTTS.tsx +++ b/src/components/wiznews/NewsTTS.tsx @@ -20,7 +20,7 @@ export default function NewsTTS({ text }: { text: string | undefined | null }) { const audioUrl = URL.createObjectURL(audioBlob); setAudioUrl(audioUrl); } catch (e) { - console.log('Error:', e); + throw new Error('Server-Failed to fetch tts Data'); } finally { setLoading(false); } From 95a53b92d9b261105c56ab17c2ac7e202d43541f Mon Sep 17 00:00:00 2001 From: SNXWXH Date: Sun, 28 Jul 2024 00:50:22 +0900 Subject: [PATCH 18/52] =?UTF-8?q?=F0=9F=A4=96=20Refactor:=20error=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(test)/test/result/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/(test)/test/result/page.tsx b/src/app/(test)/test/result/page.tsx index 3fabbd2..39820c2 100644 --- a/src/app/(test)/test/result/page.tsx +++ b/src/app/(test)/test/result/page.tsx @@ -25,7 +25,7 @@ const Page: React.FC = () => { link.click(); }) .catch((err) => { - console.log(err); + throw new Error(err); }); }, [ref]); From 249e512f03220de36825ee25ed7821ee5519dc30 Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sun, 28 Jul 2024 09:53:25 +0900 Subject: [PATCH 19/52] =?UTF-8?q?=F0=9F=94=A7=20Modify:=20svg=20=EB=AA=A8?= =?UTF-8?q?=EB=B0=94=EC=9D=BC=20=ED=97=A4=EB=8D=94=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20svg=20=ED=8F=B4=EB=8D=94=EB=A1=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/{images => svgs}/mobileHeader/close.svg | 0 public/{images => svgs}/mobileHeader/hamburger.svg | 0 public/{images => svgs}/mobileHeader/ticket.svg | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename public/{images => svgs}/mobileHeader/close.svg (100%) rename public/{images => svgs}/mobileHeader/hamburger.svg (100%) rename public/{images => svgs}/mobileHeader/ticket.svg (100%) diff --git a/public/images/mobileHeader/close.svg b/public/svgs/mobileHeader/close.svg similarity index 100% rename from public/images/mobileHeader/close.svg rename to public/svgs/mobileHeader/close.svg diff --git a/public/images/mobileHeader/hamburger.svg b/public/svgs/mobileHeader/hamburger.svg similarity index 100% rename from public/images/mobileHeader/hamburger.svg rename to public/svgs/mobileHeader/hamburger.svg diff --git a/public/images/mobileHeader/ticket.svg b/public/svgs/mobileHeader/ticket.svg similarity index 100% rename from public/images/mobileHeader/ticket.svg rename to public/svgs/mobileHeader/ticket.svg From 46def4a78b61b7126f96e6038499a21feb0a10e2 Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sun, 28 Jul 2024 09:54:15 +0900 Subject: [PATCH 20/52] =?UTF-8?q?=F0=9F=94=A7=20Modify:=20svg=20=EB=AA=A8?= =?UTF-8?q?=EB=B0=94=EC=9D=BC=20=ED=97=A4=EB=8D=94=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20svg=20=ED=8F=B4=EB=8D=94=EB=A1=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Header.tsx | 4 ++-- src/components/mobile/MobileMenu.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 5f682aa..3d9d914 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -55,7 +55,7 @@ export default function Header() { onClick={handleMobileOpen} > menu menu close_btn Date: Sun, 28 Jul 2024 09:55:19 +0900 Subject: [PATCH 21/52] =?UTF-8?q?=F0=9F=94=A7=20Modify:=20=EB=A7=88?= =?UTF-8?q?=EC=8A=A4=EC=BD=94=ED=8A=B8=20svg=20wiznews=20=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20=EB=82=B4=EB=B6=80=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/svgs/{ => wiznews}/newsMascot/ddory.svg | 0 public/svgs/{ => wiznews}/newsMascot/vic.svg | 0 src/app/(main)/wiznews/page.tsx | 6 +++--- 3 files changed, 3 insertions(+), 3 deletions(-) rename public/svgs/{ => wiznews}/newsMascot/ddory.svg (100%) rename public/svgs/{ => wiznews}/newsMascot/vic.svg (100%) diff --git a/public/svgs/newsMascot/ddory.svg b/public/svgs/wiznews/newsMascot/ddory.svg similarity index 100% rename from public/svgs/newsMascot/ddory.svg rename to public/svgs/wiznews/newsMascot/ddory.svg diff --git a/public/svgs/newsMascot/vic.svg b/public/svgs/wiznews/newsMascot/vic.svg similarity index 100% rename from public/svgs/newsMascot/vic.svg rename to public/svgs/wiznews/newsMascot/vic.svg diff --git a/src/app/(main)/wiznews/page.tsx b/src/app/(main)/wiznews/page.tsx index d475f7d..57615d1 100644 --- a/src/app/(main)/wiznews/page.tsx +++ b/src/app/(main)/wiznews/page.tsx @@ -5,9 +5,9 @@ import NewsGenerate from '@/components/wiznews/NewsGenerate'; export default function WizNews() { return ( <> -
- - +
+ +
From 7e6f1daf012f437c1c838215e0c3a869cd0e4652 Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sun, 28 Jul 2024 09:56:12 +0900 Subject: [PATCH 22/52] =?UTF-8?q?=F0=9F=92=84=20Design:=20url=20=EA=B3=B5?= =?UTF-8?q?=EC=9C=A0=EC=9A=A9=20=EB=89=B4=EC=8A=A4=20=EC=83=81=EC=84=B8=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=EC=97=90=EB=8F=84=20=EB=A7=88?= =?UTF-8?q?=EC=8A=A4=EC=BD=94=ED=8A=B8=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(main)/wiznews/[newsId]/page.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/(main)/wiznews/[newsId]/page.tsx b/src/app/(main)/wiznews/[newsId]/page.tsx index ec2fd0b..6519494 100644 --- a/src/app/(main)/wiznews/[newsId]/page.tsx +++ b/src/app/(main)/wiznews/[newsId]/page.tsx @@ -1,12 +1,19 @@ import NewsContent from '@/components/wiznews/NewsContent'; import { TParams } from '../@news/(.)[newsId]/page'; +import Mascot from '@/components/wiznews/Mascot'; export default function WizNewsDetail({ params }: TParams) { const newsId = params.newsId; return ( <> -
- +
+ + +
+
+ +
+
); From 3047411dc1c7022c3988765472d3b48cbfda46c7 Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sun, 28 Jul 2024 09:56:42 +0900 Subject: [PATCH 23/52] =?UTF-8?q?=F0=9F=94=A7=20Modify:=20tts=20svg=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/svgs/wiznews/tts.svg | 1 + 1 file changed, 1 insertion(+) create mode 100644 public/svgs/wiznews/tts.svg diff --git a/public/svgs/wiznews/tts.svg b/public/svgs/wiznews/tts.svg new file mode 100644 index 0000000..b67d4f8 --- /dev/null +++ b/public/svgs/wiznews/tts.svg @@ -0,0 +1 @@ + \ No newline at end of file From a3719094e469f61f4c9514db15876f4afc093cb5 Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sun, 28 Jul 2024 11:39:37 +0900 Subject: [PATCH 24/52] =?UTF-8?q?=F0=9F=A4=96=20Refactor:=20=EB=89=B4?= =?UTF-8?q?=EC=8A=A4=20=EA=B4=80=EB=A0=A8=20=ED=83=80=EC=9E=85=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC,=20NewsContent=20=ED=83=80=EC=9E=85=EC=97=90=20regDtt?= =?UTF-8?q?m=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/wiznews/NewsArea.tsx | 14 ++------------ src/types/index.d.ts | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/components/wiznews/NewsArea.tsx b/src/components/wiznews/NewsArea.tsx index 465e939..159309f 100644 --- a/src/components/wiznews/NewsArea.tsx +++ b/src/components/wiznews/NewsArea.tsx @@ -4,16 +4,7 @@ import { create } from 'zustand'; import NewsBalloon from './NewsBalloon'; import { useEffect } from 'react'; import NewsLoader from './NewsLoader'; - -export type TNewsContent = { - artcContents: string; - artcTitle: string; - artcSeq: number; - imgFilePath?: string; - [key: string]: any; -} | null; - -export type TNewsList = TNewsContent[]; +import { TNewsList } from '@/types'; type NewsListStore = { newsList: TNewsList; @@ -23,7 +14,7 @@ type NewsListStore = { export const useNewsListStore = create()((set) => ({ newsList: [], setNewsList: (news) => { - if (news[0] && news[0].imgFilePath === undefined) { + if (news[0]?.imgFilePath === undefined) { // news null 체크, imgFilePath가 없으면 === aiNews이면 set((state) => ({ newsList: [...news, ...state.newsList] })); } else { @@ -46,7 +37,6 @@ export default function NewsArea() { const getNews = async () => { try { const result = await fetchNews(1); - console.log(result, '리절트 뭐야'); setNewsList(result); } catch (e) { console.log('Error:', e); diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 6db73d9..9dbd0a4 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -272,6 +272,19 @@ type TBaseSeries = { visible: boolean; }; +// Wiznews + +type TNewsContent = { + artcContents: string; + artcTitle: string; + artcSeq: number; + regDttm: number; + imgFilePath?: string; + [key: string]: any; +} | null; + +type TNewsList = TNewsContent[]; + export { TResultPositionProps, TQuestionHandlerProps, @@ -304,4 +317,6 @@ export { TLeagueYearData, TLeagueDailyData, TBaseSeries, + TNewsContent, + TNewsList, }; From 81f4cf0667e4cf76afc08586d793f363a65ccc7e Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sun, 28 Jul 2024 11:46:36 +0900 Subject: [PATCH 25/52] =?UTF-8?q?=E2=9C=A8=20Feat:=20=EB=89=B4=EC=8A=A4=20?= =?UTF-8?q?=EB=8F=99=EC=A0=81=20=EB=82=A0=EC=A7=9C=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 기존에 useEffect 2개 사용하던 것을 1개로 통합, Image 태그를 효과적으로 사용하기 위해 layout fill 사용. 뉴스 영역의 높이를 추가로 늘림. 가독성을 위해 foundNews로 이름 변경. --- src/components/wiznews/NewsContent.tsx | 70 ++++++++++++++------------ 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/src/components/wiznews/NewsContent.tsx b/src/components/wiznews/NewsContent.tsx index 172eaf7..b4f7dd1 100644 --- a/src/components/wiznews/NewsContent.tsx +++ b/src/components/wiznews/NewsContent.tsx @@ -1,24 +1,35 @@ 'use client'; import { useRouter } from 'next/navigation'; import { MouseEventHandler, useEffect, useState } from 'react'; -import Image from 'next/image'; -import { TNewsContent, useNewsListStore } from './NewsArea'; +import { useNewsListStore } from './NewsArea'; import dynamic from 'next/dynamic'; +import Image from 'next/image'; +import { TNewsContent } from '@/types'; type TNewsId = { newsId: string; }; export default function NewsContent({ newsId }: TNewsId) { - const [newsData, setNewsData] = useState(null); - const [theNews, setTheNews] = useState(null); + const [foundNews, setFoundNews] = useState(null); const newsList = useNewsListStore((state) => state.newsList); const router = useRouter(); const handleBacklink: MouseEventHandler = () => { router.back(); }; - let trimmedArtcContents = - theNews && theNews.artcContents.replace(/<[^>]*>/g, ''); + const trimmedArtcContents = + foundNews && foundNews.artcContents.replace(/<[^>]*>/g, ''); + + const newsDate = () => { + const date = foundNews && new Date(foundNews.regDttm); + if (date) { + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const day = String(date.getDate()).padStart(2, '0'); + const formattedDate = `${year}-${month}-${day}`; + return formattedDate; + } + }; const fetchDetailedNews = async () => { const detailedNews = await ( @@ -34,7 +45,7 @@ export default function NewsContent({ newsId }: TNewsId) { useEffect(() => { if (newsList.length) { - setNewsData( + setFoundNews( newsList.find( // news is possibly null, so added news && (news) => news && news.artcSeq === parseInt(newsId), @@ -42,22 +53,18 @@ export default function NewsContent({ newsId }: TNewsId) { ); } else { const getDetailedNews = async () => { - setNewsData(await fetchDetailedNews()); + setFoundNews(await fetchDetailedNews()); }; getDetailedNews(); } - }, [newsId, newsList]); - - useEffect(() => { - setTheNews(newsData); - }, [newsData]); + }, []); return ( <> - {theNews && ( -
-
-
+ {foundNews && ( +
+
+
-
-

- {theNews.artcTitle} -

-

- 2024-01-17 -

+
+

{foundNews.artcTitle}

+

{newsDate()}

-
- {theNews.imgFilePath && ( - news_image +
+ {foundNews.imgFilePath && ( +
+ news_image +
)}

{trimmedArtcContents} From de52ed7c07e303f28f4ae4baabb9bcdd87295752 Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sun, 28 Jul 2024 11:48:55 +0900 Subject: [PATCH 26/52] =?UTF-8?q?=E2=9C=A8=20Feat:=20ai=20=EB=89=B4?= =?UTF-8?q?=EC=8A=A4=EC=97=90=20=EA=B2=BD=EA=B8=B0=20=EB=82=A0=EC=A7=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/wiznews/NewsGenerate.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/wiznews/NewsGenerate.tsx b/src/components/wiznews/NewsGenerate.tsx index 48271c7..f81166a 100644 --- a/src/components/wiznews/NewsGenerate.tsx +++ b/src/components/wiznews/NewsGenerate.tsx @@ -2,10 +2,12 @@ import Image from 'next/image'; import { useState } from 'react'; import { useNewsListStore } from './NewsArea'; + export default function NewsGenerate() { const [date, setDate] = useState('2024-07-11'); const [loading, setLoading] = useState(false); const setNewsList = useNewsListStore((state) => state.setNewsList); + const fetchAiNews = async () => { setLoading(true); const aiNewsData = await ( @@ -18,6 +20,7 @@ export default function NewsGenerate() { artcContents: aiNewsData.content, artcTitle: aiNewsData.title, artcSeq: Date.now(), + regDttm: new Date(date).getTime(), }, ]; setNewsList(aiNews); From f0fd205d24d13a404cbd4855e44da6dd03eaf141 Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sun, 28 Jul 2024 11:54:05 +0900 Subject: [PATCH 27/52] =?UTF-8?q?=F0=9F=A4=96=20Refactor:=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20state=20=EC=82=AD=EC=A0=9C,=20?= =?UTF-8?q?=EB=A1=9C=EB=94=A9=20=EC=86=8D=EB=8F=84=20=EB=8A=90=EB=A6=AC?= =?UTF-8?q?=EA=B2=8C=20=ED=95=98=EB=8A=94=20react-icons=EB=A5=BC=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=EB=A1=9C=20=EB=8C=80=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/wiznews/NewsTTS.tsx | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/components/wiznews/NewsTTS.tsx b/src/components/wiznews/NewsTTS.tsx index 49df528..4e98f81 100644 --- a/src/components/wiznews/NewsTTS.tsx +++ b/src/components/wiznews/NewsTTS.tsx @@ -1,9 +1,8 @@ 'use client'; -import { PiUserSound } from 'react-icons/pi'; +import Image from 'next/image'; import { useEffect, useState } from 'react'; export default function NewsTTS({ text }: { text: string | undefined | null }) { - const [audioUrl, setAudioUrl] = useState(null); const [audio, setAudio] = useState(null); const [loading, setLoading] = useState(true); @@ -18,7 +17,7 @@ export default function NewsTTS({ text }: { text: string | undefined | null }) { }); const audioBlob = await response.blob(); const audioUrl = URL.createObjectURL(audioBlob); - setAudioUrl(audioUrl); + setAudio(new Audio(audioUrl)); } catch (e) { console.log('Error:', e); } finally { @@ -33,14 +32,10 @@ export default function NewsTTS({ text }: { text: string | undefined | null }) { audio.currentTime = 0; } }; - }, [audio, text]); + }, [text]); const handleAudioPlay = () => { - if (audioUrl) { - const newAudio = new Audio(audioUrl); - setAudio(newAudio); - newAudio.play(); - } + audio?.play(); }; if (loading) { @@ -52,14 +47,15 @@ export default function NewsTTS({ text }: { text: string | undefined | null }) { className="flex justify-center items-center text-[#ed2024]" onClick={handleAudioPlay} > - + tts_img

음성 뉴스 듣기

- {/* {audioUrl && ( - - )} */} ); } From fb682e302b1dd4aa5a64149988eae410f6b1668a Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sun, 28 Jul 2024 12:26:11 +0900 Subject: [PATCH 28/52] =?UTF-8?q?=F0=9F=94=A7=20Modify:=20=EB=AA=A8?= =?UTF-8?q?=EB=B0=94=EC=9D=BC=20=EB=A9=94=EB=89=B4=20=EB=B2=84=ED=8A=BC=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20svg=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/svgs/mobileHeader/down.svg | 1 + public/svgs/mobileHeader/up.svg | 1 + src/components/mobile/MobileMenuBtn.tsx | 17 +++++++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 public/svgs/mobileHeader/down.svg create mode 100644 public/svgs/mobileHeader/up.svg diff --git a/public/svgs/mobileHeader/down.svg b/public/svgs/mobileHeader/down.svg new file mode 100644 index 0000000..b705556 --- /dev/null +++ b/public/svgs/mobileHeader/down.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/svgs/mobileHeader/up.svg b/public/svgs/mobileHeader/up.svg new file mode 100644 index 0000000..153c51e --- /dev/null +++ b/public/svgs/mobileHeader/up.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/mobile/MobileMenuBtn.tsx b/src/components/mobile/MobileMenuBtn.tsx index 3c5f5bb..edec27f 100644 --- a/src/components/mobile/MobileMenuBtn.tsx +++ b/src/components/mobile/MobileMenuBtn.tsx @@ -1,5 +1,6 @@ 'use client'; +import Image from 'next/image'; import Link from 'next/link'; import { useState } from 'react'; import { FaChevronDown } from 'react-icons/fa'; @@ -32,9 +33,21 @@ export default function MobileMenuBtn({
From b8d7630030d9337847a42198b9536331e22bce28 Mon Sep 17 00:00:00 2001 From: yheseul Date: Sun, 28 Jul 2024 15:35:58 +0900 Subject: [PATCH 29/52] =?UTF-8?q?=F0=9F=90=9B=20Fix:=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/test/ModalWrapper.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/test/ModalWrapper.tsx b/src/components/test/ModalWrapper.tsx index c44fee6..51983ab 100644 --- a/src/components/test/ModalWrapper.tsx +++ b/src/components/test/ModalWrapper.tsx @@ -21,7 +21,7 @@ export default function ModalWrapper({ onClick={closeModal} className="fixed inset-0 bg-black bg-opacity-60 z-50 flex items-center justify-center" > - {React.cloneElement(children as React.ReactElement, { closeModal })} + {children}
); From 96abdbbce513adfc30f5ddcfe896e02f9116ffd5 Mon Sep 17 00:00:00 2001 From: yheseul Date: Sun, 28 Jul 2024 15:37:02 +0900 Subject: [PATCH 30/52] =?UTF-8?q?=F0=9F=A4=96=20Refactor:=20=EA=B2=B0?= =?UTF-8?q?=EA=B3=BC=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../@result/(.)testResultModal/page.tsx | 159 +++++++++--------- 1 file changed, 76 insertions(+), 83 deletions(-) diff --git a/src/app/(main)/@result/(.)testResultModal/page.tsx b/src/app/(main)/@result/(.)testResultModal/page.tsx index b6b51be..40723b7 100644 --- a/src/app/(main)/@result/(.)testResultModal/page.tsx +++ b/src/app/(main)/@result/(.)testResultModal/page.tsx @@ -1,90 +1,83 @@ -export default function page() { - return ( - <> -

개망

- - ); -} +'use client'; -// 'use client'; +import CaptureArea from '@/components/test/result/CaptureArea'; +import { useRef, useEffect, useState } from 'react'; +import positionDetails from '@/data/positionDetails'; +import { TPositionStatisticProps } from '@/types'; +import captureResult from '@/utils/captureResult'; +import dynamic from 'next/dynamic'; +import ModalWrapper from '@/components/test/ModalWrapper'; -// import Button from '@/components/test/Button'; -// import CaptureArea from '@/components/test/result/CaptureArea'; -// import { CaptureDownload } from '@/components/test/result/CaptureDownload'; -// import ResultPosition from '@/components/test/result/ResultPosition'; -// import TestShare from '@/components/test/result/TestShare'; -// import React, { useEffect, useRef, useState } from 'react'; -// import positionDetails from '@/data/positionDetails'; -// import { TPositionStatisticProps } from '@/types'; -// import ModalWrapper from '@/components/test/ModalWrapper'; +const Button = dynamic(() => import('@/components/test/Button'), { ssr: false }); +const ResultPosition = dynamic(() => import('@/components/test/result/ResultPosition'), { ssr: false }); +const TestShare = dynamic(() => import('@/components/test/result/TestShare'), { ssr: false }); -// export default function Page() { -// const divRef = useRef(null); -// const [statistics, setStatistics] = useState([]); +const Page: React.FC = () => { + const ref = useRef(null); + const [statistics, setStatistics] = useState([]); + const handleCapture = captureResult(ref); -// const handleCaptureClick = () => { -// CaptureDownload(divRef); -// alert('테스트 결과를 캡쳐합니다.'); -// }; + useEffect(() => { + const fetchStatistics = async () => { + try { + const response = await fetch('/api/positionStatistics'); + if (response.ok) { + const data: TPositionStatisticProps[] = await response.json(); + setStatistics(data); + } else { + console.error('Failed to fetch position statistics'); + } + } catch (error) { + console.error('Failed to fetch position statistics', error); + } + }; -// useEffect(() => { -// const fetchStatistics = async () => { -// try { -// const response = await fetch('/api/positionStatistics'); -// if (response.ok) { -// const data: TPositionStatisticProps[] = await response.json(); -// setStatistics(data); -// } else { -// console.error('Failed to fetch position statistics'); -// } -// } catch (error) { -// console.error('Failed to fetch position statistics', error); -// } -// }; + fetchStatistics(); + sessionStorage.removeItem('testResult'); + }, []); -// fetchStatistics(); -// }, []); + return ( + <> + +
e.stopPropagation()} className="bg-slate-100 h-full overflow-scroll no-scrollbar"> +
+ +
+
+ 가장 많은 포지션은 뭘까요? +
+ {statistics.map((stat, index) => { + const details = positionDetails[stat.position]; + return ( + + ); + })} +
+
+ +
+ 테스트 + 공유하기 +
+ +
+
+ +
+
+
+
+ + ); +}; -// return ( -// <> -// -//
-//
-// -//
-//
-// 가장 많은 포지션은 뭘까요? -//
-// {statistics.map((stat, index) => { -// const details = positionDetails[stat.position]; -// return ( -// -// ); -// })} -//
-//
-// -//
-// 테스트 -// 공유하기 -//
-// -//
-//
-// -//
-//
-//
-//
-// -// ); -// } +export default Page; \ No newline at end of file From 99cf79dd826f9e308f5438c941ee77541d8f56f5 Mon Sep 17 00:00:00 2001 From: yheseul Date: Sun, 28 Jul 2024 15:37:51 +0900 Subject: [PATCH 31/52] =?UTF-8?q?=F0=9F=A4=96=20Refactor:=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(main)/@modal/(.)testModal/page.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/(main)/@modal/(.)testModal/page.tsx b/src/app/(main)/@modal/(.)testModal/page.tsx index 9497d10..335a210 100644 --- a/src/app/(main)/@modal/(.)testModal/page.tsx +++ b/src/app/(main)/@modal/(.)testModal/page.tsx @@ -1,3 +1,5 @@ +'use client' + import Button from '@/components/test/Button'; import ModalWrapper from '@/components/test/ModalWrapper'; import Image from 'next/image'; @@ -6,7 +8,7 @@ export default function Modal() { return ( <> -
+
e.stopPropagation()} className="flex justify-center flex-col items-center h-dvh max-w-md m-auto">
야구 입문자를 위한 @@ -31,7 +33,7 @@ export default function Modal() { height={180} className="w-40 md:w-[200px] mb-4" /> -
From dcad7034523abb7943a9917d4e1fafa794cb817a Mon Sep 17 00:00:00 2001 From: yheseul Date: Sun, 28 Jul 2024 15:39:23 +0900 Subject: [PATCH 32/52] =?UTF-8?q?=F0=9F=92=84=20Design:=20=EC=95=84?= =?UTF-8?q?=EC=9D=B4=EC=BD=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(main)/@modal/default.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/(main)/@modal/default.tsx b/src/app/(main)/@modal/default.tsx index 2aacd05..c6fdf29 100644 --- a/src/app/(main)/@modal/default.tsx +++ b/src/app/(main)/@modal/default.tsx @@ -2,7 +2,6 @@ import Button from '@/components/test/Button'; import Image from 'next/image'; -import { IoIosClose } from 'react-icons/io'; import { usePathname } from 'next/navigation'; import ModalWrapper from '@/components/test/ModalWrapper'; @@ -14,7 +13,7 @@ export default function Default() { {pathname === '/' ? (
- +
e.stopPropagation()}>

From f611a714cbea6caf168a9eb682366c3a1fe17cff Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sun, 28 Jul 2024 15:45:02 +0900 Subject: [PATCH 33/52] =?UTF-8?q?=F0=9F=8E=A8=20Style:=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/mobile/MobileMenuBtn.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/mobile/MobileMenuBtn.tsx b/src/components/mobile/MobileMenuBtn.tsx index edec27f..b12e901 100644 --- a/src/components/mobile/MobileMenuBtn.tsx +++ b/src/components/mobile/MobileMenuBtn.tsx @@ -3,8 +3,6 @@ import Image from 'next/image'; import Link from 'next/link'; import { useState } from 'react'; -import { FaChevronDown } from 'react-icons/fa'; -import { FaChevronUp } from 'react-icons/fa'; type MobileMenuBtnType = { title: string; From c052be9be30cdc765f45f20d125f78ed737cbf42 Mon Sep 17 00:00:00 2001 From: SNXWXH Date: Sun, 28 Jul 2024 17:43:29 +0900 Subject: [PATCH 34/52] =?UTF-8?q?=F0=9F=A4=96=20Refactor:=20promise.all=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(main)/ranking/ai/page.tsx | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/app/(main)/ranking/ai/page.tsx b/src/app/(main)/ranking/ai/page.tsx index 8374b2d..76488b4 100644 --- a/src/app/(main)/ranking/ai/page.tsx +++ b/src/app/(main)/ranking/ai/page.tsx @@ -22,17 +22,20 @@ export default async function RankingAi() { const year = new Date().getFullYear(); const month = new Date().getMonth() + 1; const yearmonth = year + '0' + month; - const dayOfWeek = new Date().getDay(); - //선발투수 정보 API + // 선발투수 정보 API,오늘 경기장 API const day_num: number = julyScheduleJSON[today]; - const pitcherRes: Response = await fetch( - `${process.env.BASE_URL}/api/startingPitcher?day_num=${day_num}`, - { cache: 'no-store' }, - ); + const [pitcherRes, gameRes]: [Response, Response] = await Promise.all([ + fetch(`${process.env.BASE_URL}/api/startingPitcher?day_num=${day_num}`, { + cache: 'no-store', + }), + fetch(`${process.env.BASE_URL}/api/todayGame?yearmonth=${yearmonth}`), + ]); + const pitcherData: TPitcherData = await pitcherRes.json(); + const gameData: TGameData = await gameRes.json(); const todayGame: TPitcherRecord = pitcherData['선발투수']['선발']; const team: string[] = Object.keys(todayGame); @@ -40,12 +43,6 @@ export default async function RankingAi() { const score: TTeamRecord = pitcherData['상대전적']['정규시즌전적']; const teamScore: string[] = Object.values(score); - //오늘 경기장 API - const gaemRes: Response = await fetch( - `${process.env.BASE_URL}/api/todayGame?yearmonth=${yearmonth}`, - ); - const gameData: TGameData = await gaemRes.json(); - const gameDetail: TGameInfo[] = gameData.list.filter( (item: TGameInfo): boolean => { const gameDate: string = item.gameDate.toString(); @@ -56,11 +53,11 @@ export default async function RankingAi() { (item: TGameInfo): string => item.stadium, ); - //전체 승률 및 예상 승률 + // 전체 승률 및 예상 승률 const total: number = +winlossDataJSON.total[team[1]].winningPercentage; const last: number = +winlossDataJSON.recent[team[1]].winningPercentage; - //승리 예측 API + // 승리 예측 API const gamePredict: Response = await fetch( `${process.env.BASE_URL}/api/predict?opponentTeam=${team[1]}&pastWinRate=${total}&recentWinRate=${last}&stadiumInformatio=${stadiums}&startingPitcherInformation=${pitcher[1]}&weather=`, { cache: 'no-store' }, From 44c74d1ddf9707281ed2e5d79b6194b637d3c7ed Mon Sep 17 00:00:00 2001 From: SNXWXH Date: Sun, 28 Jul 2024 17:43:54 +0900 Subject: [PATCH 35/52] =?UTF-8?q?=E2=9C=A8=20Feat:=20not-found=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/not-found.tsx | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/app/not-found.tsx diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx new file mode 100644 index 0000000..5184f37 --- /dev/null +++ b/src/app/not-found.tsx @@ -0,0 +1,33 @@ +import Image from 'next/image'; +import Link from 'next/link'; + +export default function NotFound() { + return ( +
+
+ ticket + ticket +
+

요청하신 페이지를 찾을 수 없습니다

+
+ + {/* */} + +
+
+ ); +} From 82620a8fa9fb21ee03691759186bfd70b6bc8340 Mon Sep 17 00:00:00 2001 From: SNXWXH Date: Sun, 28 Jul 2024 17:44:23 +0900 Subject: [PATCH 36/52] =?UTF-8?q?=E2=9C=A8=20Feat:=20/ranking=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20loading=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(main)/ranking/loading.tsx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/app/(main)/ranking/loading.tsx diff --git a/src/app/(main)/ranking/loading.tsx b/src/app/(main)/ranking/loading.tsx new file mode 100644 index 0000000..b8ad03a --- /dev/null +++ b/src/app/(main)/ranking/loading.tsx @@ -0,0 +1,27 @@ +import Image from 'next/image'; + +export default function Loading() { + return ( + <> +
+
+ ticket + ticket +
+

빅과 또리가 열심히 불러오고 있습니다

+
+ + ); +} From 853c1cace42dde8629d255c3a76409efa1706b47 Mon Sep 17 00:00:00 2001 From: SNXWXH Date: Sun, 28 Jul 2024 17:45:34 +0900 Subject: [PATCH 37/52] =?UTF-8?q?=F0=9F=92=A1=20Comment:=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=20=EC=A3=BC=EC=84=9D=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/not-found.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx index 5184f37..7f97003 100644 --- a/src/app/not-found.tsx +++ b/src/app/not-found.tsx @@ -23,9 +23,7 @@ export default function NotFound() {

요청하신 페이지를 찾을 수 없습니다

- {/* */}

From 1dc7b7f371f943bb6449624270775f315bd86fe7 Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sun, 28 Jul 2024 18:22:54 +0900 Subject: [PATCH 38/52] =?UTF-8?q?=F0=9F=90=9B=20Fix:=20=EB=B9=8C=EB=93=9C?= =?UTF-8?q?=20=EC=8B=9C=20cr=20=EC=98=A4=EB=A5=98=20eslint=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=EC=9C=BC=EB=A1=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index 4dbd67f..3d462d1 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -23,7 +23,12 @@ "@typescript-eslint/no-explicit-any": "warn", "react/react-in-jsx-scope": "off", "no-console": "warn", - "prettier/prettier": "warn" + "prettier/prettier": [ + "warn", + { + "endOfLine": "auto" + } + ] }, "settings": { "react": { From 41ea0760be0e7ef27c84e4677466116783a1c6ed Mon Sep 17 00:00:00 2001 From: yheseul Date: Sun, 28 Jul 2024 20:32:44 +0900 Subject: [PATCH 39/52] =?UTF-8?q?=E2=9C=A8=20Feat:=20=EB=AA=A8=EB=8B=AC=20?= =?UTF-8?q?=EA=B2=B0=EA=B3=BC=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=8B=AB?= =?UTF-8?q?=EA=B8=B0=20=EB=B2=84=ED=8A=BC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../@result/(.)testResultModal/page.tsx | 104 +++++++++++------- src/components/test/result/CaptureArea.tsx | 14 ++- 2 files changed, 77 insertions(+), 41 deletions(-) diff --git a/src/app/(main)/@result/(.)testResultModal/page.tsx b/src/app/(main)/@result/(.)testResultModal/page.tsx index 40723b7..622c95c 100644 --- a/src/app/(main)/@result/(.)testResultModal/page.tsx +++ b/src/app/(main)/@result/(.)testResultModal/page.tsx @@ -1,21 +1,42 @@ 'use client'; import CaptureArea from '@/components/test/result/CaptureArea'; -import { useRef, useEffect, useState } from 'react'; +import { useRef, useEffect, useState, useCallback } from 'react'; import positionDetails from '@/data/positionDetails'; import { TPositionStatisticProps } from '@/types'; import captureResult from '@/utils/captureResult'; import dynamic from 'next/dynamic'; -import ModalWrapper from '@/components/test/ModalWrapper'; +import ModalTestWrapper from '@/components/test/ModalTestWrapper'; +import { usePathname, useRouter } from 'next/navigation'; -const Button = dynamic(() => import('@/components/test/Button'), { ssr: false }); -const ResultPosition = dynamic(() => import('@/components/test/result/ResultPosition'), { ssr: false }); -const TestShare = dynamic(() => import('@/components/test/result/TestShare'), { ssr: false }); +const Button = dynamic(() => import('@/components/test/Button'), { + ssr: false, +}); +const ResultPosition = dynamic( + () => import('@/components/test/result/ResultPosition'), + { ssr: false }, +); +const TestShare = dynamic(() => import('@/components/test/result/TestShare'), { + ssr: false, +}); const Page: React.FC = () => { const ref = useRef(null); const [statistics, setStatistics] = useState([]); const handleCapture = captureResult(ref); + const [isModalOpen, setIsModalOpen] = useState(true); + const router = useRouter(); + const pathname = usePathname(); + + const closeModal = useCallback(() => { + setIsModalOpen(false); + }, []); + + useEffect(() => { + if (!isModalOpen) { + router.push('/'); + } + }, [isModalOpen, router]); useEffect(() => { const fetchStatistics = async () => { @@ -38,46 +59,49 @@ const Page: React.FC = () => { return ( <> - -
e.stopPropagation()} className="bg-slate-100 h-full overflow-scroll no-scrollbar"> -
- -
-
- 가장 많은 포지션은 뭘까요? + {pathname === '/testResultModal' ? ( + +
+ +
+ +
+
+ 가장 많은 포지션은 뭘까요? +
+ {statistics.map((stat, index) => { + const details = positionDetails[stat.position]; + return ( + + ); + })}
- {statistics.map((stat, index) => { - const details = positionDetails[stat.position]; - return ( - - ); - })} -
-
- -
- 테스트 - 공유하기 +
+ +
+ 테스트 + 공유하기 +
+ +
+
+
- -
-
-
-
- +
+ ) : null} ); }; -export default Page; \ No newline at end of file +export default Page; diff --git a/src/components/test/result/CaptureArea.tsx b/src/components/test/result/CaptureArea.tsx index fb7ad13..6598205 100644 --- a/src/components/test/result/CaptureArea.tsx +++ b/src/components/test/result/CaptureArea.tsx @@ -4,7 +4,11 @@ import { useEffect, useState, forwardRef } from 'react'; import Image from 'next/image'; import Loading from '@/app/(test)/test/loading'; -const CaptureArea = forwardRef((_, ref) => { +type TCaptureAreaProps = { + closeModal?: () => void; +}; + +const CaptureArea = forwardRef(({ closeModal }, ref) => { const [result, setResult] = useState<{ position: string; response: string; @@ -28,6 +32,14 @@ const CaptureArea = forwardRef((_, ref) => { ref={ref} className="w-full h-[883px] bg-[#FFFFFF] flex flex-col justify-center items-center relative" > + { closeModal ? + () : null + }
당신의 ♥천생연분♥ 야구선수는?
From 337f6b776c436121140dc7535ae2dae3329402d0 Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sun, 28 Jul 2024 22:37:08 +0900 Subject: [PATCH 40/52] =?UTF-8?q?=F0=9F=92=84=20Design:=20=EB=89=B4?= =?UTF-8?q?=EC=8A=A4=20=EB=B0=B0=EB=84=88=EC=97=90=20=EB=B0=98=EC=9D=91?= =?UTF-8?q?=ED=98=95=20=ED=8C=A8=EB=94=A9=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/wiznews/NewsBanner.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/wiznews/NewsBanner.tsx b/src/components/wiznews/NewsBanner.tsx index 109f4ce..3696b3a 100644 --- a/src/components/wiznews/NewsBanner.tsx +++ b/src/components/wiznews/NewsBanner.tsx @@ -1,7 +1,7 @@ export default function NewsBanner() { return ( <> -
+

wiz AI 뉴스

From 77624f2df76b31306f0f345bb61aadbf2d82bef1 Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sun, 28 Jul 2024 22:38:10 +0900 Subject: [PATCH 41/52] =?UTF-8?q?=F0=9F=92=84=20Design:=20=EB=AA=A8?= =?UTF-8?q?=EB=B0=94=EC=9D=BC=20=ED=97=A4=EB=8D=94=EB=A5=BC=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20=EB=B0=98=EC=9D=91=ED=98=95=20=ED=8C=A8=EB=94=A9=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(main)/player/batter/layout.tsx | 3 +-- src/app/(main)/player/pitcher/layout.tsx | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/app/(main)/player/batter/layout.tsx b/src/app/(main)/player/batter/layout.tsx index 9567bc6..c76a1ba 100644 --- a/src/app/(main)/player/batter/layout.tsx +++ b/src/app/(main)/player/batter/layout.tsx @@ -8,8 +8,7 @@ export default function BatterLayout({ return ( <>
- {' '} -
+
{children} diff --git a/src/app/(main)/player/pitcher/layout.tsx b/src/app/(main)/player/pitcher/layout.tsx index c503813..dfa47d7 100644 --- a/src/app/(main)/player/pitcher/layout.tsx +++ b/src/app/(main)/player/pitcher/layout.tsx @@ -8,8 +8,7 @@ export default function PitcherLayout({ return ( <>
- {' '} -
+
{children} From 5ea910edad5884810cbd64cb9678027a197599a5 Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sun, 28 Jul 2024 22:43:11 +0900 Subject: [PATCH 42/52] =?UTF-8?q?=F0=9F=92=84=20Design:=20=ED=94=8C?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EC=96=B4=20=EC=B9=B4=EB=93=9C=20flex=20?= =?UTF-8?q?=EA=B0=80=EC=9A=B4=EB=8D=B0=20=EC=A0=95=EB=A0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(main)/player/batter/catcher/page.tsx | 2 +- src/app/(main)/player/batter/infielder/page.tsx | 2 +- src/app/(main)/player/batter/outfielder/page.tsx | 2 +- src/app/(main)/player/pitcher/page.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/(main)/player/batter/catcher/page.tsx b/src/app/(main)/player/batter/catcher/page.tsx index d0f0024..df27989 100644 --- a/src/app/(main)/player/batter/catcher/page.tsx +++ b/src/app/(main)/player/batter/catcher/page.tsx @@ -15,7 +15,7 @@ export default function Catcher() { return ( <>
-
+
{catcherData.map((catcher, index) => (
-
+
{infielderData.map((infielder, index) => (
-
+
{outfielderData.map((outfielder, index) => (
-
+
{pitcherData.map((pitcher, index) => ( Date: Sun, 28 Jul 2024 22:44:03 +0900 Subject: [PATCH 43/52] =?UTF-8?q?=F0=9F=92=84=20Design:=20=ED=94=8C?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EC=96=B4=20=EB=B0=B0=EB=84=88=20=EB=B0=98?= =?UTF-8?q?=EC=9D=91=ED=98=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/player/Banner.tsx | 89 +++++++++++++++++--------------- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/src/components/player/Banner.tsx b/src/components/player/Banner.tsx index dd5be0c..fe3f2c2 100644 --- a/src/components/player/Banner.tsx +++ b/src/components/player/Banner.tsx @@ -38,17 +38,22 @@ export default function Banner() { return ( <> -
+
-

+

{text[pathname]?.title}

-

{text[pathname]?.subtitle}

+

+ {text[pathname]?.subtitle} +

-
+
코칭스탭 @@ -60,52 +65,50 @@ export default function Banner() { - 타자 +

타자

{pathname === 'batter' ? ( -
-
-
-
- - 포수 - - - 내야수 - - - 외야수 - -
+
+
+
+ + 포수 + + + 내야수 + + + 외야수 +
) : ( <> )} - {' '} + Date: Sun, 28 Jul 2024 23:19:55 +0900 Subject: [PATCH 44/52] =?UTF-8?q?=F0=9F=A4=96=20Refactor:=20=EB=92=A4?= =?UTF-8?q?=EB=A1=9C=EA=B0=80=EA=B8=B0=20=EB=B2=84=ED=8A=BC=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/questions/[questionId]/page.tsx | 28 +++++++++---------- src/components/test/result/BackButton.tsx | 28 +++++++++++++++++++ 2 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 src/components/test/result/BackButton.tsx diff --git a/src/app/(test)/test/questions/[questionId]/page.tsx b/src/app/(test)/test/questions/[questionId]/page.tsx index 9be7a7e..de0949a 100644 --- a/src/app/(test)/test/questions/[questionId]/page.tsx +++ b/src/app/(test)/test/questions/[questionId]/page.tsx @@ -4,9 +4,9 @@ import { useEffect, useState } from 'react'; import { useRouter } from 'next/navigation'; import ProgressBar from '@/components/test/ProgressBar'; import TestAnswer from '@/components/test/TestAnswer'; -import { IoIosArrowBack } from 'react-icons/io'; import { TQuestionHandlerProps } from '@/types'; import Loading from '../../loading'; +import BackButton from '@/components/test/result/BackButton'; type TQuestionsProps = { params: { @@ -23,15 +23,18 @@ export default function Questions({ params }: TQuestionsProps) { useEffect(() => { const fetchQuestions = async () => { try { - sessionStorage.removeItem('questions'); - sessionStorage.removeItem('positionArr'); - const response = await fetch('/api/questions'); - if (response.ok) { - const data = await response.json(); - setQuestions(data); - sessionStorage.setItem('questions', JSON.stringify(data)); + const cachedQuestions = sessionStorage.getItem('questions'); + if (cachedQuestions) { + setQuestions(JSON.parse(cachedQuestions)); } else { - console.error('Failed to fetch questions'); + const response = await fetch('/api/questions'); + if (response.ok) { + const data = await response.json(); + setQuestions(data); + sessionStorage.setItem('questions', JSON.stringify(data)); + } else { + console.error('Failed to fetch questions'); + } } } catch (error) { console.error('Failed to fetch questions', error); @@ -112,12 +115,7 @@ export default function Questions({ params }: TQuestionsProps) {
- +
{questionIndex + 1} / {totalQuestions}
diff --git a/src/components/test/result/BackButton.tsx b/src/components/test/result/BackButton.tsx new file mode 100644 index 0000000..228147e --- /dev/null +++ b/src/components/test/result/BackButton.tsx @@ -0,0 +1,28 @@ +import { useRouter } from "next/navigation"; + +type TBackButtonProps = { + positionArr: string[]; + setPositionArr: any; +} + +export default function BackButton ({ positionArr, setPositionArr }: TBackButtonProps) { + const router = useRouter(); + + const onBackClick = () => { + router.back() + const back = positionArr.slice(0, -1); + setPositionArr(back); + sessionStorage.setItem('positionArr', JSON.stringify(back)); + }; + + return ( + <> + + + ) +} \ No newline at end of file From 2541cf4f0ef63a89349a277fa3ca9edab86836e1 Mon Sep 17 00:00:00 2001 From: yheseul Date: Sun, 28 Jul 2024 23:20:58 +0900 Subject: [PATCH 45/52] =?UTF-8?q?=F0=9F=A4=96=20Refactor:=20=EB=AA=A8?= =?UTF-8?q?=EB=8B=AC=20=EB=8B=AB=EA=B8=B0=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(main)/@modal/(.)testModal/page.tsx | 106 ++++++++++++-------- src/components/test/ModalTestWrapper.tsx | 17 ++++ 2 files changed, 82 insertions(+), 41 deletions(-) create mode 100644 src/components/test/ModalTestWrapper.tsx diff --git a/src/app/(main)/@modal/(.)testModal/page.tsx b/src/app/(main)/@modal/(.)testModal/page.tsx index 335a210..8a90d25 100644 --- a/src/app/(main)/@modal/(.)testModal/page.tsx +++ b/src/app/(main)/@modal/(.)testModal/page.tsx @@ -1,54 +1,78 @@ -'use client' +'use client'; import Button from '@/components/test/Button'; -import ModalWrapper from '@/components/test/ModalWrapper'; +import ModalTestWrapper from '@/components/test/ModalTestWrapper'; import Image from 'next/image'; +import React, { useEffect, useState } from 'react'; +import { usePathname, useRouter } from 'next/navigation'; export default function Modal() { + const [isModalOpen, setIsModalOpen] = useState(true); + const router = useRouter(); + const pathname = usePathname(); + + const closeModal = () => { + setIsModalOpen(false); + } + + useEffect(() => { + if (!isModalOpen) { + router.push('/'); + } + }, [isModalOpen, router]); + return ( <> - -
e.stopPropagation()} className="flex justify-center flex-col items-center h-dvh max-w-md m-auto"> -
-
- 야구 입문자를 위한 + {pathname === '/testModal' ? ( + +
+
+ +
+ 야구 입문자를 위한 +
+ watermark +
+ 궁합테스트 +
+
+ 나와 어울리는 KT Wiz 선수 알아보기! +
+ emblem +
- watermark -
- 궁합테스트 -
-
- 나와 어울리는 KT Wiz 선수 알아보기! -
- emblem - -
-
-
- kt wiz는 2013년, 제 10구단에 대한 국민들의 강한 열망, -
경기도 및 수원시 그리고 KT그룹의 뜨거운 유치 열정으로 -
비상한 솜씨와 비범한 재능을 가진 마법사, -
- wiz라는 이름으로 신비롭고 강력한 힘으로 상상의 야구를 -
실현하겠다는 의지를 가지고 새롭게 출범하였습니다. +
+
+ kt wiz는 2013년, 제 10구단에 대한 국민들의 강한 열망, +
경기도 및 수원시 그리고 KT그룹의 뜨거운 유치 열정으로 +
비상한 솜씨와 비범한 재능을 가진 마법사, +
+ wiz라는 이름으로 신비롭고 강력한 힘으로 상상의 야구를 +
실현하겠다는 의지를 가지고 새롭게 출범하였습니다. +
-
- +
+ ) : null } ); } diff --git a/src/components/test/ModalTestWrapper.tsx b/src/components/test/ModalTestWrapper.tsx new file mode 100644 index 0000000..942aaae --- /dev/null +++ b/src/components/test/ModalTestWrapper.tsx @@ -0,0 +1,17 @@ +'use client'; + +import React, { useCallback, useState } from 'react'; + +export default function ModalTestWrapper({ + children, +}: { + children: React.ReactNode; +}) { + return ( + <> +
+ {children} +
+ + ); +} From 200a04b24f8317eebf7357d7a50166f5f2da017f Mon Sep 17 00:00:00 2001 From: yheseul Date: Sun, 28 Jul 2024 23:21:45 +0900 Subject: [PATCH 46/52] =?UTF-8?q?=F0=9F=90=9B=20Fix:=20=EB=AA=A8=EB=8B=AC?= =?UTF-8?q?=20=EC=A7=88=EB=AC=B8=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=ED=99=94?= =?UTF-8?q?=EB=A9=B4=20=EC=A0=84=ED=99=98=EC=8B=9C=20=EA=B9=9C=EB=B9=A1?= =?UTF-8?q?=EA=B1=B0=EB=A6=BC=20=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../questions/[questionId]/page.tsx | 141 ---------------- .../(main)/@questions/questionsModal/page.tsx | 153 ++++++++++++++++++ 2 files changed, 153 insertions(+), 141 deletions(-) delete mode 100644 src/app/(main)/@questions/(.)testModal/questions/[questionId]/page.tsx create mode 100644 src/app/(main)/@questions/questionsModal/page.tsx diff --git a/src/app/(main)/@questions/(.)testModal/questions/[questionId]/page.tsx b/src/app/(main)/@questions/(.)testModal/questions/[questionId]/page.tsx deleted file mode 100644 index 01f93cf..0000000 --- a/src/app/(main)/@questions/(.)testModal/questions/[questionId]/page.tsx +++ /dev/null @@ -1,141 +0,0 @@ -'use client'; - -import ModalWrapper from '@/components/test/ModalWrapper'; -import { useEffect, useState } from 'react'; -import { useRouter } from 'next/navigation'; -import ProgressBar from '@/components/test/ProgressBar'; -import TestAnswer from '@/components/test/TestAnswer'; -import { IoIosArrowBack } from 'react-icons/io'; -import { TQuestionHandlerProps } from '@/types'; -import ModalLoading from '@/components/test/ModalLoading'; - -type TQuestionsProps = { - params: { - questionId: string; - }; -}; - -export default function Questions({ params }: TQuestionsProps) { - const router = useRouter(); - const [questions, setQuestions] = useState([]); - const [loading, setLoading] = useState(true); - const [positionArr, setPositionArr] = useState([]); - - useEffect(() => { - const fetchQuestions = async () => { - try { - sessionStorage.removeItem('questions'); - sessionStorage.removeItem('positionArr'); - const response = await fetch('/api/questions'); - if (response.ok) { - const data = await response.json(); - setQuestions(data); - sessionStorage.setItem('questions', JSON.stringify(data)); - } else { - console.error('Failed to fetch questions'); - } - } catch (error) { - console.error('Failed to fetch questions', error); - } - setLoading(false); - }; - fetchQuestions(); - }, []); - - useEffect(() => { - const storedPositionArr = sessionStorage.getItem('positionArr'); - if (storedPositionArr) { - setPositionArr(JSON.parse(storedPositionArr)); - } - }, []); - - if (loading) { - return ( - - - - ); - } - - const questionIndex = parseInt(params.questionId, 10) - 1; - const question = questions[questionIndex]; - const totalQuestions = questions.length; - - const handleAnswer = async (answer: string) => { - const updatedPositionArr = [...positionArr, answer]; - setPositionArr(updatedPositionArr); - sessionStorage.setItem('positionArr', JSON.stringify(updatedPositionArr)); - - if (questionIndex < totalQuestions - 1) { - router.push(`/testModal/questions/${questionIndex + 2}`); - } else { - try { - const response = await fetch('/api/testResult', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ positions: updatedPositionArr }), - }); - - if (response.ok) { - const result = await response.json(); - sessionStorage.setItem('testResult', JSON.stringify(result)); - router.push('/testModal/result'); - } else { - const errorText = await response.text(); - console.error('Failed to fetch test result:', errorText); - } - } catch (error) { - 2; - console.error('Failed to fetch test result:', error); - } - sessionStorage.removeItem('questions'); - sessionStorage.removeItem('positionArr'); - } - setLoading(false); - }; - - const progress = ((questionIndex + 1) / totalQuestions) * 100; - - return ( - <> - -
-
-
- -
-

- Q{questionIndex + 1} -

-

- {question.Q} -

-
-
-
- handleAnswer(question.P1)}> - {question.A1} - - handleAnswer(question.P2)}> - {question.A2} - -
-
- -
- {questionIndex + 1} / {totalQuestions} -
-
-
-
-
- - ); -} diff --git a/src/app/(main)/@questions/questionsModal/page.tsx b/src/app/(main)/@questions/questionsModal/page.tsx new file mode 100644 index 0000000..7e99d6a --- /dev/null +++ b/src/app/(main)/@questions/questionsModal/page.tsx @@ -0,0 +1,153 @@ +'use client'; + +import { useCallback, useEffect, useState } from 'react'; +import { usePathname, useRouter } from 'next/navigation'; +import ProgressBar from '@/components/test/ProgressBar'; +import TestAnswer from '@/components/test/TestAnswer'; +import { TQuestionHandlerProps } from '@/types'; +import ModalLoading from '@/components/test/ModalLoading'; +import ModalTestWrapper from '@/components/test/ModalTestWrapper'; + +export default function Questions() { + const router = useRouter(); + const [questions, setQuestions] = useState([]); + const [loading, setLoading] = useState(true); + const [positionArr, setPositionArr] = useState([]); + const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0); + const [isModalOpen, setIsModalOpen] = useState(true); + const pathname = usePathname(); + + const closeModal = useCallback(() => { + setIsModalOpen(false); + sessionStorage.removeItem('questions'); + sessionStorage.removeItem('positionArr'); + }, []); + + useEffect(() => { + if (!isModalOpen) { + router.push('/'); + } + }, [isModalOpen, router]); + + const fetchQuestions = useCallback(async () => { + try { + const cachedQuestions = sessionStorage.getItem('questions'); + if (cachedQuestions) setQuestions(JSON.parse(cachedQuestions)); + const response = await fetch('/api/questions'); + if (response.ok) { + const data = await response.json(); + setQuestions(data); + sessionStorage.setItem('questions', JSON.stringify(data)); + } else { + console.error('Failed to fetch questions'); + } + } catch (error) { + console.error('Failed to fetch questions', error); + } + setLoading(false); + }, []); + + useEffect(() => { + const storedPositionArr = sessionStorage.getItem('positionArr'); + if (storedPositionArr) { + setPositionArr(JSON.parse(storedPositionArr)); + } + fetchQuestions(); + }, [fetchQuestions]); + + if (loading) { + return ( + + + + ); + } + + const totalQuestions = questions.length; + const question = questions[currentQuestionIndex]; + + const handleAnswer = async (answer: string) => { + const updatedPositionArr = [...positionArr, answer]; + setPositionArr(updatedPositionArr); + sessionStorage.setItem('positionArr', JSON.stringify(updatedPositionArr)); + + if (currentQuestionIndex < totalQuestions - 1) { + setCurrentQuestionIndex((prevIndex) => prevIndex + 1); + } else { + const response = await fetch( + `/api/testResult?positions=${updatedPositionArr}`, + ); + + if (response.ok) { + const result = await response.json(); + sessionStorage.setItem('testResult', JSON.stringify(result)); + router.push('/testResultModal'); + } else { + const errorText = await response.text(); + console.error('Failed to fetch test result:', errorText); + } + sessionStorage.removeItem('questions'); + sessionStorage.removeItem('positionArr'); + } + setLoading(false); + }; + + const onBackClick = () => { + setCurrentQuestionIndex((prevIndex) => prevIndex - 1); + const back = positionArr.slice(0, -1); + console.log(back); + setPositionArr(back); + sessionStorage.setItem('positionArr', JSON.stringify(back)); + }; + + const progress = ((currentQuestionIndex + 1) / totalQuestions) * 100; + + return ( + <> + {pathname === '/questionsModal' ? ( + +
+
+ +
+ +
+

+ Q{currentQuestionIndex + 1} +

+

+ {question.Q} +

+
+
+
+ handleAnswer(question.P1)}> + {question.A1} + + handleAnswer(question.P2)}> + {question.A2} + +
+
+ +
+ {currentQuestionIndex + 1} / {totalQuestions} +
+
+
+
+
+ ) : null} + + ); +} From 718dea7c7681f77c92f0be5c60c5fb0a9c9d555d Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Sun, 28 Jul 2024 23:24:09 +0900 Subject: [PATCH 47/52] =?UTF-8?q?=F0=9F=9A=9A=20Chore:=20react-icons=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 9 --------- package.json | 1 - 2 files changed, 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 803dfe0..38ca95f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,6 @@ "react": "^18", "react-datepicker": "^7.3.0", "react-dom": "^18", - "react-icons": "^5.2.1", "react-intersection-observer": "^9.13.0", "zustand": "^4.5.4" }, @@ -5838,14 +5837,6 @@ "react": "^18.3.1" } }, - "node_modules/react-icons": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.2.1.tgz", - "integrity": "sha512-zdbW5GstTzXaVKvGSyTaBalt7HSfuK5ovrzlpyiWHAFXndXTdd/1hdDHI4xBM1Mn7YriT6aqESucFl9kEXzrdw==", - "peerDependencies": { - "react": "*" - } - }, "node_modules/react-intersection-observer": { "version": "9.13.0", "resolved": "https://registry.npmjs.org/react-intersection-observer/-/react-intersection-observer-9.13.0.tgz", diff --git a/package.json b/package.json index 4ab35ac..a9e9eb1 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,6 @@ "react": "^18", "react-datepicker": "^7.3.0", "react-dom": "^18", - "react-icons": "^5.2.1", "react-intersection-observer": "^9.13.0", "zustand": "^4.5.4" }, From 0fadd93ef65614328d0762733fa3e1080f8d8692 Mon Sep 17 00:00:00 2001 From: SNXWXH Date: Sun, 28 Jul 2024 23:24:13 +0900 Subject: [PATCH 48/52] =?UTF-8?q?=F0=9F=92=84=20Design:=20banner=20CSS=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ranking/Banner.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ranking/Banner.tsx b/src/components/ranking/Banner.tsx index d9236a0..c4ea703 100644 --- a/src/components/ranking/Banner.tsx +++ b/src/components/ranking/Banner.tsx @@ -28,7 +28,7 @@ export default function Banner() { return ( <> -
+

From 965b47e98841014c6028585059eb5dfb1487aba2 Mon Sep 17 00:00:00 2001 From: SNXWXH Date: Sun, 28 Jul 2024 23:25:03 +0900 Subject: [PATCH 49/52] =?UTF-8?q?=F0=9F=9A=9A=20Chore:=20react-icons=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 9 --------- package.json | 1 - 2 files changed, 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 803dfe0..38ca95f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,6 @@ "react": "^18", "react-datepicker": "^7.3.0", "react-dom": "^18", - "react-icons": "^5.2.1", "react-intersection-observer": "^9.13.0", "zustand": "^4.5.4" }, @@ -5838,14 +5837,6 @@ "react": "^18.3.1" } }, - "node_modules/react-icons": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.2.1.tgz", - "integrity": "sha512-zdbW5GstTzXaVKvGSyTaBalt7HSfuK5ovrzlpyiWHAFXndXTdd/1hdDHI4xBM1Mn7YriT6aqESucFl9kEXzrdw==", - "peerDependencies": { - "react": "*" - } - }, "node_modules/react-intersection-observer": { "version": "9.13.0", "resolved": "https://registry.npmjs.org/react-intersection-observer/-/react-intersection-observer-9.13.0.tgz", diff --git a/package.json b/package.json index 4ab35ac..a9e9eb1 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,6 @@ "react": "^18", "react-datepicker": "^7.3.0", "react-dom": "^18", - "react-icons": "^5.2.1", "react-intersection-observer": "^9.13.0", "zustand": "^4.5.4" }, From 2d282c7924e96a1855e81940d9c7e73f1495f482 Mon Sep 17 00:00:00 2001 From: yheseul Date: Sun, 28 Jul 2024 23:27:26 +0900 Subject: [PATCH 50/52] =?UTF-8?q?=F0=9F=8E=A8=20Style:=20=ED=94=84?= =?UTF-8?q?=EB=A6=AC=ED=8B=B0=EC=96=B4=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(main)/@modal/(.)testModal/page.tsx | 4 +- src/app/(main)/@modal/default.tsx | 4 +- .../@result/(.)testResultModal/page.tsx | 1 - .../test/questions/[questionId]/page.tsx | 5 +- src/app/(test)/test/result/page.tsx | 15 ++- src/components/test/result/BackButton.tsx | 15 ++- src/components/test/result/CaptureArea.tsx | 106 +++++++++--------- src/components/test/result/KakaoShare.tsx | 5 - 8 files changed, 83 insertions(+), 72 deletions(-) diff --git a/src/app/(main)/@modal/(.)testModal/page.tsx b/src/app/(main)/@modal/(.)testModal/page.tsx index 8a90d25..0cc3235 100644 --- a/src/app/(main)/@modal/(.)testModal/page.tsx +++ b/src/app/(main)/@modal/(.)testModal/page.tsx @@ -13,7 +13,7 @@ export default function Modal() { const closeModal = () => { setIsModalOpen(false); - } + }; useEffect(() => { if (!isModalOpen) { @@ -72,7 +72,7 @@ export default function Modal() {

- ) : null } + ) : null} ); } diff --git a/src/app/(main)/@modal/default.tsx b/src/app/(main)/@modal/default.tsx index c6fdf29..83216f8 100644 --- a/src/app/(main)/@modal/default.tsx +++ b/src/app/(main)/@modal/default.tsx @@ -13,7 +13,9 @@ export default function Default() { {pathname === '/' ? (
- +
e.stopPropagation()}>

diff --git a/src/app/(main)/@result/(.)testResultModal/page.tsx b/src/app/(main)/@result/(.)testResultModal/page.tsx index 622c95c..462226d 100644 --- a/src/app/(main)/@result/(.)testResultModal/page.tsx +++ b/src/app/(main)/@result/(.)testResultModal/page.tsx @@ -62,7 +62,6 @@ const Page: React.FC = () => { {pathname === '/testResultModal' ? (
-
diff --git a/src/app/(test)/test/questions/[questionId]/page.tsx b/src/app/(test)/test/questions/[questionId]/page.tsx index de0949a..8c64f04 100644 --- a/src/app/(test)/test/questions/[questionId]/page.tsx +++ b/src/app/(test)/test/questions/[questionId]/page.tsx @@ -115,7 +115,10 @@ export default function Questions({ params }: TQuestionsProps) {
- +
{questionIndex + 1} / {totalQuestions}
diff --git a/src/app/(test)/test/result/page.tsx b/src/app/(test)/test/result/page.tsx index 90ffcbb..6966400 100644 --- a/src/app/(test)/test/result/page.tsx +++ b/src/app/(test)/test/result/page.tsx @@ -7,9 +7,16 @@ import { TPositionStatisticProps } from '@/types'; import captureResult from '@/utils/captureResult'; import dynamic from 'next/dynamic'; -const Button = dynamic(() => import('@/components/test/Button'), { ssr: false }); -const ResultPosition = dynamic(() => import('@/components/test/result/ResultPosition'), { ssr: false }); -const TestShare = dynamic(() => import('@/components/test/result/TestShare'), { ssr: false }); +const Button = dynamic(() => import('@/components/test/Button'), { + ssr: false, +}); +const ResultPosition = dynamic( + () => import('@/components/test/result/ResultPosition'), + { ssr: false }, +); +const TestShare = dynamic(() => import('@/components/test/result/TestShare'), { + ssr: false, +}); const Page: React.FC = () => { const ref = useRef(null); @@ -77,4 +84,4 @@ const Page: React.FC = () => { ); }; -export default Page; \ No newline at end of file +export default Page; diff --git a/src/components/test/result/BackButton.tsx b/src/components/test/result/BackButton.tsx index 228147e..bea6277 100644 --- a/src/components/test/result/BackButton.tsx +++ b/src/components/test/result/BackButton.tsx @@ -1,15 +1,18 @@ -import { useRouter } from "next/navigation"; +import { useRouter } from 'next/navigation'; type TBackButtonProps = { positionArr: string[]; setPositionArr: any; -} +}; -export default function BackButton ({ positionArr, setPositionArr }: TBackButtonProps) { +export default function BackButton({ + positionArr, + setPositionArr, +}: TBackButtonProps) { const router = useRouter(); const onBackClick = () => { - router.back() + router.back(); const back = positionArr.slice(0, -1); setPositionArr(back); sessionStorage.setItem('positionArr', JSON.stringify(back)); @@ -24,5 +27,5 @@ export default function BackButton ({ positionArr, setPositionArr }: TBackButton {'<'} 뒤로 - ) -} \ No newline at end of file + ); +} diff --git a/src/components/test/result/CaptureArea.tsx b/src/components/test/result/CaptureArea.tsx index 6598205..fc063aa 100644 --- a/src/components/test/result/CaptureArea.tsx +++ b/src/components/test/result/CaptureArea.tsx @@ -8,63 +8,65 @@ type TCaptureAreaProps = { closeModal?: () => void; }; -const CaptureArea = forwardRef(({ closeModal }, ref) => { - const [result, setResult] = useState<{ - position: string; - response: string; - } | null>(null); +const CaptureArea = forwardRef( + ({ closeModal }, ref) => { + const [result, setResult] = useState<{ + position: string; + response: string; + } | null>(null); - useEffect(() => { - const storedResult = sessionStorage.getItem('testResult'); - if (storedResult) { - const parsedResult = JSON.parse(storedResult); - setResult(parsedResult); - } - }, []); + useEffect(() => { + const storedResult = sessionStorage.getItem('testResult'); + if (storedResult) { + const parsedResult = JSON.parse(storedResult); + setResult(parsedResult); + } + }, []); - if (!result) { - return ; - } + if (!result) { + return ; + } - return ( -
- { closeModal ? - () : null - } -
- 당신의 ♥천생연분♥ 야구선수는? -
- sample -
-

⚾️{result.position}⚾️

-
- {result.response} + return ( +
+ {closeModal ? ( + + ) : null} +
+ 당신의 ♥천생연분♥ 야구선수는? +
+ sample +
+

⚾️{result.position}⚾️

+
+ {result.response} +
+ emblem
- emblem -
- ); -}); + ); + }, +); CaptureArea.displayName = 'CaptureArea'; diff --git a/src/components/test/result/KakaoShare.tsx b/src/components/test/result/KakaoShare.tsx index 70395ee..3df51ed 100644 --- a/src/components/test/result/KakaoShare.tsx +++ b/src/components/test/result/KakaoShare.tsx @@ -3,11 +3,6 @@ import React, { useEffect } from 'react'; import Image from 'next/image'; -// type KakaoShareProps = { -// description: string; -// }; - -// const KakaoShare = ({ description }: KakaoShareProps) => { const KakaoShare = () => { const shareUrl = typeof window !== 'undefined' From c04266ff7520991d4d07c490549871a27b9b5602 Mon Sep 17 00:00:00 2001 From: yheseul Date: Sun, 28 Jul 2024 23:32:03 +0900 Subject: [PATCH 51/52] =?UTF-8?q?=F0=9F=94=A7=20Modify:=20env=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/test/result/UrlCopy.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/test/result/UrlCopy.tsx b/src/components/test/result/UrlCopy.tsx index bc157fd..b9b5fdf 100644 --- a/src/components/test/result/UrlCopy.tsx +++ b/src/components/test/result/UrlCopy.tsx @@ -1,7 +1,7 @@ 'use client'; export default function UrlCopy() { - const testUrl: string = 'https://vicddory-frontend.vercel.app/test'; + const testUrl: string = `${process.env.BASE_URL}/test`; // testUrl.select(); // testUrl.setSelectionRange(0, 99999); navigator.clipboard.writeText(testUrl); From 8e861b429633f8a2380f2b0ed98071ab38e804df Mon Sep 17 00:00:00 2001 From: Jay Ho Oh Date: Mon, 29 Jul 2024 00:10:12 +0900 Subject: [PATCH 52/52] =?UTF-8?q?=F0=9F=90=9B=20Fix:=20=EB=B9=8C=EB=93=9C?= =?UTF-8?q?=20=EC=98=A4=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../questions/[questionId]/page.tsx | 138 ------------------ .../@result/(.)testResultModal/page.tsx | 4 +- src/app/(test)/test/result/page.tsx | 4 +- src/components/player/PlayerData.tsx | 8 +- src/components/test/ModalTestWrapper.tsx | 2 +- .../{captureResult.ts => useCaptureResult.ts} | 4 +- 6 files changed, 10 insertions(+), 150 deletions(-) delete mode 100644 src/app/(main)/@questions/(.)testModal/questions/[questionId]/page.tsx rename src/utils/{captureResult.ts => useCaptureResult.ts} (84%) diff --git a/src/app/(main)/@questions/(.)testModal/questions/[questionId]/page.tsx b/src/app/(main)/@questions/(.)testModal/questions/[questionId]/page.tsx deleted file mode 100644 index ff35070..0000000 --- a/src/app/(main)/@questions/(.)testModal/questions/[questionId]/page.tsx +++ /dev/null @@ -1,138 +0,0 @@ -'use client'; - -import ModalWrapper from '@/components/test/ModalWrapper'; -import { useEffect, useState } from 'react'; -import { useRouter } from 'next/navigation'; -import ProgressBar from '@/components/test/ProgressBar'; -import TestAnswer from '@/components/test/TestAnswer'; -import { IoIosArrowBack } from 'react-icons/io'; -import { TQuestionHandlerProps } from '@/types'; -import Loading from '@/app/(test)/test/loading'; - -type TQuestionsProps = { - params: { - questionId: string; - }; -}; - -export default function Questions({ params }: TQuestionsProps) { - const router = useRouter(); - const [questions, setQuestions] = useState([]); - const [loading, setLoading] = useState(true); - const [positionArr, setPositionArr] = useState([]); - - useEffect(() => { - const fetchQuestions = async () => { - try { - const cachedQuestions = sessionStorage.getItem('questions'); - if (cachedQuestions) { - setQuestions(JSON.parse(cachedQuestions)); - } else { - const response = await fetch('/api/questions'); - if (response.ok) { - const data = await response.json(); - setQuestions(data); - sessionStorage.setItem('questions', JSON.stringify(data)); - } else { - throw new Error('Server-Failed to fetch question Data'); - } - } - } catch (error) { - throw new Error('Server-Failed to fetch question Data'); - } - setLoading(false); - }; - fetchQuestions(); - }, []); - - useEffect(() => { - const storedPositionArr = sessionStorage.getItem('positionArr'); - if (storedPositionArr) { - setPositionArr(JSON.parse(storedPositionArr)); - } - }, []); - - if (loading) { - return ; - } - - const questionIndex = parseInt(params.questionId, 10) - 1; - const question = questions[questionIndex]; - const totalQuestions = questions.length; - - const handleAnswer = async (answer: string) => { - const updatedPositionArr = [...positionArr, answer]; - setPositionArr(updatedPositionArr); - sessionStorage.setItem('positionArr', JSON.stringify(updatedPositionArr)); - - if (questionIndex < totalQuestions - 1) { - router.push(`/testModal/questions/${questionIndex + 2}`); - } else { - try { - const response = await fetch('/api/testResult', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ positions: updatedPositionArr }), - }); - - if (response.ok) { - const result = await response.json(); - sessionStorage.setItem('testResult', JSON.stringify(result)); - router.push('/testModal/result'); - } else { - const errorText = await response.text(); - throw new Error(errorText); - } - } catch (error) { - throw new Error('Server-Failed to fetch testResult Data'); - } - sessionStorage.removeItem('questions'); - sessionStorage.removeItem('positionArr'); - } - }; - - const progress = ((questionIndex + 1) / totalQuestions) * 100; - - return ( - <> - -
-
-
- -
-

- Q{questionIndex + 1} -

-

- {question.Q} -

-
-
-
- handleAnswer(question.P1)}> - {question.A1} - - handleAnswer(question.P2)}> - {question.A2} - -
-
- -
- {questionIndex + 1} / {totalQuestions} -
-
-
-
-
- - ); -} diff --git a/src/app/(main)/@result/(.)testResultModal/page.tsx b/src/app/(main)/@result/(.)testResultModal/page.tsx index 462226d..ab13ee5 100644 --- a/src/app/(main)/@result/(.)testResultModal/page.tsx +++ b/src/app/(main)/@result/(.)testResultModal/page.tsx @@ -4,7 +4,7 @@ import CaptureArea from '@/components/test/result/CaptureArea'; import { useRef, useEffect, useState, useCallback } from 'react'; import positionDetails from '@/data/positionDetails'; import { TPositionStatisticProps } from '@/types'; -import captureResult from '@/utils/captureResult'; +import useCaptureResult from '@/utils/useCaptureResult'; import dynamic from 'next/dynamic'; import ModalTestWrapper from '@/components/test/ModalTestWrapper'; import { usePathname, useRouter } from 'next/navigation'; @@ -23,7 +23,7 @@ const TestShare = dynamic(() => import('@/components/test/result/TestShare'), { const Page: React.FC = () => { const ref = useRef(null); const [statistics, setStatistics] = useState([]); - const handleCapture = captureResult(ref); + const handleCapture = useCaptureResult(ref); const [isModalOpen, setIsModalOpen] = useState(true); const router = useRouter(); const pathname = usePathname(); diff --git a/src/app/(test)/test/result/page.tsx b/src/app/(test)/test/result/page.tsx index d845cc5..9ca13a3 100644 --- a/src/app/(test)/test/result/page.tsx +++ b/src/app/(test)/test/result/page.tsx @@ -4,7 +4,7 @@ import CaptureArea from '@/components/test/result/CaptureArea'; import { useRef, useEffect, useState } from 'react'; import positionDetails from '@/data/positionDetails'; import { TPositionStatisticProps } from '@/types'; -import captureResult from '@/utils/captureResult'; +import useCaptureResult from '@/utils/useCaptureResult'; import dynamic from 'next/dynamic'; const Button = dynamic(() => import('@/components/test/Button'), { @@ -21,7 +21,7 @@ const TestShare = dynamic(() => import('@/components/test/result/TestShare'), { const Page: React.FC = () => { const ref = useRef(null); const [statistics, setStatistics] = useState([]); - const handleCapture = captureResult(ref); + const handleCapture = useCaptureResult(ref); useEffect(() => { const fetchStatistics = async () => { diff --git a/src/components/player/PlayerData.tsx b/src/components/player/PlayerData.tsx index 7b23594..0448b54 100644 --- a/src/components/player/PlayerData.tsx +++ b/src/components/player/PlayerData.tsx @@ -1,10 +1,8 @@ -'use client'; - 'use client'; import React, { useState } from 'react'; import { IPlayerBack } from '@/types'; -import { MdOutlineArrowRight } from 'react-icons/md'; +// import { MdOutlineArrowRight } from 'react-icons/md'; interface PlayerData { player: IPlayerBack | null; @@ -23,9 +21,9 @@ export default function PlayerData({ player }: PlayerData) { className="h-8 w-fit mx-2 flex flex-row" onClick={onDetailHandler} > - + /> */}
선수 기록 상세보기
{playerBackNum}
diff --git a/src/components/test/ModalTestWrapper.tsx b/src/components/test/ModalTestWrapper.tsx index 942aaae..317acfa 100644 --- a/src/components/test/ModalTestWrapper.tsx +++ b/src/components/test/ModalTestWrapper.tsx @@ -1,6 +1,6 @@ 'use client'; -import React, { useCallback, useState } from 'react'; +import React from 'react'; export default function ModalTestWrapper({ children, diff --git a/src/utils/captureResult.ts b/src/utils/useCaptureResult.ts similarity index 84% rename from src/utils/captureResult.ts rename to src/utils/useCaptureResult.ts index 592fcfe..b6abcee 100644 --- a/src/utils/captureResult.ts +++ b/src/utils/useCaptureResult.ts @@ -1,7 +1,7 @@ import { useCallback, RefObject } from 'react'; import { toPng } from 'html-to-image'; -const captureResult = (ref: RefObject) => { +const useCaptureResult = (ref: RefObject) => { const handleCapture = useCallback(() => { if (ref.current === null) { return; @@ -22,4 +22,4 @@ const captureResult = (ref: RefObject) => { return handleCapture; }; -export default captureResult; +export default useCaptureResult;