-
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.
fix: update funding progress toast section
- Loading branch information
1 parent
2da5efa
commit 1c4edd6
Showing
6 changed files
with
113 additions
and
56 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
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
69 changes: 69 additions & 0 deletions
69
packages/web/src/features/manage-club/funding/detail/components/FundingStatusSection.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,69 @@ | ||
import React, { useMemo } from "react"; | ||
|
||
import { IFundingCommentResponse } from "@sparcs-clubs/interface/api/funding/type/funding.type"; | ||
import { FundingStatusEnum } from "@sparcs-clubs/interface/common/enum/funding.enum"; | ||
|
||
import ApproveReasonToast from "@sparcs-clubs/web/common/components/ApproveReasonToast"; | ||
import ProgressStatus from "@sparcs-clubs/web/common/components/ProgressStatus"; | ||
|
||
import RejectReasonToast from "@sparcs-clubs/web/common/components/RejectReasonToast"; | ||
|
||
import { FundingTagList } from "@sparcs-clubs/web/constants/tableTagList"; | ||
import { getFundingProgress } from "@sparcs-clubs/web/features/manage-club/funding/constants/fundingProgressStatus"; | ||
import { getTagDetail } from "@sparcs-clubs/web/utils/getTagDetail"; | ||
|
||
interface FundingStatusSectionProps { | ||
status: FundingStatusEnum; | ||
editedAt: Date; | ||
commentedAt?: Date; | ||
comments: IFundingCommentResponse[]; | ||
} | ||
|
||
const FundingStatusSection: React.FC<FundingStatusSectionProps> = ({ | ||
status, | ||
editedAt, | ||
commentedAt = undefined, | ||
comments, | ||
}) => { | ||
const progressStatus = getFundingProgress(status, editedAt, commentedAt); | ||
|
||
const ToastSection = useMemo(() => { | ||
if (status === FundingStatusEnum.Rejected) { | ||
return ( | ||
<RejectReasonToast | ||
title="코멘트" | ||
reasons={comments.map(comment => ({ | ||
datetime: comment.createdAt, | ||
reason: comment.content, | ||
status: getTagDetail(comment.fundingStatusEnum, FundingTagList) | ||
.text, | ||
}))} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<ApproveReasonToast | ||
title="코멘트" | ||
reasons={comments.map(comment => ({ | ||
datetime: comment.createdAt, | ||
reason: comment.content, | ||
status: | ||
comment.fundingStatusEnum === FundingStatusEnum.Partial | ||
? `${getTagDetail(comment.fundingStatusEnum, FundingTagList).text}승인` | ||
: getTagDetail(comment.fundingStatusEnum, FundingTagList).text, | ||
}))} | ||
/> | ||
); | ||
}, [comments, status]); | ||
|
||
return ( | ||
<ProgressStatus | ||
labels={progressStatus.labels} | ||
progress={progressStatus.progress} | ||
optional={comments && comments.length > 0 && ToastSection} | ||
/> | ||
); | ||
}; | ||
|
||
export default FundingStatusSection; |
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