From 115e97aeed128be97021dca02c5391dfe9f35466 Mon Sep 17 00:00:00 2001 From: cozy-ito Date: Thu, 8 May 2025 13:33:12 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=EC=8B=A0=EC=B2=AD=EC=9E=90=20?= =?UTF-8?q?=EC=9E=88=EC=9C=BC=EB=A9=B4=20=EA=B3=B5=EA=B3=A0=20=ED=8E=B8?= =?UTF-8?q?=EC=A7=91=20=EB=B6=88=EA=B0=80=EB=8A=A5=20=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NoticeDetailInfo/NoticeDetailInfo.tsx | 8 +++-- .../NoticeEmployerActionButton.tsx | 16 ++++++---- .../NoticeEmployeePage/NoticeEmployeePage.tsx | 2 +- .../NoticeEmployerPage/NoticeEmployerPage.tsx | 22 ++++++++++--- .../NoticeApplicationTableContainer.tsx | 32 ------------------- .../hooks/useShopApplications.ts | 7 +++- 6 files changed, 38 insertions(+), 49 deletions(-) delete mode 100644 src/pages/NoticeEmployerPage/components/NoticeApplicationTableContainer.tsx diff --git a/src/components/NoticeDetailInfo/NoticeDetailInfo.tsx b/src/components/NoticeDetailInfo/NoticeDetailInfo.tsx index 0c172a9..b8013b0 100644 --- a/src/components/NoticeDetailInfo/NoticeDetailInfo.tsx +++ b/src/components/NoticeDetailInfo/NoticeDetailInfo.tsx @@ -14,6 +14,7 @@ interface NoticeDetailInfoCardProps { noticeId: string; user?: User | null; isEmployerPage?: boolean; + isStartApplication?: boolean; } function NoticeDetailInfoCard({ @@ -22,6 +23,7 @@ function NoticeDetailInfoCard({ noticeInfo, user, isEmployerPage, + isStartApplication = false, }: NoticeDetailInfoCardProps) { const { hourlyPay, @@ -42,7 +44,7 @@ function NoticeDetailInfoCard({ const applicationId = currentUserApplication?.item.id ?? ""; const applicationStatus = currentUserApplication?.item.status; - const isPast = isPastDate(startsAt, workhour); + const isPast = isPastDate(startsAt); const isDisabledNotice = isPast || closed || @@ -71,9 +73,9 @@ function NoticeDetailInfoCard({ buttons={ isEmployerPage ? ( ) : ( { navigate(`/notice/edit/${noticeId}`); @@ -26,9 +25,12 @@ function NoticeEmployerActionButton({ variant="white" className={"py-[14px]"} onClick={moveToEditNoticePage} - disabled={!isMyShop} + disabled={!isMyShop || isStartApplication} > - {isMyShop ? "공고 편집하기" : "다른 가게의 공고 편집 불가"} + {isMyShop && !isStartApplication + ? "공고 편집하기" + : "이미 지원이 시작된 공고입니다."} + {!isMyShop && "다른 가게의 공고 편집 불가"} ); } diff --git a/src/pages/NoticeEmployeePage/NoticeEmployeePage.tsx b/src/pages/NoticeEmployeePage/NoticeEmployeePage.tsx index 1dcb3c1..64954e2 100644 --- a/src/pages/NoticeEmployeePage/NoticeEmployeePage.tsx +++ b/src/pages/NoticeEmployeePage/NoticeEmployeePage.tsx @@ -37,7 +37,7 @@ export default function NoticeEmployeePage() {

최근에 본 공고

- {recentNotices.length > 0 ? ( + {recentNotices?.length > 0 ? ( ) : (
diff --git a/src/pages/NoticeEmployerPage/NoticeEmployerPage.tsx b/src/pages/NoticeEmployerPage/NoticeEmployerPage.tsx index 9c2d6e0..72e52b0 100644 --- a/src/pages/NoticeEmployerPage/NoticeEmployerPage.tsx +++ b/src/pages/NoticeEmployerPage/NoticeEmployerPage.tsx @@ -2,7 +2,8 @@ import { useLoaderData, useParams } from "react-router-dom"; import NoticeDetailInfo from "../../components/NoticeDetailInfo/NoticeDetailInfo"; -import NoticeApplicationTableContainer from "./components/NoticeApplicationTableContainer"; +import NoticeApplicationTable from "./components/NoticeApplicationTable"; +import useShopApplications from "./hooks/useShopApplications"; import PostList, { PostData } from "@/components/Post/PostList"; import useUpdateRecentNotices from "@/hooks/useUpdateRecentNotices"; @@ -19,6 +20,15 @@ export default function NoticeEmployerPage() { noticeId: string; }; const { user } = useUserStore(); + const { + refetch: refetchShopApplications, + shopApplications, + totalCount, + } = useShopApplications({ + shopId, + noticeId, + type: user?.type, + }); const isMyShop = user?.shopId === shopId; @@ -37,6 +47,7 @@ export default function NoticeEmployerPage() { noticeInfo={noticeInfo} user={user} isEmployerPage + isStartApplication={shopApplications?.length > 0} />
@@ -47,14 +58,15 @@ export default function NoticeEmployerPage() { {isMyShop ? "신청자 목록" : "최근에 본 공고"} {isMyShop && ( - )} {!isMyShop && - (recentNotices.length > 0 ? ( + (recentNotices?.length > 0 ? ( ) : (
diff --git a/src/pages/NoticeEmployerPage/components/NoticeApplicationTableContainer.tsx b/src/pages/NoticeEmployerPage/components/NoticeApplicationTableContainer.tsx deleted file mode 100644 index 4b3a14f..0000000 --- a/src/pages/NoticeEmployerPage/components/NoticeApplicationTableContainer.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import useShopApplications from "../hooks/useShopApplications"; - -import NoticeApplicationTable from "./NoticeApplicationTable"; - -interface NoticeApplicationTableContainerProps { - shopId: string; - noticeId: string; -} - -function NoticeApplicationTableContainer({ - shopId, - noticeId, -}: NoticeApplicationTableContainerProps) { - const { - refetch: refetchShopApplications, - shopApplications, - totalCount, - } = useShopApplications({ - shopId, - noticeId, - }); - - return ( - - ); -} - -export default NoticeApplicationTableContainer; diff --git a/src/pages/NoticeEmployerPage/hooks/useShopApplications.ts b/src/pages/NoticeEmployerPage/hooks/useShopApplications.ts index 2bde58c..8ede54c 100644 --- a/src/pages/NoticeEmployerPage/hooks/useShopApplications.ts +++ b/src/pages/NoticeEmployerPage/hooks/useShopApplications.ts @@ -4,8 +4,10 @@ import { useSearchParams } from "react-router-dom"; import { getShopApplications } from "@/apis/services/applicationService"; import { ApplicationItem } from "@/types/application"; +import { UserType } from "@/types/user"; interface UseShopApplicationsParams { + type?: UserType; shopId: string; noticeId: string; offset?: number; @@ -13,6 +15,7 @@ interface UseShopApplicationsParams { } const useShopApplications = ({ + type, shopId, noticeId, offset = 5, @@ -45,7 +48,9 @@ const useShopApplications = ({ }; useEffect(() => { - fetchShopApplication(); + if (type === "employer") { + fetchShopApplication(); + } }, [shopId, noticeId, offset, limit, page]); return { From d5ba4ad392dab50c604782ea096cb9333f5e28a9 Mon Sep 17 00:00:00 2001 From: cozy-ito Date: Thu, 8 May 2025 14:04:04 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=EC=83=81=ED=83=9C=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=A5=B8=20=EA=B3=B5=EA=B3=A0=20=ED=8E=B8=EC=A7=91=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=20=EB=AC=B8=EA=B5=AC=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NoticeDetailInfo/NoticeDetailInfo.tsx | 4 ++- .../NoticeEmployerActionButton.tsx | 31 +++++++++++++++---- .../hooks/useShopApplications.ts | 2 +- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/components/NoticeDetailInfo/NoticeDetailInfo.tsx b/src/components/NoticeDetailInfo/NoticeDetailInfo.tsx index b8013b0..78a1ada 100644 --- a/src/components/NoticeDetailInfo/NoticeDetailInfo.tsx +++ b/src/components/NoticeDetailInfo/NoticeDetailInfo.tsx @@ -73,9 +73,11 @@ function NoticeDetailInfoCard({ buttons={ isEmployerPage ? ( ) : ( { - navigate(`/notice/edit/${noticeId}`); + if (isMyShop && !isPastNotice && isClosed && !isStartApplication) { + navigate(`/notice/edit/${noticeId}`); + } }; return ( @@ -25,12 +47,9 @@ function NoticeEmployerActionButton({ variant="white" className={"py-[14px]"} onClick={moveToEditNoticePage} - disabled={!isMyShop || isStartApplication} + disabled={isDisabled} > - {isMyShop && !isStartApplication - ? "공고 편집하기" - : "이미 지원이 시작된 공고입니다."} - {!isMyShop && "다른 가게의 공고 편집 불가"} + {buttonText} ); } diff --git a/src/pages/NoticeEmployerPage/hooks/useShopApplications.ts b/src/pages/NoticeEmployerPage/hooks/useShopApplications.ts index 8ede54c..9bac752 100644 --- a/src/pages/NoticeEmployerPage/hooks/useShopApplications.ts +++ b/src/pages/NoticeEmployerPage/hooks/useShopApplications.ts @@ -51,7 +51,7 @@ const useShopApplications = ({ if (type === "employer") { fetchShopApplication(); } - }, [shopId, noticeId, offset, limit, page]); + }, [type, shopId, noticeId, offset, limit, page]); return { refetch: fetchShopApplication, From a212b98ca9f58b7c6dfd1e48a6c75f9d1942bc7c Mon Sep 17 00:00:00 2001 From: cozy-ito Date: Thu, 8 May 2025 14:04:30 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=EC=B5=9C=EA=B7=BC=20=EB=B3=B8=20?= =?UTF-8?q?=EA=B3=B5=EA=B3=A0=20=EB=AA=A9=EB=A1=9D=20userType=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=9D=BC=20=EB=A7=81=ED=81=AC=EB=8F=84=20=EB=94=B0?= =?UTF-8?q?=EB=9D=BC=20=EB=B3=80=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/loaders/notice.ts | 11 ++++++++++- .../NoticeEmployeePage/loader/noticeEmployeeLoader.ts | 4 +++- .../NoticeEmployerPage/loader/noticeEmployerLoader.ts | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/apis/loaders/notice.ts b/src/apis/loaders/notice.ts index c09b4ab..ff6868e 100644 --- a/src/apis/loaders/notice.ts +++ b/src/apis/loaders/notice.ts @@ -2,6 +2,7 @@ import { getShopApplications } from "../services/applicationService"; import { getNotice } from "../services/noticeService"; import { PostData } from "@/components/Post/PostList"; +import { UserType } from "@/types/user"; import { getLocalStorageValue } from "@/utils/localStorage"; interface LoadNoticeParams { @@ -19,12 +20,20 @@ export const loadNotice = async ({ shopId, noticeId }: LoadNoticeParams) => { const MAX_VISIBLE_RECENT_NOTICES = 6; -export const loadRecentNotices = (noticeId: string) => { +export const loadRecentNotices = (noticeId: string, userType?: UserType) => { const allRecentNotices = getLocalStorageValue("recentNotices") ?? []; const recentNotices = allRecentNotices .filter(({ id }) => id !== noticeId) + .map(({ link, ...restNoticeInfo }) => { + const type = userType ?? "employee"; + const splittedLink = link.split("/"); + splittedLink[splittedLink.length - 1] = type; + + const updatedLink = splittedLink.join("/"); + return { link: updatedLink, ...restNoticeInfo }; + }) .slice(0, MAX_VISIBLE_RECENT_NOTICES); return recentNotices; diff --git a/src/pages/NoticeEmployeePage/loader/noticeEmployeeLoader.ts b/src/pages/NoticeEmployeePage/loader/noticeEmployeeLoader.ts index 3409d5e..17351ce 100644 --- a/src/pages/NoticeEmployeePage/loader/noticeEmployeeLoader.ts +++ b/src/pages/NoticeEmployeePage/loader/noticeEmployeeLoader.ts @@ -1,15 +1,17 @@ import { LoaderFunction } from "react-router-dom"; import { loadNotice, loadRecentNotices } from "@/apis/loaders/notice"; +import { useUserStore } from "@/hooks/useUserStore"; const noticeEmployeeLoader: LoaderFunction = async ({ params }) => { + const user = useUserStore.getState().user; const { shopId, noticeId } = params as { shopId: string; noticeId: string; }; const noticeInfo = await loadNotice({ shopId, noticeId }); - const recentNotices = loadRecentNotices(noticeId); + const recentNotices = loadRecentNotices(noticeId, user?.type); return { noticeInfo, recentNotices }; }; diff --git a/src/pages/NoticeEmployerPage/loader/noticeEmployerLoader.ts b/src/pages/NoticeEmployerPage/loader/noticeEmployerLoader.ts index ec8cb36..95d4b90 100644 --- a/src/pages/NoticeEmployerPage/loader/noticeEmployerLoader.ts +++ b/src/pages/NoticeEmployerPage/loader/noticeEmployerLoader.ts @@ -16,7 +16,7 @@ const noticeEmployerLoader: LoaderFunction = async ({ params }) => { return { noticeInfo }; } - const recentNotices = loadRecentNotices(noticeId); + const recentNotices = loadRecentNotices(noticeId, user?.type); return { noticeInfo, recentNotices }; };