Skip to content

Commit

Permalink
fix: update funding progress toast section
Browse files Browse the repository at this point in the history
  • Loading branch information
jooyeongmee committed Jan 30, 2025
1 parent 2da5efa commit 1c4edd6
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import Typography from "./Typography";
interface Reason {
datetime: Date;
reason: React.ReactNode;
status?: string;
}

interface PartialApproveReasonToastProps {
interface ApproveReasonToastProps {
title: string;
reasons: Reason[];
}
Expand All @@ -31,7 +32,7 @@ const ForceBorderRadius = styled.div`
z-index: ${({ theme }) => theme.zIndices.toast};
`;

const PartialApproveReasonToastInner = styled.div`
const ApproveReasonToastInner = styled.div`
color: ${({ theme }) => theme.colors.BLACK};
display: flex;
flex-direction: column;
Expand All @@ -41,7 +42,7 @@ const PartialApproveReasonToastInner = styled.div`
max-height: 300px;
overflow-y: auto;
.PartialApproveReasonToast-title {
.ApproveReasonToast-title {
padding: 12px 16px 0 16px;
position: sticky;
Expand All @@ -53,7 +54,7 @@ const PartialApproveReasonToastInner = styled.div`
z-index: ${({ theme }) => theme.zIndices.toast + 1};
}
.PartialApproveReasonToast-reasons {
.ApproveReasonToast-reasons {
display: flex;
width: 100%;
padding: 0 16px 12px 44px;
Expand All @@ -62,44 +63,45 @@ const PartialApproveReasonToastInner = styled.div`
flex: 1 0 0;
}
.PartialApproveReasonToast-sticky-title {
.ApproveReasonToast-sticky-title {
position: sticky;
top: 0;
background: ${({ theme }) => theme.colors.GREEN[100]};
z-index: ${({ theme }) => theme.zIndices.toast + 1};
}
`;

const PartialApproveReasonToast: React.FC<PartialApproveReasonToastProps> = ({
const ApproveReasonToast: React.FC<ApproveReasonToastProps> = ({
title,
reasons,
}) => (
<ForceBorderRadius>
<PartialApproveReasonToastInner>
<div className="PartialApproveReasonToast-title">
<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="PartialApproveReasonToast-reasons">
<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)}
{formatDotDetailDate(reason.datetime)}{" "}
{reason.status && `• ${reason.status}`}
</Typography>
<Typography fs={16} lh={24} fw="REGULAR">
{reason.reason}
</Typography>
</FlexWrapper>
))}
</div>
</PartialApproveReasonToastInner>
</ApproveReasonToastInner>
</ForceBorderRadius>
);

export default PartialApproveReasonToast;
export default ApproveReasonToast;
4 changes: 3 additions & 1 deletion packages/web/src/common/components/RejectReasonToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Typography from "./Typography";
interface Reason {
datetime: Date;
reason: React.ReactNode;
status?: string;
}

interface RejectReasonToastProps {
Expand Down Expand Up @@ -90,7 +91,8 @@ const RejectReasonToast: React.FC<RejectReasonToastProps> = ({
key={formatDotDetailDate(reason.datetime)}
>
<Typography fs={14} lh={16} fw="REGULAR" color="GRAY.600">
{formatDotDetailDate(reason.datetime)}
{formatDotDetailDate(reason.datetime)}{" "}
{reason.status && `• ${reason.status} 사유`}
</Typography>
<Typography fs={16} lh={24} fw="REGULAR">
{reason.reason}
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/constants/tableTagList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const FundingTagList: {
[FundingStatusEnum.Committee]: { text: "운위", color: "YELLOW" },
[FundingStatusEnum.Approved]: { text: "승인", color: "GREEN" },
[FundingStatusEnum.Rejected]: { text: "반려", color: "RED" },
[FundingStatusEnum.Partial]: { text: "부분 승인", color: "PURPLE" },
[FundingStatusEnum.Partial]: { text: "부분", color: "PURPLE" },
};

// TODO: interface enum 사용
Expand Down
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;
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ import Card from "@sparcs-clubs/web/common/components/Card";
import FlexWrapper from "@sparcs-clubs/web/common/components/FlexWrapper";
import Modal from "@sparcs-clubs/web/common/components/Modal";
import CancellableModalContent from "@sparcs-clubs/web/common/components/Modal/CancellableModalContent";
import PartialApproveReasonToast from "@sparcs-clubs/web/common/components/PartialApproveReasonToast";
import ProgressStatus from "@sparcs-clubs/web/common/components/ProgressStatus";
import RejectReasonToast from "@sparcs-clubs/web/common/components/RejectReasonToast";

import { getFundingProgress } from "@sparcs-clubs/web/features/manage-club/funding/constants/fundingProgressStatus";
import { useDeleteFunding } from "@sparcs-clubs/web/features/manage-club/funding/services/useDeleteFunding";
import { useGetFunding } from "@sparcs-clubs/web/features/manage-club/funding/services/useGetFunding";
import useGetFundingDeadline from "@sparcs-clubs/web/features/manage-club/funding/services/useGetFundingDeadline";
Expand All @@ -27,6 +23,7 @@ import { isActivityReportUnverifiable } from "@sparcs-clubs/web/features/manage-
import BasicEvidenceList from "../components/BasicEvidenceList";
import FixtureEvidenceList from "../components/FixtureEvidenceList";
import FundingInfoList from "../components/FundingInfoList";
import FundingStatusSection from "../components/FundingStatusSection";
import NonCorpEvidenceList from "../components/NonCorpEvidenceList";
import OtherEvidenceList from "../components/OtherEvidenceList";
import TransportationEvidenceList from "../components/TransportationEvidenceList";
Expand Down Expand Up @@ -136,42 +133,11 @@ const FundingDetailFrame: React.FC<FundingDetailFrameProps> = ({ clubId }) => {
<FlexWrapper direction="column" gap={40}>
<Card outline>
{!isPastFunding && (
<ProgressStatus
labels={
getFundingProgress(
funding.fundingStatusEnum,
funding.editedAt,
funding.commentedAt,
).labels
}
progress={
getFundingProgress(
funding.fundingStatusEnum,
funding.editedAt,
funding.commentedAt,
).progress
}
optional={
funding.comments &&
funding.comments.length > 0 &&
(funding.fundingStatusEnum === FundingStatusEnum.Partial ? (
<PartialApproveReasonToast
title="부분 승인 사유"
reasons={funding.comments.map(comment => ({
datetime: comment.createdAt,
reason: comment.content,
}))}
/>
) : (
<RejectReasonToast
title="반려 사유"
reasons={funding.comments.map(comment => ({
datetime: comment.createdAt,
reason: comment.content,
}))}
/>
))
}
<FundingStatusSection
status={funding.fundingStatusEnum}
editedAt={funding.editedAt}
commentedAt={funding.commentedAt}
comments={funding.comments.toReversed()}
/>
)}
<AsyncBoundary isLoading={isLoading} isError={isError}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const useGetFunding = (fundingId: number) =>
});

defineAxiosMock(mock => {
const fundingStatus = FundingStatusEnum.Partial;
const fundingStatus = FundingStatusEnum.Approved;
const mockFundingDetail = {
id: 1,
club: {
Expand Down Expand Up @@ -103,12 +103,30 @@ defineAxiosMock(mock => {
createdAt: "2025-01-26T18:48:59.000Z",
updatedAt: "2025-01-29T22:41:08.000Z",
comments: [
{
id: 1,
funding: { id: 1 },
chargedExecutive: { id: 123 },
content: "대충 어떤 반려 사유",
fundingStatusEnum: FundingStatusEnum.Rejected,
approvedAmount: 1230,
createdAt: new Date(2024, 11, 10),
},
{
id: 1,
funding: { id: 1 },
chargedExecutive: { id: 123 },
content: "대충 어떤 부분 승인 사유",
fundingStatusEnum: fundingStatus,
fundingStatusEnum: FundingStatusEnum.Partial,
approvedAmount: 1230,
createdAt: new Date(2024, 12, 20),
},
{
id: 1,
funding: { id: 1 },
chargedExecutive: { id: 123 },
content: "대충 어떤 승인 사유",
fundingStatusEnum: FundingStatusEnum.Approved,
approvedAmount: 1230,
createdAt: new Date(),
},
Expand Down

0 comments on commit 1c4edd6

Please sign in to comment.