From b2621129a73a9fb9274047cb859b96256d298295 Mon Sep 17 00:00:00 2001 From: MEGUMMY1 Date: Wed, 12 Jun 2024 21:59:48 +0900 Subject: [PATCH] =?UTF-8?q?design:=20Profile=20margin=20bottom=20=EC=A7=80?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- atoms/userAtom.ts | 2 +- components/Profile/Profile.module.scss | 3 ++- components/notice/CustomNoticeList/index.tsx | 13 ++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/atoms/userAtom.ts b/atoms/userAtom.ts index 55dcaeb..65fd8ca 100644 --- a/atoms/userAtom.ts +++ b/atoms/userAtom.ts @@ -12,7 +12,7 @@ interface AuthState { user: User | null; } -export const authState = atom({ +export const authState = atom({ key: "authState", default: { isAuthenticated: false, diff --git a/components/Profile/Profile.module.scss b/components/Profile/Profile.module.scss index b4bba0a..10c7f53 100644 --- a/components/Profile/Profile.module.scss +++ b/components/Profile/Profile.module.scss @@ -4,7 +4,7 @@ max-width: 964px; margin: 0 auto; padding: 60px 0; - height: 395px; + height: auto; @media (max-width: $TABLET) { padding: 60px 32px; @@ -38,6 +38,7 @@ justify-content: center; text-align: center; width: 100%; + margin-bottom: 30vh; @media (max-width: $MOBILE) { height: 195px; diff --git a/components/notice/CustomNoticeList/index.tsx b/components/notice/CustomNoticeList/index.tsx index ae1ed69..97ef424 100644 --- a/components/notice/CustomNoticeList/index.tsx +++ b/components/notice/CustomNoticeList/index.tsx @@ -11,6 +11,7 @@ import { calculateIncreasePercent } from "@/utils/calculateIncreasePercent"; import Link from "next/link"; import { useRecoilValue } from "recoil"; import { profileAtom } from "@/atoms/profileAtom"; +import { authState, signupState } from "@/atoms/userAtom"; const cx = classNames.bind(styles); @@ -22,6 +23,8 @@ const CustomNoticeList = () => { const [postsPerPage, setPostsPerPage] = useState(3); const isTablet = useResize(TABLET); const userData = useRecoilValue(profileAtom); + const auth = useRecoilValue(authState); + const sign = useRecoilValue(signupState); const userAddress = userData.area; useEffect(() => { @@ -50,8 +53,12 @@ const CustomNoticeList = () => { useEffect(() => { const loadNotices = async () => { try { - //const data = await fetchNoticesByAddress(userAddress); 지역 선별 개선 필요 - const data = await fetchNoticeList(); + let data = []; + if (auth.isAuthenticated && sign.type === "employee") { + data = await fetchNoticesByAddress(userAddress); + } else { + data = await fetchNoticeList(); + } setNotices(data); setLoading(false); } catch (err) { @@ -61,7 +68,7 @@ const CustomNoticeList = () => { }; loadNotices(); - }, [userAddress]); + }, [auth, userAddress]); if (loading) { return ;