Skip to content

Commit

Permalink
✨ Feat(#315): 대기 조건일때만 수정 가능하게 기능 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
JIY00N2 committed Dec 2, 2023
1 parent 8fa138b commit 39a3d4c
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
"use client";

import { usePathname, useRouter } from "next/navigation";
import { Question, Title } from "@/components/application";
import { useSuspenseQuery } from "@tanstack/react-query";
import getApplicationDetails from "@/services/application/getApplicationDetails";
import getSteadyDetails from "@/services/steady/getSteadyDetails";
import Button, { buttonSize } from "@/components/_common/Button";
import useApplicationListQuery from "@/hooks/query/useApplicationListQuery";
import {
getApplicationDetailsKey,
getSteadyDetailsKey,
} from "@/constants/queryKeys";

const ApplicationPage = ({
params,
}: {
params: { steady_id: string; application_id: string };
}) => {
const applicationId = params.application_id;
const steadyId = params.steady_id;
const pathname = usePathname();
const pageType = pathname.split("/")[2];
const router = useRouter();
const { data: applicationData } = useSuspenseQuery({
queryKey: getApplicationDetailsKey(applicationId),
queryFn: () => getApplicationDetails(applicationId),
});

const { data: steadyDetailsData } = useSuspenseQuery({
queryKey: getSteadyDetailsKey(steadyId),
queryFn: () => getSteadyDetails(steadyId),
staleTime: 10000,
});

const { applicationListData } = useApplicationListQuery();

const application = applicationListData.pages.map(
(page) =>
page.content.find(
(item) => item.applicationId.toString() === applicationId,
)?.status,
)[0];

return (
<>
<Title
title={steadyDetailsData ? steadyDetailsData.name : "Temp"}
pageType={pageType}
>
{applicationData.surveys.map((survey, index) => (
<Question
key={index}
question={survey.question}
index={index}
>
<div className="h-100 w-full border-1">{survey.answer}</div>
</Question>
))}
</Title>
{application === "WAITING" && (
<div className="flex items-center justify-end">
<Button
className={`${buttonSize.sm} bg-st-primary text-st-white`}
onClick={() =>
router.push(`/application/edit/${steadyId}/${applicationId}`)
}
>
수정 하기
</Button>
</div>
)}
</>
);
};

export default ApplicationPage;
2 changes: 1 addition & 1 deletion src/app/(user-menu)/mypage/application/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const MyApplicationPage = () => {
useApplicationListQuery();

const handleApplicationDetail = (steadyId: number, applicationId: number) => {
router.push(`/application/edit/${steadyId}/${applicationId}`);
router.push(`/application/${steadyId}/${applicationId}`);
};

const handleDeleteApplication = async (id: string) => {
Expand Down

0 comments on commit 39a3d4c

Please sign in to comment.