Browse Source

Merge branch 'master' of http://gitea.palntour.com/pav/pav-home

pull/2/head
junh_eee 2 years ago
parent
commit
29be2190eb
  1. 105
      src/components/basis/flight/plan/FlightPlanAreaForm.js
  2. 28
      src/components/basis/flight/plan/FlightPlanAreaModal.js
  3. 45
      src/components/basis/flight/plan/FlightPlanForm.js
  4. 48
      src/containers/basis/flight/plan/FlightPlanAreaContainer.js
  5. 44
      src/containers/basis/flight/plan/FlightPlanDetailContainer.js
  6. 16
      src/modules/basis/flight/actions/basisFlightAction.ts
  7. 12
      src/modules/basis/flight/models/basisFlightModel.ts
  8. 8
      src/modules/basis/flight/reducers/basisFlightReducer.ts
  9. 18
      src/modules/basis/flight/sagas/basisFlightSaga.ts

105
src/components/basis/flight/plan/FlightPlanAreaForm.js

@ -1,20 +1,24 @@
import React from 'react';
import React, { useState, useEffect } from 'react';
import classnames from 'classnames';
import {
Card,
CardBody,
Col,
FormGroup,
FormFeedback,
Input,
Label,
Row,
Button
Button,
Form
} from 'reactstrap';
const FlightPlanAreaForm = () => {
const FlightPlanAreaForm = (props) => {
return (
<Card>
<CardBody>
<CardBody>
<div className='search-cont search-info pd-0'>
<div className='cont-ti mb-1 d-flex justify-content-between align-items-sm-center align-items-start flex-sm-row'>
<div>
@ -28,57 +32,22 @@ const FlightPlanAreaForm = () => {
</div>
<dl>
<dt>
<dt>
<div className='search-info-box'>
<Row>
<Col className='list-input' lg={6} md={6} sm={12}>
<FormGroup>
<Label for='test'>
<span className='necessary'>*</span>
<span className='necessary'></span>(m)
</Label>
<Input
type='text'
id='ownerNm'
name='ownerNm'
id='radius'
name='radius'
size='sm'
placeholder=''
/>
</FormGroup>
</Col>
</Row>
</div>
<div className='search-info-box'>
<Row>
<Col className='list-input' lg={6} md={6} sm={12}>
<FormGroup>
<Label for='test'>
<span className='necessary'>*</span>
</Label>
<Input
type='text'
id='ownerNm'
name='ownerNm'
size='sm'
placeholder=''
/>
</FormGroup>
</Col>
</Row>
</div>
<div className='search-info-box'>
<Row>
<Col className='list-input' lg={6} md={6} sm={12}>
<FormGroup>
<Label for='test'>
<span className='necessary'>*</span>(m)
</Label>
<Input
type='text'
id='ownerNm'
name='ownerNm'
size='sm'
placeholder=''
/>
placeholder=''
innerRef={props.data}
/>
</FormGroup>
</Col>
</Row>
@ -89,33 +58,55 @@ const FlightPlanAreaForm = () => {
<FormGroup className='m_ft'>
<div className='m_ft_box'>
<Label for='test'>
<span className='necessary'>*</span>(m/ft)
<span className='necessary'></span>(m/ft)
</Label>
<Input
type='text'
id='ownerNm'
name='ownerNm'
id='altitude_m'
name='altitude_m'
size='sm'
placeholder='m'
placeholder='m'
innerRef={props.data}
/>
</div>
<div className='m_ft_box'>
<Input
type='text'
id='ownerNm'
name='ownerNm'
id='altitude'
name='altitude'
size='sm'
placeholder='ft'
placeholder='ft'
innerRef={props.data}
/>
</div>
</div>
</FormGroup>
</Col>
</Col>
</Row>
</div>
<Button.Ripple
className='mr-1'
color='primary'
size='sm'
onClick={
props.submit
}
>
확인
</Button.Ripple>
<Button.Ripple
className='mr-1'
color='danger'
size='sm'
onClick={() =>
props.setModal({ ...props.modal, isOpen: !props.modal.isOpen })
}
>
취소
</Button.Ripple>
</dt>
</dl>
</div>
</div>
</CardBody>
</Card>
)

28
src/components/modal/FormModal.js → src/components/basis/flight/plan/FlightPlanAreaModal.js

@ -1,6 +1,11 @@
import { useState } from 'react';
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import FlightPlanAreaContainer from '../../../../containers/basis/flight/plan/FlightPlanAreaContainer';
export const FlightPlanAreaModal = props => {
const [onSubmit, setOnSubmit] = useState(false);
export const FormModal = props => {
return (
<div className='vertically-centered-modal'>
<Modal
@ -18,19 +23,26 @@ export const FormModal = props => {
{props.modal.title}
</ModalHeader>
<ModalBody>
{props.modal.contents}
<FlightPlanAreaContainer
modal={props.modal}
setModal={props.setModal}
onSubmit={onSubmit}
setOnSubmit={setOnSubmit}
/>
</ModalBody>
<ModalFooter>
{/* <ModalFooter>
<Button
type="submit"
color='primary'
onClick={() =>
props.setModal({ ...props.modal, isOpen: !props.modal.isOpen })
}
// onClick={() =>
// // props.setModal({ ...props.modal, isOpen: !props.modal.isOpen })
// setOnSubmit(true)
// }
outline
>
확인
저장
</Button>
</ModalFooter>
</ModalFooter> */}
</Modal>
</div>
);

45
src/components/basis/flight/plan/FlightPlanForm.js

@ -44,7 +44,7 @@ const FlightPlanForm = (props) => {
<Row>
<Col className='list-input' lg={4} md={6} sm={12}>
<FormGroup>
<Label for='test'>성명</Label>
<Label for='test'><span className='necessary'>*</span></Label>
<Input
type='text'
id='applicantNm'
@ -57,7 +57,7 @@ const FlightPlanForm = (props) => {
</Col>
<Col className='list-input' lg={4} md={6} sm={12}>
<FormGroup>
<Label for='test'>생년월일</Label>
<Label for='test'><span className='necessary'>*</span></Label>
<Input
type='text'
id='applicantBirthDt'
@ -67,10 +67,14 @@ const FlightPlanForm = (props) => {
placeholder=''
/>
</FormGroup>
</Col>
</Col>
</Row>
</div>
<div className='search-info-box'>
<Row>
<Col className='list-input' lg={4} md={6} sm={12}>
<FormGroup>
<Label for='test'>전화번호</Label>
<Label for='test'><span className='necessary'>*</span> </Label>
<Input
type='text'
id='applicantPhone'
@ -81,10 +85,9 @@ const FlightPlanForm = (props) => {
/>
</FormGroup>
</Col>
<Col className='list-input' lg={4} md={6} sm={12}>
<FormGroup>
<Label for='test'>팩스번호</Label>
<Label for='test'><span className='necessary'></span> </Label>
<Input
type='text'
id='applicantPhone'
@ -94,15 +97,16 @@ const FlightPlanForm = (props) => {
placeholder=''
/>
</FormGroup>
</Col>
</Row>
</div>
</Col>
</Row>
</div>
<div className='search-info-box'>
{/* <div className='search-info-box'>
<Row>
<Col className='list-input' lg={4} md={6} sm={12}>
<FormGroup>
<Label for='test'>주소</Label>
<Label for='test'><span className='necessary'>*</span></Label>
<Input
type='text'
id='applicantAddress'
@ -115,7 +119,7 @@ const FlightPlanForm = (props) => {
</Col>
<Col className='list-input' lg={4} md={6} sm={12}>
<FormGroup>
<Label for='test'>상세주소</Label>
<Label for='test'><span className='necessary'>*</span> </Label>
<Input
type='text'
id='applicantAddress'
@ -127,7 +131,7 @@ const FlightPlanForm = (props) => {
</FormGroup>
</Col>
</Row>
</div>
</div> */}
</dt>
<dt>
@ -273,7 +277,8 @@ const FlightPlanForm = (props) => {
id='ownerNm'
name='ownerNm'
size='sm'
placeholder=''
placeholder=''
readOnly
/>
</FormGroup>
</Col>
@ -287,7 +292,8 @@ const FlightPlanForm = (props) => {
id='ownerNm'
name='ownerNm'
size='sm'
placeholder=''
placeholder=''
readOnly
/>
</FormGroup>
</Col>
@ -305,7 +311,8 @@ const FlightPlanForm = (props) => {
id='ownerNm'
name='ownerNm'
size='sm'
placeholder=''
placeholder=''
readOnly
/>
</FormGroup>
</Col>
@ -320,7 +327,8 @@ const FlightPlanForm = (props) => {
id='ownerNm'
name='ownerNm'
size='sm'
placeholder='m'
placeholder='m'
readOnly
/>
</div>
<div className='m_ft_box'>
@ -329,7 +337,8 @@ const FlightPlanForm = (props) => {
id='ownerNm'
name='ownerNm'
size='sm'
placeholder='ft'
placeholder='ft'
readOnly
/>
</div>
</FormGroup>

48
src/containers/basis/flight/plan/FlightPlanAreaContainer.js

@ -1,29 +1,53 @@
import React, { useEffect, useState } from 'react';
import { useForm } from 'react-hook-form';
import {useHistory} from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';
import FlightPlanAreaForm from '../../../../components/basis/flight/plan/FlightPlanAreaForm';
import { Button, Col, Row } from 'reactstrap';
import {Col, Row, Form } from 'reactstrap';
import * as Actions from '../../../../modules/basis/flight/actions/basisFlightAction';
import FlightPlanAreaMap from '../../../../components/basis/flight/plan/FlightPlanAreaMap';
import * as yup from 'yup';
import { yupResolver } from '@hookform/resolvers/yup';
const FlightPlanAreaContainer = () => {
const FlightPlanAreaContainer = (props) => {
const dispatch = useDispatch();
const history = useHistory();
const { areaList } = useSelector(state => state.flightState);
const [airArea, setAirArea] = useState(null);
const validSchema = yup.object().shape({
});
const { register, getValues, setValue, errors, handleSubmit } = useForm({
defaultValues: {
coodinates: [],
radius: '',
altitude_m: '',
altitude_ft: '',
},
resolver: yupResolver(validSchema)
});
const getAriAreaList = () => {
const getAirAreaList = () => {
dispatch(Actions.AREA_LIST.request());
}
const createAirArea = async data => {
dispatch(Actions.FLIGHT_PLAN_AREA.request(data));
props.setModal({ ...props.modal, isOpen: !props.modal.isOpen });
props.setOnSubmit(false);
}
useEffect(() => {
getAriAreaList();
getAirAreaList();
}, []);
useEffect(() => {
setAirArea(areaList);
}, [areaList])
}, [areaList])
return (
<Row>
@ -34,8 +58,14 @@ const FlightPlanAreaContainer = () => {
/>
) : null}
</Col>
<Col md={6} lg={6}>
<FlightPlanAreaForm />
<Col md={6} lg={6}>
<FlightPlanAreaForm
modal={props.modal}
setModal={props.setModal}
data={register}
errors={errors}
submit={handleSubmit(createAirArea)}
/>
</Col>
</Row>

44
src/containers/basis/flight/plan/FlightPlanDetailContainer.js

@ -1,18 +1,38 @@
import React, {useState} from 'react';
import React, {useEffect, useState} from 'react';
import FlightPlanForm from '../../../../components/basis/flight/plan/FlightPlanForm';
import { CustomDetailLayout } from '../../../../components/layout/CustomDetailLayout';
import { FormModal } from '../../../../components/modal/FormModal';
import { FlightPlanAreaModal } from '../../../../components/basis/flight/plan/FlightPlanAreaModal';
import FlightPlanAreaContainer from './FlightPlanAreaContainer';
import {useHistory} from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';
import * as yup from 'yup';
import { yupResolver } from '@hookform/resolvers/yup';
import * as Actions from '../../../../modules/basis/flight/actions/basisFlightAction';
import { useForm } from 'react-hook-form';
const FlightPlanDetailContainer = () => {
const dispatch = useDispatch();
const history = useHistory();
const { flightPlanArea } = useSelector(state => state.flightState);
const [areaInfo, setAreaInfo] = useState();
const [modal, setModal] = useState({
isOpen: false,
title: '',
contents: '',
title: '',
});
/* Form Validation Checking */
const validSchema = yup.object().shape({
});
const {} = useForm({
defaultValues: {
coodinates: [],
radius: '',
altitude_m: '',
altitude_ft: '',
},
resolver: yupResolver(validSchema)
})
const saveFlightPlanArea = () => {
console.log('비행 구역 설정 저장');
@ -21,20 +41,24 @@ const FlightPlanDetailContainer = () => {
const openModal = () => {
setModal({
isOpen: true,
title: '비행 구역 설정',
contents: <FlightPlanAreaContainer />
title: '비행 구역 설정',
});
}
useEffect(() => {
setAreaInfo(flightPlanArea);
}, [flightPlanArea]);
return (
<CustomDetailLayout title={"비행 계획 신청서"}>
<FlightPlanForm
openModal={openModal}
areaInfo={areaInfo}
/>
<FormModal
<FlightPlanAreaModal
modal={modal}
save={saveFlightPlanArea}
setModal={setModal}
setModal={setModal}
/>
</CustomDetailLayout>
)

16
src/modules/basis/flight/actions/basisFlightAction.ts

@ -1,6 +1,6 @@
import { AxiosError } from 'axios';
import { createAsyncAction, ActionType} from 'typesafe-actions';
import { FlightAreaData } from '../models/basisFlightModel';
import { FlightAreaData, FlightPlanArea } from '../models/basisFlightModel';
// 공역 조회
@ -8,14 +8,26 @@ const AREA_LIST_REQUEST = 'basis/flight/area/LIST_REQUEST';
const AREA_LIST_SUCCESS = 'basis/flight/area/LIST_SUCCESS';
const AREA_LIST_FAILURE = 'basis/flight/area/LIST_FAILURE';
// 비행 구역 설정
const FLIGHT_PLAN_AREA_REQUEST = 'basis/flight/plan/area/LIST_REQUEST';
const FLIGHT_PLAN_AREA_SUCCESS = 'basis/flight/plan/area/LIST_SUCCESS';
const FLIGHT_PLAN_AREA_FAILURE = 'basis/flight/plan/area/LIST_FAILURE';
export const AREA_LIST = createAsyncAction(
AREA_LIST_REQUEST,
AREA_LIST_SUCCESS,
AREA_LIST_FAILURE
)<FlightAreaData, { data: FlightAreaData }, AxiosError>();
export const FLIGHT_PLAN_AREA = createAsyncAction(
FLIGHT_PLAN_AREA_REQUEST,
FLIGHT_PLAN_AREA_SUCCESS,
FLIGHT_PLAN_AREA_FAILURE
)<FlightPlanArea, { data: FlightPlanArea }, AxiosError>();
const actions = {
AREA_LIST
AREA_LIST,
FLIGHT_PLAN_AREA
};
export type FlightAction = ActionType<typeof actions>;

12
src/modules/basis/flight/models/basisFlightModel.ts

@ -1,11 +1,21 @@
export interface FlightState {
areaList: FlightAreaData | undefined
flightPlanArea: FlightPlanArea | undefined
}
export interface FlightAreaData {
areaList: []
}
export interface FlightPlanArea {
address : '',
coordinates : '',
redius : '',
altitude_m : '',
altitude_ft : '',
}
export const initFlight = {
areaList: undefined
areaList: undefined,
flightPlanArea: undefined
};

8
src/modules/basis/flight/reducers/basisFlightReducer.ts

@ -12,4 +12,10 @@ export const flightReducer = createReducer<FlightState, Actions.FlightAction> (
const {data} = action.payload;
draft.areaList = data;
})
) ;
)
.handleAction(Actions.FLIGHT_PLAN_AREA.request, (state, action) =>
produce(state, draft => {
const data = action.payload;
draft.flightPlanArea = data;
})
)

18
src/modules/basis/flight/sagas/basisFlightSaga.ts

@ -38,6 +38,24 @@ function* listAreaSaga(action: ActionType<typeof Actions.AREA_LIST.request>) {
}
}
function* createFlightPlanArea(action: ActionType<typeof Actions.FLIGHT_PLAN_AREA.request>) {
try {
const data = action.payload;
yield put(
Actions.FLIGHT_PLAN_AREA.success({
data: data
})
)
} catch (error: any) {
yield put(
Actions.FLIGHT_PLAN_AREA.failure(error)
)
}
}
export function* flightSaga() {
yield takeEvery(Actions.AREA_LIST.request, listAreaSaga);
yield takeEvery(Actions.FLIGHT_PLAN_AREA.request, createFlightPlanArea);
}
Loading…
Cancel
Save