Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/243 #345

Merged
merged 31 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
13ccf39
[feat]:펀딩내역 내부 레이아웃 구현(#243)
devkyoung2 May 24, 2024
95569f5
[feat] : 펀딩내역 아이템 컴포넌트 구현(#243)
devkyoung2 May 24, 2024
9797db1
[feat] : 펀딩내역 아이템 타입 지정(#243)
devkyoung2 May 24, 2024
c64a33f
[feat]: 펀딩내역 api 요청을 위한 함수 구현(#243)
devkyoung2 May 24, 2024
17b3407
[fix]: getContributedFundingHistory api/응답타입수정(#243)
devkyoung2 May 24, 2024
7159bb9
Merge branch 'dev' into feat/243
devkyoung2 May 24, 2024
4896ec9
Merge branch 'dev' into feat/243
devkyoung2 May 27, 2024
83153dc
[fix]: 잘못된 useDateFilter 상태값 수정(#243)
devkyoung2 May 27, 2024
8637138
[feat]: 펀딩내역 EmptyItem 추가&춘식이 이미지 임로트 경로 수정(#243)
devkyoung2 May 27, 2024
610593d
[feat]: 기여한 펀딩내역탭 구현(#243)
devkyoung2 May 27, 2024
21302e1
[refactor]: 불필요한 타입단언 제거(#243)
devkyoung2 May 27, 2024
57df1f1
Merge branch 'dev' into feat/243
devkyoung2 May 29, 2024
a35c3d9
Merge branch 'dev' into feat/243
devkyoung2 Jun 4, 2024
fd0ac00
[fix]: 등록한 펀딩내역 api 요청 함수 수정(#243)
devkyoung2 Jun 4, 2024
9fb573e
[refactor]: 펀딩내역아이템 타입 파일 분리(#243)
devkyoung2 Jun 4, 2024
41fc60b
[feat]: 등록한 펀딩내역탭 구현(#243)
devkyoung2 Jun 4, 2024
f77aa3c
[fix]: 잘못된 props 수정(#243)
devkyoung2 Jun 4, 2024
43fbf6c
[fix]: 렌더링 로직 수정 및 파일 임포트 경로 수정(#243)
devkyoung2 Jun 4, 2024
53d3515
[refactor]: 타입 이름 수정(#243)
devkyoung2 Jun 4, 2024
1e3c789
[feat]: 등록한 펀딩 아이템 레이아웃 구현(#243)
devkyoung2 Jun 4, 2024
f766e51
[remove]: 필요없는 파일 삭제(#243)
devkyoung2 Jun 4, 2024
bb0bed1
[feat]: 기여한 펀딩 아이템 레이아웃 구현(#243)
devkyoung2 Jun 4, 2024
19f5d92
[feat]: 등록한 펀딩 아이템 api 연동(#243)
devkyoung2 Jun 4, 2024
efe6437
[feat]: 기여한 펀딩 아이템 api 연동(#243)
devkyoung2 Jun 4, 2024
d5e5d45
[refactor]: 등록한 펀딩 아이템 상태 타입 상수화(#243)
devkyoung2 Jun 4, 2024
4f47087
[feat]: 등록한 펀딩 아이템 등록한 날짜 응답값 추가(#243)
devkyoung2 Jun 4, 2024
48fec41
[fix]: 임의의 날짜값 제거 및 필요한 props 전달 (#243)
devkyoung2 Jun 4, 2024
18791c1
[feat]: 날짜시간 포매탕 함수 구현(#243)
devkyoung2 Jun 4, 2024
1ef3a85
[feat]: 기여한 펀딩 취소시 흐림효과 구현(#243)
devkyoung2 Jun 4, 2024
57ae477
[feat]: 등록한 펀딩 취소시 스타일 적용(#243)
devkyoung2 Jun 4, 2024
bfa0fa7
Merge branch 'dev' into feat/243
devkyoung2 Jun 10, 2024
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
8 changes: 8 additions & 0 deletions src/components/feature/EmptyItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ const EMPTY_ITEM_TEXT = {
title: `주문내역이 없어요`,
description: `소중한 친구에게 마음❤️을 전해보아요~!`,
},
funding_contributed: {
title: `기여했던 펀딩이 없어요`,
description: `친구의 펀딩아이템에 마음을 전해보세요~!`,
},
funding_registered: {
title: `등록했던 펀딩이 없어요`,
description: `펀딩받고 싶은 선물🎁이 있나요?\n내 취향에 맞는 선물을 등록해보세요~!`,
},
} as const;

const EmptyItem = ({ type }: EmptyItemProps) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
@import 'styles/mixins.module';

.txt_date {
@include font(15px, 400);

margin-bottom: 10px;

.num_data {
@include font(15px, 700);

margin-left: 5px;
}
}

.cancel {
opacity: 0.5;
}

.wrapper_history {
margin-bottom: 30px;
border: 2px solid #ededed;
border-radius: 8px;
box-shadow: 0 1px 2px -1px rgba(0, 0, 0, 6%);

.section_status {
position: relative;
padding: 16px;
border-bottom: 1px solid #ededed;

.ico_receiver {
@include ico-gift-order(-125px, -15px, 18px, 12px);

display: inline-block;
margin: 2px 3px 0 0;
}

.txt_detail {
@include font(13px, 400, #666);

position: absolute;
right: 16px;
line-height: 16px;
letter-spacing: -0.024em;

.ico_detail {
@include ico-gift-order(-100px, -15px, 6px, 10px);

margin: 0 0 0 4px;
}
}
}

.section_product {
display: flex;
padding: 16px;

.thumb_product {
@include size(96px, 96px, 0 10px 0 0, 0);
}

.info_product {
line-height: 18px;

.txt_brand {
@include font(14px, 400, #888);
}

.txt_title {
@include font(14px, 400, #222);
@include text-ellipsis(2);

display: block;
overflow: hidden;
padding: 4px 0;
}

.num_price {
@include font(14px, 700, #000);

.txt_unit {
@include font(14px, 400, #000);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import clsx from 'clsx';
import { Link } from 'react-router-dom';

import { formatNumberWithComma, formatDateAndTime } from 'utils/format';

import { ContributedFundingItemType } from 'types/fundingHistory';

import styles from './index.module.scss';

type ContributedFundingItemProps = { item: ContributedFundingItemType };

const ContributedFundingItem = ({ item }: ContributedFundingItemProps) => {
const { product, fundingDetail } = item;
const { productId, name, photo, brandName } = product;
const { contributedAt, creatorName, contributedAmount, status } =
fundingDetail;

return (
<Link to={`/product/${productId}`}>
<p
className={clsx(styles.txt_date, {
[styles.cancel]: status === 'CANCEL_REFUND',
})}
>
기여한 날짜
<span className={styles.num_data}>
{formatDateAndTime(contributedAt)}
</span>
Comment on lines +26 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

PR 내용에 올려주신 사진에는 시간이 undefined로 뜨고 있는데, 실제 API 응답으로 테스트를 못해서 임의의 값을 넣느라고 이런 이슈가 생긴 걸까요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네! 원래는 이 부분에 등록한 날짜가 와야하는데 지금은 만료일만 받고 있어서 만료일로 테스트 했습니다. 테스트 한 만료일에는 날짜정보밖에 없어서 undefined가 뜨는데 태환님께 시간정보 포함한 등록한 날짜 추가요청 드렸어요.

</p>

<div className={styles.wrapper_history}>
<div className={styles.section_status}>
<span className={styles.ico_receiver} />
{creatorName}
<span className={styles.txt_detail}>
상세보기
<span className={styles.ico_detail} />
</span>
</div>

<div
className={clsx(styles.section_product, {
[styles.cancel]: status === 'CANCEL_REFUND',
})}
>
<img
src={photo}
alt={`${name}상품이미지`}
className={styles.thumb_product}
/>
<div className={styles.info_product}>
<p className={styles.txt_brand}>{brandName}</p>
<strong className={styles.txt_title}>{name}</strong>
<em className={styles.num_price}>
{formatNumberWithComma(contributedAmount)}
<span className={styles.txt_unit}>원</span>
</em>
</div>
</div>
</div>
</Link>
);
};

export default ContributedFundingItem;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.area_funding {
padding: 30px 0 100px;
}
71 changes: 71 additions & 0 deletions src/layouts/MyPage/FundingHistory/ContributedFunding/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { useQuery } from '@tanstack/react-query';

import { useEffect, useState } from 'react';

import EmptyItem from 'components/feature/EmptyItem';
import FilterBar from 'components/ui/FilterBar';
import Spinner from 'components/ui/Spinner';

import { useDateFilter } from 'hooks/useDateFilter';
import { useInfinityScroll } from 'hooks/useInfinityScroll';
import { getContributedFundingHistory } from 'services/api/v1/fundingHistory';

import { ContributedFundingItemType } from 'types/fundingHistory';

import ContributedFundingItem from './ContributedFundingItem';

import styles from './index.module.scss';

const ContributedFunding = () => {
const [fundingItems, setFundingItems] = useState<
ContributedFundingItemType[]
>([]);
const [hasNext, setHasNext] = useState<boolean>(true);
const [page, setPage] = useState<number>(0);

const { startDate, endDate } = useDateFilter();

const { data, isLoading, refetch, isFetched } = useQuery({
queryKey: ['contributedFundingHistory', startDate, endDate],
queryFn: () => getContributedFundingHistory(startDate, endDate),
});

const observingTarget = useInfinityScroll(() => {
if (data) setPage(data.pageNumber + 1);
}, hasNext);

useEffect(() => {
refetch();
}, [page]);

useEffect(() => {
if (data) {
setFundingItems(data.items);
setHasNext(data.hasNext);
}
}, [data]);

return (
<>
<section className={styles.area_funding}>
<FilterBar />
{isFetched &&
(fundingItems.length === 0 ? (
<EmptyItem type="funding_contributed" />
) : (
<ul>
{fundingItems.map((item) => (
<li key={item.fundingDetail.fundingId}>
<ContributedFundingItem item={item} />
</li>
))}
</ul>
))}
</section>
{isLoading && <Spinner />}
{!isLoading && hasNext && <div ref={observingTarget} />}
</>
);
};

export default ContributedFunding;
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
@import 'styles/mixins.module';

.txt_date {
@include font(15px, 400);

margin-bottom: 10px;

.num_data {
@include font(15px, 700);

margin-left: 5px;
}
}

.wrapper_history {
margin-bottom: 30px;
border: 2px solid #ededed;
border-radius: 8px;
box-shadow: 0 1px 2px -1px rgba(0, 0, 0, 6%);

.section_status {
position: relative;
padding: 16px;
border-bottom: 1px solid #ededed;

.txt_detail {
@include font(13px, 400, #666);

position: absolute;
right: 16px;
line-height: 16px;
letter-spacing: -0.024em;

.ico_detail {
@include ico-gift-order(-100px, -15px, 6px, 10px);

margin: 0 0 0 4px;
}
}
}

.cancel {
color: #f00;
}
}

.section_product {
display: flex;
padding: 16px;

.thumb_product {
@include size(96px, 96px, 0 10px 0 0, 0);
}

.info_product {
line-height: 18px;

.txt_brand {
@include font(14px, 400, #888);
}

.txt_title {
@include font(14px, 400, #222);
@include text-ellipsis(2);

display: block;
overflow: hidden;
padding: 4px 0;
}
}
}

.txt_price {
@include font(14px, 400, #a5a5a5);

padding: 5px 6px 0 0;

.num_price {
@include font(14px, 700, #000);

margin-left: 10px;
}

.txt_unit {
@include font(14px, 400, #000);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import clsx from 'clsx';
import { Link } from 'react-router-dom';

import { formatNumberWithComma, formatDateAndTime } from 'utils/format';

import {
REGISTERED_ITEM_STATUS,
RegisteredFundingItemType,
} from 'types/fundingHistory';

import styles from './index.module.scss';

type RegisteredFundingItemProps = {
item: RegisteredFundingItemType;
};

const RegisteredFundingItem = ({ item }: RegisteredFundingItemProps) => {
return (
<Link to={`/product/${item.productId}`}>
<p className={styles.txt_date}>
등록한 날짜
<span className={styles.num_data}>
{formatDateAndTime(item.createdAt)}
</span>
</p>

<div className={styles.wrapper_history}>
<div
className={clsx(styles.section_status, {
[styles.cancel]: item.status === 'CANCEL',
})}
>
{REGISTERED_ITEM_STATUS[item.status]}
<span className={styles.txt_detail}>
상세보기
<span className={styles.ico_detail} />
</span>
</div>

<div className={styles.section_product}>
<img
src={item.productImage}
alt={`${item.productName}상품이미지`}
className={styles.thumb_product}
/>
<div className={styles.info_product}>
<p className={styles.txt_brand}>{item.brandName}</p>
<strong className={styles.txt_title}>{item.productName}</strong>
<p className={styles.txt_price}>
목표 금액 |
<em className={styles.num_price}>
{formatNumberWithComma(item.goalAmount)}
</em>
<span className={styles.txt_unit}>원</span>
</p>
</div>
</div>
</div>
</Link>
);
};

export default RegisteredFundingItem;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.area_funding {
padding: 30px 0 100px;
}
Loading
Loading