Skip to content

Commit

Permalink
Merge pull request #131 from PLADI-ALM/feat/PDW-77-select-car
Browse files Browse the repository at this point in the history
[PDW-77/feat] 9주차 백로그
  • Loading branch information
psyeon1120 authored Nov 12, 2023
2 parents e2ea172 + ca3cdb4 commit d566aa4
Show file tree
Hide file tree
Showing 19 changed files with 1,405 additions and 73 deletions.
2 changes: 1 addition & 1 deletion src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
text-align: center;
height: 100vh;
width: 100vw;
min-height: 700px;
min-height: 680px;
display: flex;
}
15 changes: 13 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ import ResourceManage from 'pages/admin/resource/ResourceManage';
import ResourceManageAdd from "./pages/admin/resource/ResourceManageAdd";
import ResourceManageDetail from 'pages/admin/resource/ResourceManageDetail';
import OfficeManageDetail from 'pages/admin/office/OfficeManageDetail';
import SelectCar from "./pages/basic/booking/car/SelectCar";
import CarBooking from "./pages/basic/booking/car/CarBooking";
import CarBookingCheck from "./pages/basic/booking/car/CarBookingCheck";
import CarManage from "./pages/admin/car/CarManage";
import CarBookingManage from "./pages/admin/carBookings/CarBookingManage";

function App() {

Expand All @@ -34,13 +39,16 @@ function App() {
<Route element={<SidebarLayout />}>
<Route path="/officeBooking" element={<SelectOffice/>} />
<Route path="/officeBooking/:officeId" element={<OfficeBooking />} />
<Route path='/resourceBooking' element={<SelectResource />} />
<Route path='/resourceBooking/:resourceId' element={<ResourceBooking />} />
<Route path='/carBooking' element={<SelectCar />} />
<Route path='/carBooking/:carId' element={<CarBooking />} />
<Route path="/my/bookings/offices" element={<BookedList title="회의실 예약 내역" type={"offices"} />} />
<Route path="/my/bookings/offices/:bookingId" element={<OfficeBookingCheck isAdmin={false} />} />
<Route path="/my/bookings/resources" element={<BookedList title="장비 예약 내역" type={"resources"} />} />
<Route path='/my/bookings/resources/:bookingId' element={<ResourceBookingCheck />} />
<Route path="/my/bookings/cars" element={<BookedList title="차량 예약 내역" type={"cars"} />} />
<Route path='/resourceBooking' element={<SelectResource />} />
<Route path='/resourceBooking/:resourceId' element={<ResourceBooking />} />
<Route path='/my/bookings/cars/:bookingId' element={<CarBookingCheck />} />
<Route path='/admin/offices' element={<OfficeManage />} />
<Route path='/admin/offices/:officeId' element={<OfficeManageDetail />} />
<Route path='/admin/officeBooking' element={<OfficeBookingManage />} />
Expand All @@ -51,6 +59,9 @@ function App() {
<Route path='/admin/resources/:resourceId' element={<ResourceManageDetail/>} />
<Route path='/admin/resourceBooking' element={<ResourceBookingManage/>} />
<Route path='/admin/resourceBooking/:bookingId' element={<ResourceBookingCheck isAdmin={true} />} />
<Route path='/admin/cars' element={<CarManage />} />
<Route path='/admin/carBooking' element={<CarBookingManage/>} />
<Route path='/admin/carBooking/:bookingId' element={<CarBookingCheck isAdmin={true} />} />
<Route path='/admin/users' element={<UserManage />} />
</Route>
</Routes>
Expand Down
9 changes: 6 additions & 3 deletions src/components/card/ResourceInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ const ResourceTitleContainer = styled.div`
align-items: center;
`

function moveToDetail(resourceId) {
window.location.href = "/resourceBooking/"+resourceId
function moveToDetail(id, type) {
if (type === 'resource')
window.location.href = "/resourceBooking/"+id
else if (type === 'car')
window.location.href = "/carBooking/"+id
}

function ResourceInfo(props) {
return (
<ResourceCardClick onClick={() => moveToDetail(props.resourceId)}>
<ResourceCardClick onClick={() => moveToDetail(props.id, props.type)}>
<DetailContainer>
<ResourceCardImage src={props.imgUrl} />

Expand Down
2 changes: 1 addition & 1 deletion src/components/sidebar/MenuLineStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Link} from "react-router-dom";

export const InactiveMenuLine = styled(Link)`
padding: 3px 20px;
margin-bottom: 13px;
margin-bottom: 10px;
cursor: pointer;
display: flex;
align-items: center;
Expand Down
28 changes: 14 additions & 14 deletions src/components/sidebar/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,9 @@ const SubMenus = styled.div`
display: ${props => props.active ? 'block' : 'none'}
`

const MyBox = styled.div`
margin-bottom: 20px;
`

const MyInfo = styled.div`
padding: 3px 0;
margin: 0 20px 18px 20px;
margin: 0 0 10px 20px;
width: fit-content;
display: flex;
align-items: center;
Expand All @@ -60,15 +56,21 @@ const MyInfo = styled.div`
border-left: 5px solid white;
`

const ManageBtn = styled.div`
text-decoration: underline;
cursor: pointer;
margin-left: 10px;
`

const Logout = styled(MyInfo)`
color: #A65959;
cursor: pointer;
`

// 해당 상위 메뉴의 하위 메뉴 활성화 여부
function useIsSubMenuActive(subMenuList) {
var currentPath = useLocation().pathname
for (var i = 0; i < subMenuList.length; i++) {
const currentPath = useLocation().pathname;
for (let i = 0; i < subMenuList.length; i++) {
if (currentPath.startsWith(subMenuList[i].path))
return true
}
Expand Down Expand Up @@ -101,9 +103,8 @@ function Sidebar() {
navigateToLogin()

const [userName, setUserName] = useState("")
const [info, setInfo] = useState("")

// 이름, 직급
// 이름
const getUserInfo = () => {
UsersAxios.get("/position", {
headers: {
Expand All @@ -112,7 +113,6 @@ function Sidebar() {
})
.then((response) => {
setUserName(response.data.data.name)
setInfo(response.data.data.position)
})
.catch((error) => {
basicError(error)
Expand Down Expand Up @@ -157,13 +157,13 @@ function Sidebar() {

</div>

<MyBox>
<div>
{/* 사원 정보 */}
<MyInfo><Icon src={MyInfoIcon} />{userName} {info}</MyInfo>
<MyInfo><Icon src={MyInfoIcon} />{userName}<ManageBtn>관리</ManageBtn></MyInfo>
{/* 로그아웃 */}
<Logout onClick={logout}><Icon src={LogoutIcon} />로그아웃</Logout>
</MyBox>
</Container >
</div>
</Container>
)
}

Expand Down
80 changes: 80 additions & 0 deletions src/pages/admin/car/CarManage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import React, {useEffect, useState} from "react";
import {RightContainer, TitleText, WhiteContainer} from "components/rightContainer/RightContainer";
import {Bar, BookedTable, BookedThead, NoLineTr, TableContainer} from "pages/basic/myBookings/BookedList";
import CarManageTableCell from "./CarManageTableCell";
import ManageSearchBar from "components/searchBar/ManageSearchBar";
import {getToken} from "utils/IsLoginUtil";
import {basicError} from "utils/ErrorHandlerUtil";
import {AdminCarsAxios} from "api/AxiosApi";

function CarManage(props) {

const [cars, setCars] = useState([]);

const getCars = (name) => {
AdminCarsAxios.get(`?keyword=${name}`, {
headers: {
Authorization: getToken()
}
})
.then((Response) => { setCars(Response.data.data.content) })
.catch((error) => {basicError(error)})
};

const searchCars = (e) => {
getCars(e.target.value)
};

useEffect(() => {
getCars("");
}, [])

const moveToAdd = () => {
window.location.href = `/admin/cars/add`
}

return (
<RightContainer>
<TitleText>차량 관리</TitleText>
<ManageSearchBar selectOptions={null} buttonTitle="차량 추가" onEnter={searchCars} btnClick={moveToAdd}/>
<WhiteContainer>
<Bar />
<TableContainer>
<BookedTable>
<BookedThead>
<tr>
<th width="15%">차량명</th>
<th width="10%">제조사</th>
<th width="10%">현재위치</th>
<th width="15%">책임자</th>
<th width="30%">설명</th>
<th width="8%"></th>
</tr>
</BookedThead>
<tbody>
{ cars.length === 0 ?
<NoLineTr>
<td colSpan={5}>차량 내역이 없습니다.</td>
</NoLineTr>
: cars.map((car) =>
<CarManageTableCell
key={car.carId}
id={car.carId}
name={car.name}
manufacturer={car.location}
location={car.location}
user={car.responsibilityName}
userPhone={car.responsibilityPhone}
description={car.description}
isEnable={car.isActive}
/>
)}
</tbody>
</BookedTable>
</TableContainer>
</WhiteContainer>
</RightContainer>
);
}

export default CarManage;
Loading

0 comments on commit d566aa4

Please sign in to comment.