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
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ const routes: RouteObject[] = [
element: <RewardAddressDetailPage />,
},
{
path: 'address-complete/:productId',
path: 'address-complete',
element: <RewardAddressCompletePage />,
},
{
Expand Down
29 changes: 29 additions & 0 deletions src/constants/home.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { HomeServiceMenuItem } from '../types/home';

// 홈 화면의 고정 서비스 메뉴입니다.
export const HOME_SERVICE_MENU_ITEMS: HomeServiceMenuItem[] = [
{
id: 'disposal-info',
title: '배출 정보',
path: '/disposal-info',
icon: 'trash',
},
{
id: 'disposal-auth',
title: '배출 인증',
path: '/certification',
icon: 'camera',
},
{
id: 'reward-save',
title: '리워드 적립',
path: '/reward',
icon: 'reward',
},
{
id: 'contribution',
title: '실시간 기여도',
path: '/my-contribution',
icon: 'chart',
},
];
2 changes: 1 addition & 1 deletion src/layouts/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Layout = () => {
const isCamera = !!matchPath('/camera', location.pathname);

const isReward = !!matchPath({ path: '/reward/*', end: false }, location.pathname);
const isRewardAddressComplete = !!matchPath('/reward/address-complete/:productId', location.pathname);
const isRewardAddressComplete = !!matchPath('/reward/address-complete', location.pathname);
const isRewardUseComplete = !!matchPath('/reward/use-complete/:productId', location.pathname);
const isRewardHistory = !!matchPath('/reward/history', location.pathname);
const isRewardStore = !!matchPath('/reward/store', location.pathname);
Expand Down
77 changes: 0 additions & 77 deletions src/mocks/home.ts

This file was deleted.

155 changes: 0 additions & 155 deletions src/mocks/reward.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/pages/home-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import LogoutIcon from '../assets/icons/logout.svg';
import BigLogo from '../assets/icons/Big-logo.svg?react';
import RewardIcon from '../assets/icons/reward.svg';
import TrashIcon from '../assets/icons/trash.svg';
import { HOME_SERVICE_MENU_ITEMS } from '../mocks/home';
import { HOME_SERVICE_MENU_ITEMS } from '../constants/home';
import type { HomeServiceMenuItem } from '../types/home';
import { useNavigate } from 'react-router-dom';
import { getMyInfo } from '../apis/user';
Expand Down Expand Up @@ -133,7 +133,7 @@ export default function HomePage() {
</div>
</section>

{/* 홈 서비스 메뉴입니다. 아이콘은 mock 데이터의 icon 값으로 매칭합니다. */}
{/* 홈 서비스 메뉴입니다. 아이콘은 메뉴 설정의 icon 값으로 매칭합니다. */}
<section className='mt-7'>
<h2 className='text-[17px] font-bold leading-none'>어떤 서비스를 찾으시나요?</h2>
<div className='mt-4 grid grid-cols-2 gap-3'>
Expand Down
21 changes: 11 additions & 10 deletions src/pages/reward-page/reward-address-complete-page.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { Navigate, useNavigate, useParams } from 'react-router-dom';
import { Navigate, useLocation, useNavigate } from 'react-router-dom';
import FullCheck from '../../assets/icons/full-check.svg';
import { mockRewardProducts } from '../../mocks/reward';

interface RewardAddressCompleteLocationState {
addressCreated?: boolean;
}

export default function RewardAddressCompletePage() {
const navigate = useNavigate();
const { productId } = useParams<{ productId: string }>();
const numericProductId = Number(productId);
const product = Number.isSafeInteger(numericProductId)
? mockRewardProducts.find(({ id }) => id === numericProductId)
: undefined;
const { state } = useLocation();
const addressCreated = (state as RewardAddressCompleteLocationState | null)
?.addressCreated;

if (!product || product.type !== 'PARTNER') {
return <Navigate to='/reward/store' replace />;
if (!addressCreated) {
return <Navigate to='/reward/address-list' replace />;
}

return (
Expand All @@ -35,7 +36,7 @@ export default function RewardAddressCompletePage() {

<button
type='button'
onClick={() => navigate(`/reward/checkout/${product.id}`, { replace: true })}
onClick={() => navigate('/reward/address-list', { replace: true })}
className='h-[50px] w-full shrink-0 rounded-full bg-main-green1 text-base font-bold text-white'
>
확인
Expand Down
5 changes: 4 additions & 1 deletion src/pages/reward-page/reward-address-detail-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ function RewardAddressDetailForm({
await queryClient.invalidateQueries({
queryKey: ['rewardAddressList'],
});
navigate(-2);
navigate('/reward/address-complete', {
replace: true,
state: { addressCreated: true },
});
},
onError: (error) => {
console.error('배송지 생성에 실패했습니다.', error);
Expand Down
21 changes: 0 additions & 21 deletions src/types/reward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ export type RewardProductType = 'PARTNER_BRAND' | 'COUPON_GIFTICON';

export type RewardFilterType = 'ALL' | RewardProductType;

export type MockRewardProductType = 'PARTNER' | 'GIFTICON';

export type RewardProductStatus = 'ACTIVE' | 'INACTIVE' | 'SOLD_OUT';

export type RewardAddressType = 'HOME' | 'COMPANY' | 'SCHOOL';
Expand Down Expand Up @@ -77,22 +75,6 @@ export interface RewardHistoryParams {



export interface RewardProduct {
id: number;
name: string;
type: MockRewardProductType;
point: number;
description?: string;
usageGuide?: string;
validityPeriod?: string;
}

export interface RewardShippingAddress {
id: number;
name: string;
address: string;
}

export interface ApiResponse<T> {
isSuccess: boolean;
code: string;
Expand Down Expand Up @@ -128,9 +110,6 @@ export interface ShippingAddressListResult {
shippingAddresses: ShippingAddress[];
}

export type ShippingAddressListResponse =
ApiResponse<ShippingAddressListResult>;

export interface AddressCandidates {
roadAddress: string;
jibunAddress: string;
Expand Down
Loading