Skip to content

Commit

Permalink
Merge pull request #105 from CHZZK-Study/feat/server-sink
Browse files Browse the repository at this point in the history
feat: 내가 등록한 경매 URL 수정
  • Loading branch information
aquaman122 authored Oct 4, 2024
2 parents 59f34fb + 6844039 commit f20b68d
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/components/common/item/ProductItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const ProductItem = ({ product, children }: { product: ProductProps; children: R
<div className='flex flex-col'>
<div className='w-full h-auto mb-4'>
<div className='relative'>
<img className='object-cover w-full h-[10rem] rounded-t' src={`${product.cdnPath ? product.cdnPath : jordanBlackImage}`} alt='Jordan Black Shoes' />
<img className='object-cover w-full h-[15rem] rounded-t' src={`${product.cdnPath ? product.cdnPath : jordanBlackImage}`} alt='Jordan Black Shoes' />
{product.timeRemaining && <TimeLabel time={product.timeRemaining} />}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/login/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const postSignup = async (data: User) => {
};

export const logout = async () => {
await httpClient.post(API_END_POINT.LOGOUT, {}, { withCredentials: true });
await httpClient.post(API_END_POINT.LOGOUT, { withCredentials: true });

removeToken();
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/order/OrderListTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ const OrderListTab = ({ activeTab, setActiveTab }: OrderListTabProps) => {
onClick={() => setActiveTab('AuctionHistory')}
>
{isWidthScreen ? (
'진행중인 경매'
'참여한 경매'
) : (
<>
진행중인
참여한
<br />
경매
</>
Expand Down
11 changes: 9 additions & 2 deletions src/components/order/OrderLostProduct.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import { LuUsers } from 'react-icons/lu';
import ProductItem from '../common/item/ProductItem';

const OrderLostProduct = ({ product }: { product: IUserAuctionLostItem }) => {
const date = new Date(product.endDateTime);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');

const formattedDate = `${year}.${month}.${day}`;

return (
<ProductItem product={product}>
<div className='flex'>
Expand All @@ -18,14 +25,14 @@ const OrderLostProduct = ({ product }: { product: IUserAuctionLostItem }) => {
<LuUsers className='text-gray-500' />
<p className='text-sm text-gray-500'>마감된 날짜</p>
</div>
<p className='ml-4 font-semibold'>{`${product.endDateTime}`}</p>
<p className='ml-4 font-semibold'>{formattedDate}</p>
</div>
<div className='flex'>
<div className='flex gap-2'>
<LuUsers className='text-gray-500' />
<p className='text-sm text-gray-500'>가장 높은 금액</p>
</div>
<p className='ml-4 font-semibold'>{`${product.highestBid}`}</p>
<p className='ml-4 font-semibold'>{`${(product.highestBid).toLocaleString()}`}</p>
</div>
</ProductItem>
);
Expand Down
11 changes: 9 additions & 2 deletions src/components/order/OrderWonProduct.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import { LuUsers } from 'react-icons/lu';
import ProductItem from '../common/item/ProductItem';

const OrderWonProduct = ({ product }: { product: IUserAuctionWonItem }) => {
const date = new Date(product.endDateTime);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');

const formattedDate = `${year}.${month}.${day}`;

return (
<ProductItem product={product}>
<div className='flex'>
Expand All @@ -18,14 +25,14 @@ const OrderWonProduct = ({ product }: { product: IUserAuctionWonItem }) => {
<LuUsers className='text-gray-500' />
<p className='text-sm text-gray-500'>마감된 날짜</p>
</div>
<p className='ml-4 font-semibold'>{`${product.endDateTime}`}</p>
<p className='ml-4 font-semibold'>{formattedDate}</p>
</div>
<div className='flex'>
<div className='flex gap-2'>
<LuUsers className='text-gray-500' />
<p className='text-sm text-gray-500'>최종 낙찰금액</p>
</div>
<p className='ml-4 font-semibold'>{`${product.winningBid}`}</p>
<p className='ml-4 font-semibold'>{`${(product.winningBid).toLocaleString()}`}</p>
</div>
</ProductItem>
);
Expand Down
16 changes: 8 additions & 8 deletions src/components/user/UserOrder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ interface ParticipationCountItmes {
}

interface Props {
participationCount?: ParticipationCountItmes;
participantCount?: ParticipationCountItmes;
preRegisterCount?: number;
registeredAuctionCount?: number;
}

const UserOrder = ({ participationCount, preRegisterCount, registeredAuctionCount}: Props) => {
const UserOrder = ({ participantCount, preRegisterCount, registeredAuctionCount}: Props) => {
const navigate = useNavigate();
const $participationCount = participationCount || { failedAuctionCount: 0, ongoingAuctionCount: 0, successfulAuctionCount: 0 };
const $participantCount = participantCount || { failedAuctionCount: 0, ongoingAuctionCount: 0, successfulAuctionCount: 0 };
const $preRegisterCount = preRegisterCount || 0;
const $registeredAuctionCount = registeredAuctionCount || 0;

Expand All @@ -41,11 +41,11 @@ const UserOrder = ({ participationCount, preRegisterCount, registeredAuctionCoun
>
<img
src={OnGoingIcon}
alt="진행중인 경매"
alt="참여한 경매"
className="w-8 h-8 mb-2"
/>
<span className="text-sm font-semibold">진행중인 경매</span>
<span className="mt-1 text-lg text-orange-500">{$participationCount.ongoingAuctionCount}</span>
<span className="text-sm font-semibold">참여한 경매</span>
<span className="mt-1 text-lg text-orange-500">{$participantCount.ongoingAuctionCount}</span>
</div>

{/* 성공한 경매 */}
Expand All @@ -59,7 +59,7 @@ const UserOrder = ({ participationCount, preRegisterCount, registeredAuctionCoun
>
<img src={SuccessIcon} alt="성공한 경매" className="w-8 h-8 mb-2" />
<span className="text-sm font-semibold">성공한 경매</span>
<span className="mt-1 text-lg text-orange-500">{$participationCount.successfulAuctionCount}</span>
<span className="mt-1 text-lg text-orange-500">{$participantCount.successfulAuctionCount}</span>
</div>

{/* 실패한 경매 */}
Expand All @@ -73,7 +73,7 @@ const UserOrder = ({ participationCount, preRegisterCount, registeredAuctionCoun
>
<img src={FailedIcon} alt="실패한 경매" className="w-8 h-8 mb-2" />
<span className="text-sm font-semibold">실패한 경매</span>
<span className="mt-1 text-lg text-orange-500">{$participationCount.failedAuctionCount}</span>
<span className="mt-1 text-lg text-orange-500">{$participantCount.failedAuctionCount}</span>
</div>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions src/components/user/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import { useNavigate } from 'react-router-dom';
interface Props {
nickname?: string;
bio?: string;
link?: string;
}

const UserProfile = ({ nickname, bio }: Props) => {
const UserProfile = ({ nickname, bio, link }: Props) => {
const navigator = useNavigate();
const userNickname = nickname || null;
const userBio = bio || null;
const userLink = link || null;

return (
<div className="flex items-center pb-8 my-10 border-b border-b-gray3">
Expand All @@ -23,7 +25,7 @@ const UserProfile = ({ nickname, bio }: Props) => {
<button
className="px-3 py-1 border border-gray2 rounded-md"
onClick={() =>
navigator('profile/edit', { state: { userNickname, userBio } })
navigator('profile/edit', { state: { userNickname, userBio, userLink } })
}
>
수정
Expand Down
10 changes: 4 additions & 6 deletions src/components/user/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ export interface GetAuctionProps {
pageNumber: number;
pageSize: number;
sortType?: string;
nickname: string;
}

export const getAuctionOngoingRegister = async ({ pageNumber, pageSize, sortType = 'newest', nickname }: GetAuctionProps): Promise<IAuctionRegisteredList> => {
const response = await httpClient.get(`${API_END_POINT.MY_ACUTION_ONGOING_REGISTER}/${nickname}?&sort=${sortType}&page=${pageNumber}&size=${pageSize}`);
export const getAuctionOngoingRegister = async ({ pageNumber, pageSize, sortType = 'newest' }: GetAuctionProps): Promise<IAuctionRegisteredList> => {
const response = await httpClient.get(`${API_END_POINT.MY_ACUTION_ONGOING_REGISTER}?sort=${sortType}&page=${pageNumber}&size=${pageSize}`);
return response.data;
};

export const getAuctionPreEnrollRegister = async ({
pageNumber,
pageSize,
sortType = 'newest',
nickname,
sortType = 'product-newest'
}: GetAuctionProps): Promise<IPreAuctionRegisteredList> => {
const response = await httpClient.get(`${API_END_POINT.MY_ACUTION_PRE_ENROLL_REGISTER}/${nickname}?&sort=${sortType}&page=${pageNumber}&size=${pageSize}`);
const response = await httpClient.get(`${API_END_POINT.MY_ACUTION_PRE_ENROLL_REGISTER}?sort=${sortType}&page=${pageNumber}&size=${pageSize}`);
return response.data;
};
8 changes: 4 additions & 4 deletions src/hooks/useMyAuctionList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const useMyAuctionList = (activeTab: boolean, nickname: string): any => {
hasNextPage: hasNextOngoingPage,
refetch: refetchOngoingData,
} = useInfiniteQuery({
queryKey: [queryKeys.MY_AUCTION_REGISTERD, nickname],
queryKey: [queryKeys.MY_AUCTION_REGISTERD],
queryFn: () =>
getAuctionOngoingRegister({ pageNumber: 0, pageSize: 10, nickname }),
getAuctionOngoingRegister({ pageNumber: 0, pageSize: 10 }),
getNextPageParam: (lastPage) => {
if (lastPage.pageNumber + 1 >= lastPage.totalPages) {
return undefined;
Expand All @@ -37,9 +37,9 @@ const useMyAuctionList = (activeTab: boolean, nickname: string): any => {
hasNextPage: hasNextEnrollPage,
refetch: refetchEnrollData,
} = useInfiniteQuery({
queryKey: [queryKeys.MY_PRODUCT_REGISTERD, nickname],
queryKey: [queryKeys.MY_PRODUCT_REGISTERD],
queryFn: () =>
getAuctionPreEnrollRegister({ pageNumber: 0, pageSize: 10, nickname }),
getAuctionPreEnrollRegister({ pageNumber: 0, pageSize: 10 }),
getNextPageParam: (lastPage) => {
if (lastPage.pageNumber + 1 >= lastPage.totalPages) {
return undefined;
Expand Down
7 changes: 4 additions & 3 deletions src/hooks/useProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const useProfile = () => {
export const useEditProfile = () => {
const navigate = useNavigate();
const location = useLocation();
const { nickname, bio } = location.state || {};
const { userNickname, userBio, userLink } = location.state || {};

const {
control,
Expand All @@ -28,8 +28,9 @@ export const useEditProfile = () => {
formState: { errors },
} = useForm<UserProfile>({
defaultValues: {
nickname: nickname || '',
bio: bio || '',
nickname: userNickname || '',
bio: userBio || '',
link: userLink || '',
}
});

Expand Down
4 changes: 2 additions & 2 deletions src/pages/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const User = () => {

return (
<div className="flex flex-col">
<UserProfile nickname={profileData?.nickname} bio={profileData?.bio} />
<UserOrder participationCount={profileData?.participationCount} preRegisterCount={profileData?.preRegisterCount} registeredAuctionCount={profileData?.registeredAuctionCount} />
<UserProfile nickname={profileData?.nickname} bio={profileData?.bio} link={profileData?.link} />
<UserOrder participantCount={profileData?.participantCount} preRegisterCount={profileData?.preRegisterCount} registeredAuctionCount={profileData?.registeredAuctionCount} />
<UserOrderList />
</div>
);
Expand Down

0 comments on commit f20b68d

Please sign in to comment.