diff --git a/src/components/basis/flight/plan/FlightPlanPilot.js b/src/components/basis/flight/plan/FlightPlanPilot.js index ef4d784..2aa4fdf 100644 --- a/src/components/basis/flight/plan/FlightPlanPilot.js +++ b/src/components/basis/flight/plan/FlightPlanPilot.js @@ -4,7 +4,7 @@ import {Search} from 'react-feather'; import {GridDatabase} from '../../../crud/grid/GridDatatable'; import { AiOutlineSearch } from 'react-icons/ai'; -const FlightPlanPilot = ({ pilotList, handleSelectPilot, returnPilot, onClickEvent, onChange, inputVal }) => { +const FlightPlanPilot = ({ handleSelectPilot, returnPilot, onClickEvent, onChange,name}) => { const columns = [ {id: 'groupNm', name: '그룹 명', cell: row => (
{row.groupNm}
)}, @@ -52,13 +52,13 @@ const FlightPlanPilot = ({ pilotList, handleSelectPilot, returnPilot, onClickEve
- +
+
+
+
+

조종사 목록

+ 검색결과 총 {!!returnPilot ? returnPilot.length : 0}건 +
+
+
+
+ +
+ +
+
+
+
+ + + {/* {inputVal !== '' ? (
@@ -100,6 +124,29 @@ const FlightPlanPilot = ({ pilotList, handleSelectPilot, returnPilot, onClickEve
+ ):( +
+
+
+

조종사 목록

+ 검색결과 총 {!!pilotList ? pilotList.length : 0}건 +
+
+
+
+ +
+ +
+
+
+
+ )} */} ) diff --git a/src/containers/basis/flight/plan/FlightPlanPilotContainer.js b/src/containers/basis/flight/plan/FlightPlanPilotContainer.js index 8dd72f2..f58efd7 100644 --- a/src/containers/basis/flight/plan/FlightPlanPilotContainer.js +++ b/src/containers/basis/flight/plan/FlightPlanPilotContainer.js @@ -1,82 +1,73 @@ -import React, {useEffect, useState} from 'react'; -import {useDispatch, useSelector} from 'react-redux'; +import React, { useEffect, useState } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; import * as Actions from '../../../../modules/basis/flight/actions/basisFlightAction'; import FlightPlanPilot from '../../../../components/basis/flight/plan/FlightPlanPilot'; -const FlightPlanPilotContainer = ({handleModal, type}) => { +const FlightPlanPilotContainer = ({ handleModal, type }) => { const dispatch = useDispatch(); const { pilotList, selectGroup } = useSelector(state => state.flightState); const [returnPilot, setReturnPilot] = useState(''); - const [inputVal , setInputVal] = useState(''); - const [text, setText] = useState(''); + const [name , setName] = useState(''); /* 조종사 조회 */ - const handleSearch = () => { + const handleSearch = () => { const groupId = sessionStorage.getItem('groupId'); - - if(groupId) { + + if (groupId) { dispatch(Actions.FLIGHT_PLAN_PILOT_LIST.request(groupId)); - } + } } /* 조종사 선택 */ const handleSelectPilot = (cstmrSno) => { - handleModal({target: 'pilot', isOpen: false}); + handleModal({ target: 'pilot', isOpen: false }); const pilot = pilotList.find(pilot => { return pilot.cstmrSno === cstmrSno; - }); + }); /* 파일럿 정보 Redux 저장 */ dispatch(Actions.PILOT_SELECT(pilot)); } - + useEffect(() => { handleSearch(); + // setReturnPilot(''); }, []) - useEffect(()=> { - if(pilotList) { - onTest(); - } - },[pilotList]) + useEffect(() => { + setReturnPilot(pilotList) + }, [pilotList]) - const onChange = (e) => { - setInputVal(e.target.value); - }; - const onClickEvent= (e)=> { - - - onTest(); - setInputVal(''); + const onChange =(e) =>{ + setName(e.target.value); } + + const onClickEvent = () => { + + const filterPilot = pilotList.filter(pilot => pilot.memberName.includes(name)); + + if (name === '') { + const resetPilots = pilotList; + setReturnPilot(resetPilots) + } else { + setReturnPilot(filterPilot) + } + + }; + - const onTest = () => { - const [MATCHVALUE] = pilotList.filter((unit) => - unit.memberName.toLowerCase().includes(inputVal)); - pilotList.filter((unit) =>{ - if(inputVal==''){ - setReturnPilot(unit) - }else if(unit.memberName.includes(inputVal)){ - setReturnPilot(MATCHVALUE) - }else if (inputVal != ''){ - setReturnPilot('') - } - }) - } return ( - + name={name} + /> ) }