Skip to content

Commit

Permalink
refactor: pathname 상수 사용
Browse files Browse the repository at this point in the history
  • Loading branch information
iOdiO89 committed Jul 25, 2024
1 parent 01aa11c commit 240c856
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
7 changes: 4 additions & 3 deletions src/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import styled from 'styled-components'
import NavBar from './navBar'
import { useAtom } from 'jotai'
import { currentTabAtom, historyCountAtom, processCountAtom, waitingCountAtom } from 'utils/atom'
import { ROUTE } from '@constants/path'

export default function Layout() {
const navigate = useNavigate()
Expand All @@ -15,17 +16,17 @@ export default function Layout() {
{
name: '승인 대기',
count: waitingCount,
onClick: () => onClickTab('/waiting'),
onClick: () => onClickTab(ROUTE.WAITING_MAIN),
},
{
name: '진행 중',
count: processCount,
onClick: () => onClickTab('/process'),
onClick: () => onClickTab(ROUTE.PROCESS_MAIN),
},
{
name: '히스토리',
count: historyCount,
onClick: () => onClickTab('/history'),
onClick: () => onClickTab(ROUTE.HISTORY_MAIN),
},
]

Expand Down
15 changes: 8 additions & 7 deletions src/components/orderCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { returnTotalPrice } from 'utils/cardFunc'
import PreviousOrder from './prevOrder'
import OrderDetail from './orderDetail'
import { useState } from 'react'
import { ROUTE } from '@constants/path'

export type productType = {
name: string
Expand Down Expand Up @@ -37,32 +38,32 @@ export default function OrderCard({ tableNumber, status, orders, prevOrders }: O
<OrderChip status={status} />
</TitleContainer>
<TimeText>
{pathname === '/waiting' ? '0분 전' : dayjs().locale('ko').format('YYYY년 M월 D일 HH시 mm분 ss초')}
{pathname === '/history' && ' 결제 완료'}
{pathname === ROUTE.WAITING_MAIN ? '0분 전' : dayjs().locale('ko').format('YYYY년 M월 D일 HH시 mm분 ss초')}
{pathname === ROUTE.HISTORY_MAIN && ' 결제 완료'}
</TimeText>
</Top>
<OrderSummary>
메뉴 {orders.length}개 총 {returnTotalPrice(orders).toLocaleString()}
</OrderSummary>
<OrderDetail orders={orders} />
{!(pathname === '/history' && status === 'single') && <Divider />}
{!(pathname === ROUTE.HISTORY_MAIN && status === 'single') && <Divider />}
{prevOrders !== undefined && (
<PreviousOrder
showDetail={showDetail}
setShowDetail={setShowDetail}
orders={orders}
showLabel={pathname === '/process' && status === 'multi'}
showLabel={pathname === ROUTE.PROCESS_MAIN && status === 'multi'}
/>
)}
<ButtonContainer>
{pathname === '/waiting' && (
{pathname === ROUTE.WAITING_MAIN && (
<>
<WhiteButton>주문 거절</WhiteButton>
<BlackButton>주문 승인</BlackButton>
</>
)}
{pathname === '/process' && <BlackButton>결제 완료</BlackButton>}
{pathname === '/history' && status === 'multi' && (
{pathname === ROUTE.PROCESS_MAIN && <BlackButton>결제 완료</BlackButton>}
{pathname === ROUTE.HISTORY_MAIN && status === 'multi' && (
<BlackButton onClick={toggleShowDetail}>{showDetail ? '최초 주문만 보기' : '이전 주문 보기'}</BlackButton>
)}
</ButtonContainer>
Expand Down

0 comments on commit 240c856

Please sign in to comment.