From 41c11e53c9a80713c99e968658ab4dbbfbdc5323 Mon Sep 17 00:00:00 2001 From: psyeon1120 Date: Fri, 3 Nov 2023 04:18:48 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[PDW-69]=20refactor:=20=EC=9D=BC=EB=B0=98?= =?UTF-8?q?=20=EC=82=AC=EC=9B=90=20=EC=98=88=EC=95=BD=20=EB=B0=98=EB=82=A9?= =?UTF-8?q?=20=EA=B8=B0=EB=8A=A5=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 5 +- src/components/sidebar/MenuLineStyle.js | 29 +++++------ src/constants/Path.js | 10 ++-- src/pages/basic/myBookings/BookedLine.js | 62 +++++++++--------------- src/pages/basic/myBookings/BookedList.js | 56 +++++---------------- 5 files changed, 58 insertions(+), 104 deletions(-) diff --git a/src/App.js b/src/App.js index 27de54c..e258acb 100644 --- a/src/App.js +++ b/src/App.js @@ -34,10 +34,11 @@ function App() { }> } /> } /> - } /> + } /> } /> - } /> + } /> } /> + } /> } /> } /> } /> diff --git a/src/components/sidebar/MenuLineStyle.js b/src/components/sidebar/MenuLineStyle.js index 281696f..c3858a5 100644 --- a/src/components/sidebar/MenuLineStyle.js +++ b/src/components/sidebar/MenuLineStyle.js @@ -1,20 +1,21 @@ -import { styled } from 'styled-components'; -import { Link } from "react-router-dom"; +import {styled} from 'styled-components'; +import {Link} from "react-router-dom"; export const InactiveMenuLine = styled(Link)` - padding: 3px 20px; - margin-bottom: 13px; - cursor: pointer; - display: flex; - align-items: center; - color: #717171; - font-size: 19px; - border-left: 5px solid white; - &:hover { - color: #8741CB; - } + padding: 3px 20px; + margin-bottom: 13px; + cursor: pointer; + display: flex; + align-items: center; + color: #717171; + font-size: 19px; + border-left: 5px solid white; + + &:hover { + color: #8741CB; + } ` export const ActiveMenuLine = styled(InactiveMenuLine)` - color: #8741CB; + color: #8741CB; ` \ No newline at end of file diff --git a/src/constants/Path.js b/src/constants/Path.js index 9270125..60a7b3a 100644 --- a/src/constants/Path.js +++ b/src/constants/Path.js @@ -43,14 +43,14 @@ export const ADMIN_MAIN_MENUS = [ export const MAIN_PATH = '/officeBooking' -export const BookingCategoryPathList = [ - "offices", "resources" +export const BookingCategoryList = [ + "offices", "resources", "cars" ] export function getBookingCategoryPath(koreanName) { if (koreanName === '회의실') { - return BookingCategoryPathList[0] - } else if (koreanName === '장비') { - return BookingCategoryPathList[1] + return BookingCategoryList[0] + } else if (koreanName === '장비' || koreanName === '차량') { + return BookingCategoryList[1] } } \ No newline at end of file diff --git a/src/pages/basic/myBookings/BookedLine.js b/src/pages/basic/myBookings/BookedLine.js index a1bbe43..48d31f3 100644 --- a/src/pages/basic/myBookings/BookedLine.js +++ b/src/pages/basic/myBookings/BookedLine.js @@ -1,74 +1,60 @@ import React from 'react'; -import { Link } from 'react-router-dom'; +import {Link} from 'react-router-dom'; import SmallButton from 'components/button/SmallButton'; -import { BOOKED, USING, WAITING, findStatus } from 'constants/BookingStatus'; -import { BookingsAxios } from 'api/AxiosApi'; -import { BookedLineTr } from './BookedList'; -import { BookingCategoryPathList } from 'constants/Path'; -import { StatusText, StatusContainer, StatusCircle } from 'components/booking/StatusTag'; -import { basicError } from 'utils/ErrorHandlerUtil'; +import {BOOKED, USING, WAITING, findStatus} from 'constants/BookingStatus'; +import {BookingsAxios} from 'api/AxiosApi'; +import {BookedLineTr} from './BookedList'; +import {BookingCategoryList} from 'constants/Path'; +import {StatusText, StatusContainer, StatusCircle} from 'components/booking/StatusTag'; +import {basicError} from 'utils/ErrorHandlerUtil'; import {getToken} from "../../../utils/IsLoginUtil"; function cancelBooking(bookingId, name, info, start, end, type) { if (window.confirm(`${name}(${info}) ${start} ~ ${end}\n예약을 취소하시겠습니까?`)) { - BookingsAxios.patch(`/${type}/${bookingId}/cancel`, + BookingsAxios.patch(`/${type}/${bookingId}/cancel`, null, { headers: { Authorization: getToken() } }) - .catch((error) => { - basicError(error) - }) - alert("취소되었습니다.") - window.location.reload() - } -} - -function returnBooking(bookingId, name, info, start, end) { - if (window.confirm(`${name}(${info}) ${start} ~ ${end}\n장비를 반납하시겠습니까?`)) { - BookingsAxios.patch(`/resources/${bookingId}/return`, - { - headers: { - Authorization: getToken() + .then(() => { + alert("취소되었습니다.") + window.location.reload() } - }) + ) .catch((error) => { basicError(error) }) - alert("반납되었습니다.") - window.location.reload() } } function BookedLine(props) { - var status = findStatus(props.status) - + const status = findStatus(props.status); return ( <> - {props.name}({props.info}) + {props.name}({props.info}) + {props.start} ~ {props.end} - + {props.status} { - (props.type === BookingCategoryPathList[0]) ? + (props.type === BookingCategoryList[0]) ? // 회의실 - ((status === BOOKED) || (props.status === USING)) ? + ((status === BOOKED) || (status === USING)) ? - cancelBooking(props.id, props.name, props.info, props.start, props.end, props.type)} name={'취소'} /> + cancelBooking(props.id, props.name, props.info, props.start, props.end, props.type)} + name={'취소'}/> : null : - // 장비 + // 장비, 차량 ((status === WAITING) || (status === BOOKED)) ? - cancelBooking(props.id, props.name, props.info, props.start, props.end, props.type)} name={'취소'} /> - : (status === USING) ? - - returnBooking(props.id, props.name, props.info, props.start, props.end)} name={'반납'} /> - : null + cancelBooking(props.id, props.name, props.info, props.start, props.end, props.type)} + name={'취소'}/> + : null } diff --git a/src/pages/basic/myBookings/BookedList.js b/src/pages/basic/myBookings/BookedList.js index 8c1fa98..785bd10 100644 --- a/src/pages/basic/myBookings/BookedList.js +++ b/src/pages/basic/myBookings/BookedList.js @@ -1,13 +1,10 @@ -import React, { useEffect, useState } from 'react'; +import React, {useEffect, useState} from 'react'; import styled from "styled-components" import BookedLine from './BookedLine'; -import { RightContainer, WhiteContainer, TitleText } from "components/rightContainer/RightContainer"; -import { BookingsAxios } from 'api/AxiosApi'; -import { SelectToggle } from 'components/capsule/SelectToggle'; -import { BookingCategoryList } from 'constants/ToggleList'; -import { BookingCategoryPathList, getBookingCategoryPath } from 'constants/Path'; -import { getToken } from 'utils/IsLoginUtil'; -import { basicError } from 'utils/ErrorHandlerUtil'; +import {RightContainer, TitleText, WhiteContainer} from "components/rightContainer/RightContainer"; +import {BookingsAxios} from 'api/AxiosApi'; +import {getToken} from 'utils/IsLoginUtil'; +import {basicError} from 'utils/ErrorHandlerUtil'; const TitleContainer = styled.div` display: flex; @@ -61,30 +58,13 @@ export const NoLineTr = styled.tr` border-bottom: #E1E0E2 solid 1px; ` -const optionList = BookingCategoryList.map((category) => ()) - function BookedList(props) { const [bookings, setBookingList] = useState([]) - const [category, setCategory] = useState(BookingCategoryList[0]) - const [categoryPath, setCategoryPath] = useState(BookingCategoryPathList[0]) - // 회의실 예약내역 - const getOfficeBookingList = () => { - BookingsAxios.get("?category=office", { - headers: { - Authorization: getToken() - } - }) - .then((response) => { setBookingList(response.data.data.content) }) - .catch((error) => { - basicError(error) - }) - } - - // 장비 예약내역 - const getResourceBookingList = () => { - BookingsAxios.get("?category=resource", { + // 예약내역 + const getBookingList = () => { + BookingsAxios.get(`${props.type}`, { headers: { Authorization: getToken() } @@ -96,27 +76,13 @@ function BookedList(props) { } useEffect(() => { - getOfficeBookingList() - }, []) - - useEffect(() => { - if (category === BookingCategoryList[0]) { - getOfficeBookingList() - } else { - getResourceBookingList() - } - }, [category]) - - const changeCategory = (e) => { - setCategory(e.target.value) - setCategoryPath(getBookingCategoryPath(e.target.value)) - } + getBookingList() + }, [props.type]) return ( {props.title} - @@ -143,7 +109,7 @@ function BookedList(props) { start={booking.startDateTime} end={booking.endDateTime} status={booking.status} - type={categoryPath} + type={props.type} />)} From 7baa252fb47d26fbbaa2868a809b433408083f79 Mon Sep 17 00:00:00 2001 From: psyeon1120 Date: Sat, 4 Nov 2023 23:56:40 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[PDW-69]=20refactor:=20APP=20Route=20?= =?UTF-8?q?=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 79 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/src/App.js b/src/App.js index e258acb..8acf66c 100644 --- a/src/App.js +++ b/src/App.js @@ -20,42 +20,51 @@ import OfficeManageDetail from 'pages/admin/office/OfficeBookingManageDetail'; function App() { - const SidebarLayout = () => ( - <> - - - - ) + const SidebarLayout = () => ( + <> + + + + ) - return ( -
- - } /> - }> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - - -
- ) + return ( +
+ + }/> + }>\ + }> + }/> + + }> + }/> + + }> + }/> + + }> + + }> + }/> + + }> + }/> + + }> + }/> + + }> + }/> + }/> + }/> + + }> + }/> + + }/> + + +
+ ) } export default App;