Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/features/billilge/components/BillilgeStatusBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ interface BillilgeStatusBadgeProps {
}

// Figma: 빌릴게 대여내역 뱃지(1133:50036)의 Content Badge/Content Badge. WDS ContentBadge가 color="accent"면
// accentColor의 8% 배경에 원색 글자를, neutral이면 Fill/Normal 배경을 깔아서 Figma 구조와 같다
// (EventsStatusBadge와 같은 방식). 크기는 대여 내역 카드(1243:74983)에서 실측한 small이다.
// accentColor의 8% 배경에 원색 글자를 깔아서 Figma 구조와 같다(EventsStatusBadge와 같은 방식).
// 승인대기도 주황으로 바꿔서 모든 상태가 accent다. 크기는 대여 내역 카드(1243:74983)에서 실측한 small이다.
function BillilgeStatusBadge({ status }: BillilgeStatusBadgeProps) {
const badge = BILLILGE_STATUS_BADGES[status];

return (
<ContentBadge
accentColor={badge.color === "accent" ? badge.token : undefined}
color={badge.color}
neutralColor={badge.color === "neutral" ? badge.token : undefined}
accentColor={badge.token}
color="accent"
size="small"
variant="solid"
>
Expand Down
19 changes: 6 additions & 13 deletions src/features/billilge/constants/billilge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,52 +28,45 @@ export const BILLILGE_CATEGORY_LABELS = {
HYGIENE: "위생용품",
} satisfies Record<BillilgeCategory, string>;

// 대여 상태 뱃지 — Figma 빌릴게 대여내역 뱃지(1133:50036). 승인을 기다리는 두 상태만 회색(neutral)이고
// 나머지는 accent 색이다. 대여 내역·반납이 필요한 물품·홈 대여 현황이 같이 쓴다.
// 대여 상태 뱃지 — Figma 빌릴게 대여내역 뱃지(1133:50036). 대여 내역·반납이 필요한 물품·홈 대여 현황이 같이 쓴다.
// Figma는 승인을 기다리는 두 상태(대여·반납 승인대기)가 회색인데, 반려로 오해할 수 있어서 홈 학생회비 "납부확인중"
// 뱃지(3147:146354)와 같은 주황으로 바꿨다. 그래서 모든 상태가 accent 색이라 색 종류(neutral/accent)는 두지 않는다.
export const BILLILGE_STATUS_BADGES = {
PENDING: {
color: "neutral",
label: "대여 승인대기",
token: "semantic.label.alternative",
token: "semantic.accent.foreground.orange",
},
CONFIRMED: {
color: "accent",
label: "수령대기",
token: "semantic.accent.foreground.orange",
},
RENTAL: {
color: "accent",
label: "대여중",
token: "semantic.accent.foreground.blue",
},
RETURN_PENDING: {
color: "neutral",
label: "반납 승인대기",
token: "semantic.label.alternative",
token: "semantic.accent.foreground.orange",
},
RETURN_CONFIRMED: {
color: "accent",
label: "반납대기",
token: "semantic.accent.foreground.orange",
},
RETURNED: {
color: "accent",
label: "반납완료",
token: "semantic.accent.foreground.green",
},
CANCEL: {
color: "accent",
label: "대기취소",
token: "semantic.accent.foreground.red",
},
REJECTED: {
color: "accent",
label: "대여불가",
token: "semantic.accent.foreground.red",
},
} as const satisfies Record<
BillilgeRentalStatus,
{ color: "neutral" | "accent"; label: string; token: string }
{ label: string; token: string }
>;

// 반납 기한 문구 — 빌릴게 반납 탭과 홈 대여 현황이 같이 쓴다. Figma는 "반납까지 N시간"만 있는데, 며칠짜리 대여는
Expand Down
21 changes: 11 additions & 10 deletions src/features/home/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,18 @@ function HomeScreen() {
<HomeNoticeBanner onSelect={openBanner} />
</Suspense>
{/* 배너 카드(relative)가 뒤 섹션보다 나중에 그려져 그림자가 덮지 않게 뒤 섹션도 relative로 둔다 */}
{/* 대여 중인 물품 → 신청 안내(신청마감 D-nn) → 신청한 행사 순으로, 내 대여·신청 현황을 먼저 보여 준다 */}
<div className="relative flex flex-col gap-2">
<div className="px-5">
{/* 대여 현황은 반납 대기·확인을 나눠 보여 주려고 홈 조회가 아니라 빌릴게 반납 조회·대여 내역 조회로 받는다 */}
<Suspense fallback={<HomeRentalSkeleton />}>
<HomeRentalSection
onBrowse={() => navigate(BILLILGE_TAB_PATHS.rent)}
onMore={() => navigate(BILLILGE_TAB_PATHS.return)}
onReturnRequest={openReturnRequest}
/>
</Suspense>
</div>
<Suspense fallback={null}>
<HomeApplyCardList
onApply={(section) =>
Expand All @@ -145,16 +156,6 @@ function HomeScreen() {
onSelect={(section) => push(getApplySectionPath(section))}
/>
</Suspense>
<div className="px-5">
{/* 대여 현황은 반납 대기·확인을 나눠 보여 주려고 홈 조회가 아니라 빌릴게 반납 조회로 받는다 */}
<Suspense fallback={<HomeRentalSkeleton />}>
<HomeRentalSection
onBrowse={() => navigate(BILLILGE_TAB_PATHS.rent)}
onMore={() => navigate(BILLILGE_TAB_PATHS.return)}
onReturnRequest={openReturnRequest}
/>
</Suspense>
</div>
<div className="px-5">
<Suspense fallback={<HomeAppliedEventSkeleton />}>
<HomeAppliedEventSection
Expand Down
57 changes: 49 additions & 8 deletions src/features/home/components/HomeRentalSection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useSuspenseQuery } from "@tanstack/react-query";
import { useSuspenseQueries } from "@tanstack/react-query";
import { Button, Divider, Typography } from "@wanteddev/wds";

import returnItemsEmpty from "@/assets/icons/billilge-empty/return-items.svg";
Expand All @@ -9,10 +9,19 @@ import {
getReturnDueLabel,
} from "@/features/billilge/constants/billilge";
import HomeEmptyState from "@/features/home/components/HomeEmptyState";
import { formatDateTime } from "@/lib/date";
import { billilgeQueries } from "@/shared/entities/billilge/billilgeQueries";
import type { BillilgeHistoryListResponse } from "@/shared/entities/billilge/billilgeTypes";

const VISIBLE_COUNT = 2;

// 신청했지만 아직 받아 가지 않은 대여(대여 승인대기·수령대기) — 반납 필요 조회에는 없어서 대여 내역에서 고른다
function selectAwaitingPickup({ histories }: BillilgeHistoryListResponse) {
return histories.filter(
(history) => history.status === "PENDING" || history.status === "CONFIRMED",
);
}

interface HomeRentalSectionProps {
// 반납 신청 — 홈에서 바로 확인 모달을 띄운다
onReturnRequest: (rentalHistoryId: number) => void;
Expand All @@ -25,16 +34,29 @@ interface HomeRentalSectionProps {
// Figma: Rental Summary 2건 (nodeId 3147:146269), 3건 이상 (3147:146326), empty (3562:163925)
// 빌릴게 반납 탭과 같은 반납 필요 대여를 받아 그린다(홈 API는 반납 대기·확인을 나누지 않아 쓰지 않는다). 받는 동안은 HomeScreen의
// Suspense가 HomeRentalSkeleton을 보여준다.
// 반납 필요 대여 뒤에 아직 받아 가지 않은 대여도 붙인다 — Figma에 이 상태가 없어서, 반납 기한 대신 대여 예정 시각을
// 보조 문구로 쓰고 버튼 대신 상태 뱃지를 둔다. 반납 기한이 있는 대여가 더 급해서 먼저 보인다.
function HomeRentalSection({
onReturnRequest,
onMore,
onBrowse,
}: HomeRentalSectionProps) {
const {
data: { rentalHistories: rentals },
} = useSuspenseQuery(billilgeQueries.returnRequired());
// 두 조회를 따로 기다리지 않게(요청이 줄줄이 이어지지 않게) 한 번에 같이 받는다 — 빌릴게 반납 탭과 같은 조회라 캐시도 같이 쓴다
const [
{
data: { rentalHistories: rentals },
},
{ data: awaitingPickup },
] = useSuspenseQueries({
queries: [
billilgeQueries.returnRequired(),
{ ...billilgeQueries.histories(), select: selectAwaitingPickup },
],
});

if (rentals.length === 0) {
const totalCount = rentals.length + awaitingPickup.length;

if (totalCount === 0) {
return (
<HomeEmptyState
action={
Expand All @@ -53,7 +75,12 @@ function HomeRentalSection({
);
}

const hiddenCount = rentals.length - VISIBLE_COUNT;
const visibleRentals = rentals.slice(0, VISIBLE_COUNT);
const visibleAwaitingPickup = awaitingPickup.slice(
0,
VISIBLE_COUNT - visibleRentals.length,
);
const hiddenCount = totalCount - VISIBLE_COUNT;

return (
<div className="flex flex-col gap-3 rounded-xl bg-background-normal p-4">
Expand All @@ -63,10 +90,10 @@ function HomeRentalSection({
variant="label2"
weight="medium"
>
대여 중인 물품 · {rentals.length}건
대여 중인 물품 · {totalCount}건
</Typography>
<div className="flex flex-col gap-4">
{rentals.slice(0, VISIBLE_COUNT).map((rental) => {
{visibleRentals.map((rental) => {
const due = getReturnDueLabel(rental.dueAt);
return (
<BillilgeItemCard
Expand All @@ -87,6 +114,20 @@ function HomeRentalSection({
/>
);
})}
{visibleAwaitingPickup.map((rental) => (
<BillilgeItemCard
icon={rental.itemImageUrl}
itemName={rental.itemName ?? BILLILGE_DELETED_ITEM_NAME}
key={rental.rentalHistoryId}
subtitle={
rental.rentAt
? `${formatDateTime(rental.rentAt)} 대여 예정`
: "대여 예정"
}
surface={false}
trailingBadge={<BillilgeStatusBadge status={rental.status} />}
/>
))}
</div>
{hiddenCount > 0 && (
<>
Expand Down
Loading