import React, { useRef, useEffect, useState } from 'react'; import axios from 'axios'; import { Link, useHistory } from 'react-router-dom'; import Notification from '../notification'; import moment from 'moment'; import Alert from '../../component/alert'; import ModalPdf from '../../component/pdf/modal_pdf'; import ModalMemo from '../../component/modal_memo'; import ModalConfirm from '../../component/modal_confirm'; import Thumbnail from '../../component/thumbnail'; import PageLoader from '../../component/page_loader'; const MeetingDetail = (props) => { const history = useHistory(); const [notice, setNotice] = useState(localStorage.getItem('notice')); const [loaded, setLoaded] = useState(false); const [meeting, setMeeting] = useState(null); const [thumbnail, setThumbnail] = useState(''); const [_approval_register, setApprovalRegister] = useState(false); const [show_pdf_modal, setShowPDFModal] = useState(false); const [show_memo_modal, setShowMemoModal] = useState(false); const [show_confirm_modal, setShowConfirmMoal] = useState(false); const [submit, setSubmit] = useState(false); const [_400error, set400Error] = useState(''); const [_404error, set404Error] = useState(''); const [_success, setSuccess] = useState(''); const isMountedRef = useRef(true); useEffect(() => { isMountedRef.current = false; setLoaded(false); let child_id = document.getElementById('child_id').value; axios.get(`/api/children/meetings/detail/${props.match.params?.meeting_id}`, {params:{child_id: child_id}}) .then(response => { setLoaded(true); setNotice(response.data.notice); if(response.data.status_code == 200) { var meeting = response.data.params; setMeeting(meeting); if(meeting.meeting_image.length > 0) setThumbnail(meeting.meeting_image[0].image); if(meeting.approval.approval_at != null){ setApprovalRegister(true); } } else { set400Error("失敗しました。"); } }) .catch(err=>{ setLoaded(true); setNotice(err.response.data.notice); if(err.response.status==404){ set404Error(err.response.data.message); } }) },[]); const handleApprovalRegister = () => { setSubmit(true); const formdata = new FormData(); formdata.append('child_id', document.getElementById('child_id').value); formdata.append('meeting_id', props.match.params.meeting_id); axios.post('/api/children/meeting/approvals/registerApproval', formdata) .then(response => { setSubmit(false); setShowConfirmMoal(false); setNotice(response.data.notice); switch(response.data.status_code){ case 200: { setSuccess(response.data.success_messages); setApprovalRegister(true); break; } case 400: set400Error(response.data.error_messages); break; } }) } const handlePDFOpen = (pdf) => { var pieces = pdf.split('/'); var file_name = pieces[pieces.length-1]; window.open(`/pdf/${file_name}`, '_blank'); } return (

ミーティング詳細

{ loaded && _approval_register == false && meeting &&
}
{ !loaded && } { loaded && meeting &&
setShowMemoModal(false)} /> setShowPDFModal(false)} />
} setShowConfirmMoal(false)} handleAccept={handleApprovalRegister} loading={submit}/> { _success && setSuccess('')}>{_success} } { _400error && set400Error('')}>{_400error} } { _404error && { set404Error(''); history.push({ pathname: "/c-account/meeting" }); }}> {_404error} }
) } export default MeetingDetail;