From 8fd004c9948dc8a6c42fcd7d993e71ba786435af Mon Sep 17 00:00:00 2001 From: leve68 Date: Fri, 23 Aug 2024 18:34:36 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20event2=20=EC=9D=B4=EB=AF=B8=20?= =?UTF-8?q?=EC=B0=B8=EC=97=AC=ED=95=9C=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=ED=94=BC=EB=93=9C=EB=B0=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/share.html | 19 ++++++++++++------- src/client/constants/common.ts | 1 + .../RandomMainSection/RandomMainSection.tsx | 13 ++++++++----- src/client/types/RandomEvent.ts | 1 + 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/public/share.html b/public/share.html index 27dcd98..c755c85 100644 --- a/public/share.html +++ b/public/share.html @@ -179,20 +179,25 @@ const uid = urlParams.get("UID"); try { - await fetch(`lots/link&UID=${uid}`); + await fetch( + `https://d1zb0qi5v6qyks.cloudfront.net/lots/link&UID=${uid}`, + ); } catch (error) { console.error("Error posting answers:", error); return null; } try { - const response = await fetch("/lots/typeId", { - method: "POST", - headers: { - "Content-Type": "application/json", + const response = await fetch( + "https://d1zb0qi5v6qyks.cloudfront.net/lots/typeId", + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ resultTypeId: id }), }, - body: JSON.stringify({ resultTypeId: id }), - }); + ); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); diff --git a/src/client/constants/common.ts b/src/client/constants/common.ts index 421d3a5..e0d2ebe 100644 --- a/src/client/constants/common.ts +++ b/src/client/constants/common.ts @@ -9,4 +9,5 @@ export const LONG_BUTTON_TEXT = { NO_AUTH: "본인인증하고 이벤트 참여하기", EVENT_END: "이벤트 참여 완료", START_EVENT: "이벤트 참여하기", + ALREADY_END: "이미 참여하셨습니다", }; diff --git a/src/client/pages/randomEventResultPage/RandomMainSection/RandomMainSection.tsx b/src/client/pages/randomEventResultPage/RandomMainSection/RandomMainSection.tsx index e9381b0..c0af175 100644 --- a/src/client/pages/randomEventResultPage/RandomMainSection/RandomMainSection.tsx +++ b/src/client/pages/randomEventResultPage/RandomMainSection/RandomMainSection.tsx @@ -26,6 +26,7 @@ const RandomMainSection = ({ const [isCopied, setIsCopied] = useState(false); const [shareUrl, setShareUrl] = useState("https://www.hyundaiseltos.site/"); + const [isAlreadyEnd, setIsAlreadyEnd] = useState(false); const handleRetry = () => { navigate("/event2/0"); @@ -37,6 +38,8 @@ const RandomMainSection = ({ console.log("getURL"); const { result } = await postRandomResult(resultTypeId); setShareUrl(result.uniqueLink); + console.log("setState"); + if (!result.applied) setIsAlreadyEnd(true); } catch (error) { if (error instanceof Error) { if (error.message === "Failed to fetch") return; @@ -64,10 +67,6 @@ const RandomMainSection = ({ } }; - useEffect(() => { - getUniqueUrl(); - }, [isAuth]); - const setText = () => { if (isAuth === false) return LONG_BUTTON_TEXT.NO_AUTH; if (isRandomEnd === true) return LONG_BUTTON_TEXT.EVENT_END; @@ -134,7 +133,11 @@ const RandomMainSection = ({ size="long" onClick={handleEventParticipation} defaultText={setText()} - disabledText={LONG_BUTTON_TEXT.EVENT_END} + disabledText={ + isAlreadyEnd + ? LONG_BUTTON_TEXT.ALREADY_END + : LONG_BUTTON_TEXT.EVENT_END + } isEnabled={!isAuth || !isRandomEnd} /> diff --git a/src/client/types/RandomEvent.ts b/src/client/types/RandomEvent.ts index b031f5e..24985a1 100644 --- a/src/client/types/RandomEvent.ts +++ b/src/client/types/RandomEvent.ts @@ -78,6 +78,7 @@ export interface ScenarioInterface { export interface SharedLinkInterface { uniqueLink: string; + applied: boolean; } export interface TooltipInterface { From d51970ccab6db5612c9d9f236e45cb3d831e7efd Mon Sep 17 00:00:00 2001 From: leve68 Date: Fri, 23 Aug 2024 18:35:40 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=EA=B8=B0=EB=8C=80=ED=8F=89=20?= =?UTF-8?q?=EA=B8=80=EC=9E=90=EC=88=98=20=EC=A0=9C=ED=95=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RandomExpectations/RandomExpectations.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/pages/randomEventResultPage/RandomExpectations/RandomExpectations.tsx b/src/client/pages/randomEventResultPage/RandomExpectations/RandomExpectations.tsx index d5f8153..e6bf1e1 100644 --- a/src/client/pages/randomEventResultPage/RandomExpectations/RandomExpectations.tsx +++ b/src/client/pages/randomEventResultPage/RandomExpectations/RandomExpectations.tsx @@ -44,6 +44,7 @@ const RandomExpectations = forwardRef((props, ref) => { onChange={handleTextArea} value={expectation} placeholder="최소 20자 이상 입력하세요." + maxLength={200} className="ml-8 h-[12.25rem] w-[77.25rem] resize-none border-none bg-gray-950 text-gray-50 outline-none" > {error && ( ((props, ref) => { /> )} +
+ {error === "success" && ( + <> +

+ 작성한 기대평은 워드 클라우드에 반영됩니다 +

+ + + )} +
); });