Skip to content

Commit 7c44375

Browse files
authored
버그수정사항 추가 (#61)
* fix: 페이지 접근 권한 추가 - 주문 페이지, 프로필 페이지, 메뉴 페이지 * fix: 테이블 페이지 네이션 수정 * fix: 폴더명 대문자로 인한 빌드에러 수정
1 parent cfec4a4 commit 7c44375

File tree

4 files changed

+90
-77
lines changed

4 files changed

+90
-77
lines changed

src/pages/dashboard/components/OrderTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ const OrderTable = () => {
152152
</span>
153153
<button
154154
onClick={() => setPageIndex((prev) => prev + 1)}
155-
disabled={currentPageData.length < PAGE_SIZE}
155+
disabled={currentPageData.length <= PAGE_SIZE}
156156
>
157157
다음 페이지
158158
</button>

src/pages/menuList/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import MenuCard from './components/menuCard';
44
import { useNavigate, useParams } from 'react-router-dom';
55
import { Button } from 'common/components';
66
import { MenuListProps } from './types';
7+
import useAuth from 'common/hooks/useAuth';
78
import { useGetStoresMenuQuery } from 'queries/modules/stores/useStoresQuery';
89

910
const MenuList = ({ data }: MenuListProps) => {
@@ -39,6 +40,7 @@ const MenuList = ({ data }: MenuListProps) => {
3940
};
4041

4142
const MenuListWrapper = () => {
43+
const { AuthGuard } = useAuth(['admin', 'owner']);
4244
const storeId = 1;
4345

4446
// useGetStoresMenuQuery 훅을 사용해 데이터 받아오기
@@ -47,8 +49,13 @@ const MenuListWrapper = () => {
4749
if (isLoading) return <div>Loading...</div>;
4850
if (error) return <div>Error loading menus</div>;
4951
if (!data) return <></>;
50-
return <MenuList data={data?.response} />;
52+
return (
53+
<AuthGuard>
54+
<MenuList data={data?.response} />
55+
</AuthGuard>
56+
);
5157
};
58+
5259
export default MenuListWrapper;
5360

5461
const _container = css`

src/pages/order/index.tsx

Lines changed: 80 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
import queryString from 'query-string';
2727
import { commaize } from 'utils/commaize';
2828
import colors from 'styles/color';
29+
import useAuth from 'common/hooks/useAuth';
2930

3031
const STATUS_OPTIONS = [
3132
{
@@ -43,6 +44,9 @@ const STATUS_OPTIONS = [
4344
];
4445

4546
const Order = ({ ...rest }) => {
47+
// 권한 설정
48+
const { AuthGuard } = useAuth(['admin', 'owner']);
49+
4650
const navigate = useNavigate();
4751
const [searchParams] = useSearchParams();
4852
const { pathname } = useLocation();
@@ -157,99 +161,101 @@ const Order = ({ ...rest }) => {
157161
}
158162

159163
return (
160-
<div css={_container} {...rest}>
161-
<div css={_header}>
162-
<div>
163-
<h1>주문</h1>
164-
<div>주문 내역을 확인하실 수 있어요.</div>
165-
</div>
166-
<div css={_filterWrapper}>
167-
<Filter
168-
leftSlot={<Lightning />}
169-
backgroundColor="lightBlue"
170-
placeholder="주문 상태"
171-
value={orderStatus}
172-
onChange={handleChangeOrderStatus}
173-
options={STATUS_OPTIONS}
174-
/>
175-
{/* TODO: datepicker는 추후에 개발 */}
176-
{/* <Filter
164+
<AuthGuard>
165+
<div css={_container} {...rest}>
166+
<div css={_header}>
167+
<div>
168+
<h1>주문</h1>
169+
<div>주문 내역을 확인하실 수 있어요.</div>
170+
</div>
171+
<div css={_filterWrapper}>
172+
<Filter
173+
leftSlot={<Lightning />}
174+
backgroundColor="lightBlue"
175+
placeholder="주문 상태"
176+
value={orderStatus}
177+
onChange={handleChangeOrderStatus}
178+
options={STATUS_OPTIONS}
179+
/>
180+
{/* TODO: datepicker는 추후에 개발 */}
181+
{/* <Filter
177182
leftSlot={<Calendar />}
178183
backgroundColor="lightBlue"
179184
placeholder="주문 기간"
180185
/> */}
186+
</div>
181187
</div>
182-
</div>
183188

184-
<div css={_tableContainer}>
185-
<table>
186-
<thead>
187-
{table.getHeaderGroups().map((headerGroup) => (
188-
<tr key={headerGroup.id}>
189-
{headerGroup.headers.map((header) => (
190-
<th
191-
css={css`
189+
<div css={_tableContainer}>
190+
<table>
191+
<thead>
192+
{table.getHeaderGroups().map((headerGroup) => (
193+
<tr key={headerGroup.id}>
194+
{headerGroup.headers.map((header) => (
195+
<th
196+
css={css`
192197
padding: 20px;
193198
`}
194-
key={header.id}
195-
colSpan={header.colSpan}
196-
>
197-
<div>
198-
{flexRender(
199-
header.column.columnDef.header,
200-
header.getContext(),
201-
)}
202-
</div>
203-
</th>
204-
))}
205-
</tr>
206-
))}
207-
</thead>
208-
<tbody>
209-
{table.getRowModel().rows.map((row) => (
210-
<tr
211-
css={css`
199+
key={header.id}
200+
colSpan={header.colSpan}
201+
>
202+
<div>
203+
{flexRender(
204+
header.column.columnDef.header,
205+
header.getContext(),
206+
)}
207+
</div>
208+
</th>
209+
))}
210+
</tr>
211+
))}
212+
</thead>
213+
<tbody>
214+
{table.getRowModel().rows.map((row) => (
215+
<tr
216+
css={css`
212217
cursor: pointer;
213218
&:hover {
214219
background-color: ${colors.secondary};
215220
}
216221
`}
217-
key={row.id}
218-
onClick={() => gotoOrderDetail(row.original.orderId)}
219-
>
220-
{row.getVisibleCells().map((cell) => (
221-
<td
222-
key={cell.id}
223-
css={css`
222+
key={row.id}
223+
onClick={() => gotoOrderDetail(row.original.orderId)}
224+
>
225+
{row.getVisibleCells().map((cell) => (
226+
<td
227+
key={cell.id}
228+
css={css`
224229
padding: 20px;
225230
`}
226-
>
227-
{flexRender(cell.column.columnDef.cell, cell.getContext())}
228-
</td>
229-
))}
230-
</tr>
231-
))}
232-
</tbody>
233-
</table>
234-
</div>
235-
<div css={_paginationContainer}>
236-
<div
237-
css={css`
231+
>
232+
{flexRender(cell.column.columnDef.cell, cell.getContext())}
233+
</td>
234+
))}
235+
</tr>
236+
))}
237+
</tbody>
238+
</table>
239+
</div>
240+
<div css={_paginationContainer}>
241+
<div
242+
css={css`
238243
color: #3e4954;
239244
`}
240-
>
241-
총 주문 건수: {(orders as any)?.response?.totalCount}
245+
>
246+
총 주문 건수: {(orders as any)?.response?.totalCount}
247+
</div>
248+
<Pagination
249+
currentPage={Number(page)}
250+
// @ts-expect-error 타입이 useQuery에서 안잡혀서 임시로 타입을 무시합니다.
251+
totalCount={orders?.response?.totalCount}
252+
onClickPage={handleClickPage}
253+
onClickPrevPage={handleClickPrevPage}
254+
onClickNextPage={handleClickNextPage}
255+
/>
242256
</div>
243-
<Pagination
244-
currentPage={Number(page)}
245-
// @ts-expect-error 타입이 useQuery에서 안잡혀서 임시로 타입을 무시합니다.
246-
totalCount={orders?.response?.totalCount}
247-
onClickPage={handleClickPage}
248-
onClickPrevPage={handleClickPrevPage}
249-
onClickNextPage={handleClickNextPage}
250-
/>
251257
</div>
252-
</div>
258+
</AuthGuard>
253259
);
254260
};
255261

src/pages/profile/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { css } from "@emotion/react";
33
import useAuth from 'common/hooks/useAuth';
44

55
const Profile = ({ ...rest }) => {
6-
const { AuthGuard } = useAuth(["admin"]);
6+
const { AuthGuard } = useAuth(["admin", "owner"]);
77

88
return (
99
<AuthGuard>

0 commit comments

Comments
 (0)