Skip to content

Commit

Permalink
Merge pull request #72 from PLADI-ALM/feat/PDW-36-manager-resources-s…
Browse files Browse the repository at this point in the history
…earch-api-2

[PDW-36/feat] 자원 관리 페이지 검색 api 연결
  • Loading branch information
psyeon1120 authored Oct 14, 2023
2 parents bfcc2b3 + d19d789 commit 2b3d43e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
34 changes: 31 additions & 3 deletions src/pages/manager/resourceManage/ResourceManage.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
import React from "react";
import { useState, useEffect } from "react";
import axios from "axios";
import { RightContainer, TitleText, WhiteContainer } from "components/rightContainer/RightContainer";
import { Bar, BookedTable, BookedThead, TableContainer } from "../../booking/bookedList/BookedList";
import ResourceManageTableCell from "./ResourceManageTableCell";
import ManageSearchBar from "components/searchBar/ManageSearchBar";
import { getToken } from "utils/IsLoginUtil";
import { basicError } from "utils/ErrorHandlerUtil";
import { AdminBookingResourceAxios } from "api/AxiosApi";


function ResourceManage(props) {

const [resources, setResources] = useState([]);

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

const getSearchResources = (e) => {
getResources(e.target.value)
};

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


return (
<RightContainer>
<TitleText>{props.title}</TitleText>
<ManageSearchBar buttonTitle="자원 추가"/>
<ManageSearchBar buttonTitle="자원 추가" onEnter={getSearchResources}/>

<WhiteContainer>
<Bar />
Expand All @@ -27,7 +49,13 @@ function ResourceManage(props) {
</tr>
</BookedThead>
<tbody>
<ResourceManageTableCell name={"MAcBookPro"} category={"전자기기"} description={"맥북 프로가 가지고 싶다면 이걸로 대여해서 코딩하세요"}/>
{ resources.length === 0 ?
<ResourceManageTableCell>
<td colSpan={4}>자원 내역이 없습니다.</td>
</ResourceManageTableCell>
: resources.map((resource) =>
<ResourceManageTableCell key={resource.resourceId} id={resource.resourceId} name={resource.name} category={resource.category} description={resource.description}/>
)}
</tbody>
</BookedTable>
</TableContainer>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { BookedLineTr } from '../../booking/bookedList/BookedList';


Expand Down

0 comments on commit 2b3d43e

Please sign in to comment.