From 45d93479dd1cb81e006bfdef1aadd3679c39226e Mon Sep 17 00:00:00 2001 From: DeveloperRyou Date: Mon, 10 Jun 2024 22:53:46 +0900 Subject: [PATCH 1/3] =?UTF-8?q?FIX:=20=EC=A7=81=EC=9B=90=EC=B4=88=EB=8C=80?= =?UTF-8?q?=20=EB=A7=81=ED=81=AC=20=EB=B3=B5=EC=82=AC=EA=B8=B0=EB=8A=A5=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 --- src/pages/manage/confirm.tsx | 23 +++++------------------ src/screen/manage/ShareLink.tsx | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/pages/manage/confirm.tsx b/src/pages/manage/confirm.tsx index edec2e0..9aad33f 100644 --- a/src/pages/manage/confirm.tsx +++ b/src/pages/manage/confirm.tsx @@ -1,21 +1,10 @@ -import React, { useState } from "react"; -import { useRouter } from "next/router"; -import FlexBox from "@modules/layout/FlexBox"; -import TopTitle from "@modules/layout/TopTitle"; -import TextButton from "@modules/components/button/TextButton"; import ConfirmEmployee from "@/screen/manage/ConfirmEmployee"; import ShareLink from "@/screen/manage/ShareLink"; -import { InviteSchedule, inviteScheduleInit } from "@/data/inviteSchedule"; - -function setSelectedPostion(arg0: string) { - console.log(arg0); - throw new Error("Function not implemented."); -} - -function setInviteSchedule(inviteSchedule: InviteSchedule) { - console.log(inviteSchedule); - throw new Error("Function not implemented."); -} +import TextButton from "@modules/components/button/TextButton"; +import FlexBox from "@modules/layout/FlexBox"; +import TopTitle from "@modules/layout/TopTitle"; +import { useRouter } from "next/router"; +import { useState } from "react"; type View = "confirm" | "share"; @@ -28,8 +17,6 @@ export default function Home() { }; const handleShiftButton = () => { - setSelectedPostion(""); - setInviteSchedule(inviteScheduleInit); router.push("/manage"); }; diff --git a/src/screen/manage/ShareLink.tsx b/src/screen/manage/ShareLink.tsx index 8fb784f..4c579fc 100644 --- a/src/screen/manage/ShareLink.tsx +++ b/src/screen/manage/ShareLink.tsx @@ -21,14 +21,16 @@ interface InviteDataType { } function ShareLink() { + const [inviteId, setInviteId] = useState(""); const [linkCopied, setLinkCopied] = useState(false); const [inviteSchedule] = useAtom(inviteScheduleAtom); const [selectedPosition] = useAtom(selectedPositionAtom); const [storeId] = useAtom(storeIdAtom); - const inviteId = createRandomString(8); - const handleCopyLink = (id: string) => { - const link = `${window.location.origin}/id?=${id}`; + if (!inviteId) setInviteId(createRandomString(8)); + + const handleCopyLink = () => { + const link = `${window.location.origin}/?id=${inviteId}`; copy( link, () => { @@ -40,7 +42,7 @@ function ShareLink() { ); }; - const sendInviteToDB = async (id: string) => { + const sendInviteToDB = async () => { const inviteData: InviteDataType = { storeId, position: selectedPosition, @@ -48,19 +50,19 @@ function ShareLink() { createdAt: dayjs().format("YYYY-MM-DD HH:mm:ss"), }; const data = { - id, + id: inviteId, inviteData, }; try { await axios.post("/api/dynamoDB", data); - handleCopyLink(inviteId); + handleCopyLink(); } catch (error) { - console.error("Failed to create invite:", error); + alert("초대링크 생성에 실패했습니다."); } }; useEffect(() => { - sendInviteToDB(inviteId); + sendInviteToDB(); }, []); return ( @@ -84,7 +86,7 @@ function ShareLink() {
링크복사가 안되었나요?
-