-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6705c75
commit b1ad4c8
Showing
11 changed files
with
459 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 31 additions & 86 deletions
117
packages/web/src/app/manage-club/funding/[id]/edit/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
packages/web/src/features/manage-club/funding/frames/EditFundingFrame.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import React from "react"; | ||
|
||
import { useParams, useRouter } from "next/navigation"; | ||
|
||
import { overlay } from "overlay-kit"; | ||
|
||
import AsyncBoundary from "@sparcs-clubs/web/common/components/AsyncBoundary"; | ||
import FlexWrapper from "@sparcs-clubs/web/common/components/FlexWrapper"; | ||
import Modal from "@sparcs-clubs/web/common/components/Modal"; | ||
import ConfirmModalContent from "@sparcs-clubs/web/common/components/Modal/ConfirmModalContent"; | ||
import PageHead from "@sparcs-clubs/web/common/components/PageHead"; | ||
import Typography from "@sparcs-clubs/web/common/components/Typography"; | ||
|
||
import useGetInitialFundingFormData from "../hooks/useGetInitialFundingForm"; | ||
import useUpdateFunding from "../hooks/useUpdateFunding"; | ||
import { FundingFormData } from "../types/funding"; | ||
|
||
import FundingForm from "./FundingForm"; | ||
|
||
interface EditFundingFrameProps { | ||
clubId: number; | ||
} | ||
|
||
const EditFundingFrame: React.FC<EditFundingFrameProps> = ({ clubId }) => { | ||
const router = useRouter(); | ||
const { id: fundingId } = useParams<{ id: string }>(); | ||
const cancelClick = () => { | ||
router.push(`/manage-club/funding/${fundingId}`); | ||
}; | ||
|
||
const { | ||
data: funding, | ||
isLoading, | ||
isError, | ||
} = useGetInitialFundingFormData(+fundingId); | ||
|
||
const { mutateAsync: updateFunding } = useUpdateFunding(+fundingId, clubId); | ||
|
||
const handleSubmit = (data: FundingFormData) => { | ||
updateFunding(data, { | ||
onSuccess: () => { | ||
overlay.open(({ isOpen, close }) => ( | ||
<Modal isOpen={isOpen}> | ||
<ConfirmModalContent | ||
onConfirm={() => { | ||
close(); | ||
router.push(`/manage-club/funding/${fundingId}`); | ||
}} | ||
> | ||
수정이 완료되었습니다. <br /> | ||
확인을 누르면 신청 내역 화면으로 이동합니다. | ||
</ConfirmModalContent> | ||
</Modal> | ||
)); | ||
}, | ||
onError: error => { | ||
overlay.open(({ isOpen, close }) => ( | ||
<Modal isOpen={isOpen}> | ||
<ConfirmModalContent onConfirm={close}> | ||
지원금 수정에 실패했습니다. | ||
<Typography color="GRAY.300" fs={12} lh={16} fw="REGULAR"> | ||
{error.message} | ||
</Typography> | ||
</ConfirmModalContent> | ||
</Modal> | ||
)); | ||
}, | ||
}); | ||
}; | ||
|
||
return ( | ||
<FlexWrapper direction="column" gap={60}> | ||
<PageHead | ||
items={[ | ||
{ name: "대표 동아리 관리", path: "/manage-club" }, | ||
{ name: "지원금", path: "/manage-club/funding" }, | ||
]} | ||
title="지원금 수정" | ||
enableLast | ||
/> | ||
<AsyncBoundary isLoading={isLoading} isError={isError}> | ||
<FundingForm | ||
onCancel={cancelClick} | ||
onSubmit={handleSubmit} | ||
initialData={funding ?? []} | ||
/> | ||
</AsyncBoundary> | ||
</FlexWrapper> | ||
); | ||
}; | ||
|
||
export default EditFundingFrame; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.