1- import { Button , ErrorBox , Modal } from "@components/common" ;
1+ import { Button , ErrorBox , Modal , Toast } from "@components/common" ;
22import {
33 EntranceInput ,
44 TimetableInfo ,
@@ -9,6 +9,7 @@ import styled from "@emotion/styled";
99import useEventsStore from "@hooks/useEventsStore" ;
1010import useUrlEventId from "@hooks/useUrlEventId" ;
1111import { closePage } from "@lib/handleCrossPlatform" ;
12+ import useToast from "@lib/hooks/useToast" ;
1213import type { NextPageWithLayout } from "@pages/_app" ;
1314import Link from "next/link" ;
1415import { useEffect , useState } from "react" ;
@@ -18,6 +19,7 @@ const getLocalStorageKey = (id: string) => {
1819
1920const Events : NextPageWithLayout = ( ) => {
2021 const [ windowHeight , setWindowHeight ] = useState < number > ( 0 ) ;
22+ const { isToastOpen, toggleToast } = useToast ( ) ;
2123 useEffect ( ( ) => {
2224 const resizeHandlerForFixedHeight = ( ) => {
2325 if ( window !== undefined ) {
@@ -60,20 +62,19 @@ const Events: NextPageWithLayout = () => {
6062 if ( window !== undefined ) {
6163 window . localStorage . setItem ( getLocalStorageKey ( id ) , name ) ;
6264 }
63- //TODO 모달 활용해서 알림해주기
65+ toggleToast ( ) ;
6466 return "" ;
6567 } ;
6668
6769 useEffect ( ( ) => {
6870 if ( window === undefined || ! id ) return ;
69- const userName = window . localStorage . getItem ( getLocalStorageKey ( id ) ) ;
70- setCurrentAttendee (
71- window . localStorage . getItem ( getLocalStorageKey ( id ) ) || ""
72- ) ;
73- if ( userName ) {
74- //TODO 모달 활용해서 알림해주기
71+ const previousAttendee =
72+ window . localStorage . getItem ( getLocalStorageKey ( id ) ) || "" ;
73+ if ( previousAttendee ) {
74+ setCurrentAttendee ( previousAttendee ) ;
75+ toggleToast ( ) ;
7576 }
76- } , [ id ] ) ;
77+ } , [ id , toggleToast ] ) ;
7778
7879 if ( status === "idle" || status === "loading" ) {
7980 return (
@@ -107,6 +108,9 @@ const Events: NextPageWithLayout = () => {
107108 < EntranceInput onClickEntrance = { handleClickEntrance } />
108109 </ Modal >
109110 ) }
111+ { isToastOpen && (
112+ < Toast message = { `${ currentAttendee } 님이 입장하셨습니다.` } />
113+ ) }
110114 < Container >
111115 < Header >
112116 < Text > 가능한 시간을 입력하세요!</ Text >
0 commit comments