-
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.
Merge pull request #1403 from academic-relations/1402-add-partial-app…
…rove-toast-in-funding-page add partial approve related logic in funding detail frame
- Loading branch information
Showing
10 changed files
with
333 additions
and
65 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
packages/web/src/common/components/ApproveReasonToast.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,107 @@ | ||
import React from "react"; | ||
|
||
import styled from "styled-components"; | ||
|
||
import colors from "@sparcs-clubs/web/styles/themes/colors"; | ||
import { formatDotDetailDate } from "@sparcs-clubs/web/utils/Date/formatDate"; | ||
|
||
import FlexWrapper from "./FlexWrapper"; | ||
import Icon from "./Icon"; | ||
|
||
import Typography from "./Typography"; | ||
|
||
interface Reason { | ||
datetime: Date; | ||
reason: React.ReactNode; | ||
status?: string; | ||
} | ||
|
||
interface ApproveReasonToastProps { | ||
title: string; | ||
reasons: Reason[]; | ||
} | ||
|
||
const ForceBorderRadius = styled.div` | ||
position: sticky; | ||
top: 0px; | ||
border-radius: 8px; | ||
width: 100%; | ||
overflow: hidden; | ||
border: 1px solid ${({ theme }) => theme.colors.GREEN[600]}; | ||
background: ${({ theme }) => theme.colors.GREEN[100]}; | ||
z-index: ${({ theme }) => theme.zIndices.toast}; | ||
`; | ||
|
||
const ApproveReasonToastInner = styled.div` | ||
color: ${({ theme }) => theme.colors.BLACK}; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
gap: 8px; | ||
width: 100%; | ||
max-height: 300px; | ||
overflow-y: auto; | ||
.ApproveReasonToast-title { | ||
padding: 12px 16px 0 16px; | ||
position: sticky; | ||
top: 0; | ||
display: flex; | ||
align-items: center; | ||
gap: 8px; | ||
background: ${({ theme }) => theme.colors.GREEN[100]}; | ||
z-index: ${({ theme }) => theme.zIndices.toast + 1}; | ||
} | ||
.ApproveReasonToast-reasons { | ||
display: flex; | ||
width: 100%; | ||
padding: 0 16px 12px 44px; | ||
flex-direction: column; | ||
gap: 8px; | ||
flex: 1 0 0; | ||
} | ||
.ApproveReasonToast-sticky-title { | ||
position: sticky; | ||
top: 0; | ||
background: ${({ theme }) => theme.colors.GREEN[100]}; | ||
z-index: ${({ theme }) => theme.zIndices.toast + 1}; | ||
} | ||
`; | ||
|
||
const ApproveReasonToast: React.FC<ApproveReasonToastProps> = ({ | ||
title, | ||
reasons, | ||
}) => ( | ||
<ForceBorderRadius> | ||
<ApproveReasonToastInner> | ||
<div className="ApproveReasonToast-title"> | ||
<Icon type="error" size={20} color={colors.GREEN[600]} /> | ||
<Typography fs={16} lh={24} fw="MEDIUM"> | ||
{title} | ||
</Typography> | ||
</div> | ||
<div className="ApproveReasonToast-reasons"> | ||
{reasons.map(reason => ( | ||
<FlexWrapper | ||
direction="column" | ||
gap={4} | ||
key={formatDotDetailDate(reason.datetime)} | ||
> | ||
<Typography fs={14} lh={16} fw="REGULAR" color="GRAY.600"> | ||
{formatDotDetailDate(reason.datetime)}{" "} | ||
{reason.status && `• ${reason.status}`} | ||
</Typography> | ||
<Typography fs={16} lh={24} fw="REGULAR"> | ||
{reason.reason} | ||
</Typography> | ||
</FlexWrapper> | ||
))} | ||
</div> | ||
</ApproveReasonToastInner> | ||
</ForceBorderRadius> | ||
); | ||
|
||
export default ApproveReasonToast; |
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
Oops, something went wrong.