|
|
|
@ -1,28 +1,27 @@
|
|
|
|
|
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 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; |
|
|
|
@ -33,49 +32,41 @@ const FlightPlanPilotContainer = ({handleModal, type}) => {
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
handleSearch(); |
|
|
|
|
// setReturnPilot('');
|
|
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
useEffect(()=> { |
|
|
|
|
if(pilotList) { |
|
|
|
|
onTest(); |
|
|
|
|
} |
|
|
|
|
},[pilotList]) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
setReturnPilot(pilotList) |
|
|
|
|
}, [pilotList]) |
|
|
|
|
|
|
|
|
|
const onChange = (e) => { |
|
|
|
|
setInputVal(e.target.value); |
|
|
|
|
}; |
|
|
|
|
const onClickEvent= (e)=> { |
|
|
|
|
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) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
onTest(); |
|
|
|
|
setInputVal(''); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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 ( |
|
|
|
|
<FlightPlanPilot |
|
|
|
|
handleSelectPilot={handleSelectPilot} |
|
|
|
|
handleSearch={handleSearch} |
|
|
|
|
onClickEvent={onClickEvent} |
|
|
|
|
onChange={onChange} |
|
|
|
|
pilotList={pilotList} |
|
|
|
|
onChange={onChange} |
|
|
|
|
returnPilot={returnPilot} |
|
|
|
|
setInputVal={setInputVal} |
|
|
|
|
inputVal={inputVal} |
|
|
|
|
|
|
|
|
|
name={name} |
|
|
|
|
/> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|