From 7921df64b1362e2e379041979bfe59ba29479e19 Mon Sep 17 00:00:00 2001 From: JangAyeon <67853616+JangAyeon@users.noreply.github.com> Date: Tue, 27 Feb 2024 06:47:13 +0900 Subject: [PATCH] feat: island item no exist State Modal --- components/molecules/LandEdit.tsx | 25 ++++++++++++++++++++++++- components/molecules/LandItem.tsx | 27 ++++++++++++--------------- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/components/molecules/LandEdit.tsx b/components/molecules/LandEdit.tsx index 41b97e1..7d155b2 100644 --- a/components/molecules/LandEdit.tsx +++ b/components/molecules/LandEdit.tsx @@ -1,10 +1,14 @@ import styled from "@emotion/styled" -import { Dispatch, SetStateAction } from "react" +import { Dispatch, SetStateAction, useEffect } from "react" +import AuthModal from "@/components/modal/AuthModal" import LandCategory from "@/components/molecules/LandCategory" import LandItem from "@/components/molecules/LandItem" import LandType from "@/components/molecules/LandType" +import useIsland from "@/hooks/useIsland" +import useStateModal from "@/hooks/useStateModal" + import { ICategory } from "@/types/categoryTabs" interface ILandEdit { @@ -14,8 +18,27 @@ interface ILandEdit { } const LandEdit = ({ list, setCategory, category }: ILandEdit) => { + const { islandItemExist } = useIsland() + const { state, text, isOpen, setIsOpen, setStateModal } = useStateModal() + useEffect(() => { + if (islandItemExist.length === 0) { + setStateModal({ + state: "fail", + text: "카드 게임 플레이를 통해 아이템을 구하세요", + isOpen: true, + }) + } + }, [islandItemExist]) return ( + {text && isOpen && ( + setIsOpen(false)} + /> + )} {category === 0 ? : } diff --git a/components/molecules/LandItem.tsx b/components/molecules/LandItem.tsx index 94eb727..8878fdf 100644 --- a/components/molecules/LandItem.tsx +++ b/components/molecules/LandItem.tsx @@ -1,5 +1,4 @@ import styled from "@emotion/styled" -import { useEffect } from "react" import "swiper/css" import { Swiper, SwiperSlide } from "swiper/react" @@ -13,21 +12,19 @@ import { ItemIdProps } from "@/types/common/islandProps" const LandItem = () => { const { islandItemExist } = useIsland() const { swiperSetting, currentSlide } = useSwiper() - /* - useEffect(() => { - console.log("land item", list) - }, [list]) -*/ + return ( - - - {islandItemExist.map((id: ItemIdProps, idx: number) => ( - - - - ))} - - + <> + + + {islandItemExist.map((id: ItemIdProps, idx: number) => ( + + + + ))} + + + ) }