-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(member): 마이페이지 내 회비 신청 내역 API 연동 (#78)
- Loading branch information
Showing
5 changed files
with
127 additions
and
14 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
67 changes: 67 additions & 0 deletions
67
apps/member/src/components/my/MyMembershipHistorySection/MyMembershipHistorySection.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,67 @@ | ||
import Image from '@components/common/Image/Image'; | ||
import ListButton from '@components/common/ListButton/ListButton'; | ||
import Section from '@components/common/Section/Section'; | ||
import useModal from '@hooks/common/useModal'; | ||
import { createImageUrl } from '@utils/api'; | ||
import { toYYMMDD } from '@utils/date'; | ||
import { formatWon } from '@utils/string'; | ||
import type { MembershipFeeType } from '@type/membershipFee'; | ||
import { Badge } from '@clab/design-system'; | ||
|
||
interface MyMembershipFeeProps { | ||
data: Array<MembershipFeeType>; | ||
} | ||
|
||
const title = '회비 신청 내역'; | ||
|
||
const MyMembershipHistorySection = ({ data }: MyMembershipFeeProps) => { | ||
const { openModal } = useModal(); | ||
|
||
const onClickShow = (membership: MembershipFeeType) => { | ||
openModal({ | ||
title: title, | ||
content: ( | ||
<div className="space-y-2"> | ||
<Image | ||
src={createImageUrl(membership.imageUrl || '')} | ||
className="border rounded-lg" | ||
alt="증빙자료" | ||
/> | ||
<ul className="space-y-2 text-black"> | ||
<li className="space-x-2"> | ||
<Badge color="blue">{membership.category.toUpperCase()}</Badge> | ||
<Badge color="yellow">대기</Badge> | ||
</li> | ||
<li>내용: {membership.content}</li> | ||
<li>금액: ₩{formatWon(membership.amount)}</li> | ||
<li>신청일: {toYYMMDD(membership.createdAt)}</li> | ||
</ul> | ||
</div> | ||
), | ||
}); | ||
}; | ||
|
||
return ( | ||
<Section> | ||
<Section.Header title={title} /> | ||
<Section.Body className="text-sm"> | ||
{data.map((membership) => ( | ||
<ListButton | ||
key={membership.id} | ||
onClick={() => onClickShow(membership)} | ||
> | ||
<p className="pr-4 space-x-2 truncate grow"> | ||
<Badge color="blue">{membership.category.toUpperCase()}</Badge> | ||
<span>{membership.content}</span> | ||
</p> | ||
<p className="text-clab-main-light"> | ||
{toYYMMDD(membership.createdAt)} | ||
</p> | ||
</ListButton> | ||
))} | ||
</Section.Body> | ||
</Section> | ||
); | ||
}; | ||
|
||
export default MyMembershipHistorySection; |
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 |
---|---|---|
@@ -1,10 +1,32 @@ | ||
import { QUERY_KEY } from '@constants/key'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
import { getMembershipFee } from '@api/membershipFee'; | ||
import { PaginationPramsType } from '@type/api'; | ||
|
||
export const useMembershipFee = (page = 0, size = 20) => { | ||
interface UseMembershipFeeParamsType extends PaginationPramsType { | ||
memberId?: string; | ||
memberName?: string; | ||
category?: string; | ||
} | ||
/** | ||
* 회비 정보를 조회합니다. | ||
*/ | ||
export const useMembershipFee = ({ | ||
memberId, | ||
memberName, | ||
category, | ||
page = 0, | ||
size = 20, | ||
}: UseMembershipFeeParamsType) => { | ||
return useSuspenseQuery({ | ||
queryKey: [QUERY_KEY.MEMBERSHIP_FEE, page, size], | ||
queryFn: () => getMembershipFee(page, size), | ||
queryKey: [QUERY_KEY.MEMBERSHIP_FEE], | ||
queryFn: () => | ||
getMembershipFee({ | ||
memberId, | ||
memberName, | ||
category, | ||
page, | ||
size, | ||
}), | ||
}); | ||
}; |
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