Skip to content

Commit

Permalink
Merge pull request #125 from PLADI-ALM/refactor/PDW-70-search-resource
Browse files Browse the repository at this point in the history
[PDW-70/fix] 장비 목록 검색 API 연결
  • Loading branch information
psyeon1120 authored Nov 6, 2023
2 parents 7a219b0 + 1fefdfe commit 9a7b8f7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/components/searchBar/ManageSearchBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const ManageSearchText = styled.input`
background: none;
border: none;
outline: none;
width: 100%;
`

export const ManageAddButton = styled.button`
Expand Down
9 changes: 6 additions & 3 deletions src/pages/basic/booking/office/SelectOffice.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ function SelectOffice(props) {
const [offices, setOffices] = useState([]);
const facilityName = useRef("");
const [date, setDate] = useState("");
const [startTime, setStartTime] = useState("");
const [endTime, setEndTime] = useState("");
const [startTime, setStartTime] = useState("00:00");
const [endTime, setEndTime] = useState("00:00");

const changeFacilityName = (e) => {
facilityName.current = e.target.value;
Expand All @@ -47,7 +47,10 @@ function SelectOffice(props) {
}

const searchOffice = () => {
OfficesAxios.get(`?date=${date}&startTime=${startTime}&endTime=${endTime}&facilityName=${facilityName.current}`, {
let url = `?facilityName=${facilityName.current}`
if (date !== "")
url = `?facilityName=${facilityName.current}&date=${date}&startTime=${startTime}&endTime=${endTime}`
OfficesAxios.get(url, {
headers: {
Authorization: getToken()
}
Expand Down
22 changes: 13 additions & 9 deletions src/pages/basic/booking/resource/SelectResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ function SelectResource(props) {
const resourceName = useRef("");
const [startDate, setStartDate] = useState("");
const [endDate, setEndDate] = useState("");
const [startTime, setStartTime] = useState("");
const [endTime, setEndTime] = useState("");
const [startTime, setStartTime] = useState("00:00");
const [endTime, setEndTime] = useState("00:00");

useEffect(() => {
searchResource();
Expand All @@ -46,16 +46,20 @@ function SelectResource(props) {
setEndDate(e.target.value)
}

const changeStart = (e) => {
const changeStartTime = (e) => {
setStartTime(e.target.value)
}

const changeEnd = (e) => {
const changeEndTime = (e) => {
setEndTime(e.target.value)
}

const searchResource = () => {
ResourcesAxios.get(`?resourceName=${resourceName.current}&startDate=${startDate}&endDate=${endDate}`,
// var bookingPurpose = document.getElementById("bookingPurpose").value;
let url = `?resourceName=${resourceName.current}`;
if (startDate !== "" && endDate !== "")
url = `?resourceName=${resourceName.current}&startDate=${startDate} ${startTime}&endDate=${endDate} ${endTime}`;
ResourcesAxios.get(url,
{
headers: {
Authorization: getToken()
Expand All @@ -80,11 +84,11 @@ function SelectResource(props) {
<SearchTextInput placeholder="장비명 검색" onChange={changeResourceName}/>

<SearchDateContainer>
<SearchDateInput onChange={changeStartDate}/>
<TimeDropBox change={changeStart}/>
<SearchDateInput value={startDate} onChange={changeStartDate}/>
<TimeDropBox change={changeStartTime}/>
~
<SearchDateInput onChange={changeEndDate}/>
<TimeDropBox change={changeEnd}/>
<SearchDateInput value={endDate} onChange={changeEndDate}/>
<TimeDropBox change={changeEndTime}/>
</SearchDateContainer>

<ImagePaddingButton image={SearchButtonImg} width={"40px"} height={"40px"} background={"#717171"} click={searchResource}/>
Expand Down

0 comments on commit 9a7b8f7

Please sign in to comment.