From 4d8839c888177069f35c281cf153f6d2e8da8b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?qkr7828=28=EB=B0=95=EC=9E=AC=EC=9A=B0=29?= Date: Tue, 9 Aug 2022 10:56:50 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A1=B0=EC=A2=85=EC=82=AC=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basis/flight/plan/FlightPlanPilot.js | 55 ++++++++++++- .../flight/plan/FlightPlanPilotContainer.js | 79 ++++++++----------- 2 files changed, 86 insertions(+), 48 deletions(-) diff --git a/src/components/basis/flight/plan/FlightPlanPilot.js b/src/components/basis/flight/plan/FlightPlanPilot.js index ef4d7846..2aa4fdf0 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 8dd72f24..f58efd79 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} + /> ) }