import React, { useEffect, useState } from 'react';
import { useHistory } from 'react-router-dom'
import moment from 'moment';
import axios from 'axios';
import { LoadingButton } from '@material-ui/lab';
import { CircularProgress } from '@material-ui/core';
import Button from '@mui/material/Button';
import Dialog from '@mui/material/Dialog';
import DialogActions from '@mui/material/DialogActions';
import DialogContent from '@mui/material/DialogContent';
import DialogContentText from '@mui/material/DialogContentText';
import DialogTitle from '@mui/material/DialogTitle';
import Slide from '@mui/material/Slide';
import Alert from '../../component/alert';
import ModalPdf from '../../component/admin/pdf_modal_admin';
import ModalMemo from '../../component/admin/modal_memo';
const Transition = React.forwardRef(function Transition(props, ref) {
return ;
});
const MeetingDetail = (props) => {
const history = useHistory();
const [open, setOpen] = useState(false);
const [loaded, setLoaded] = useState(false);
const [submit, setSubmit] = useState(false);
const [meeting, setMeeting] = useState(null);
const [_400error, set400Error] = useState('');
const [_success, setSuccess] = useState('');
const [showPdf, setShowPdf] = useState(false);
const [showMemo, setShowMemo] = useState(false);
useEffect(() => {
setLoaded(false);
axios.get(`/api/admin/meetings/detail/${props.match.params?.meeting_id}`, {params: { father_id: 1 }})
.then((response) => {
setLoaded(true);
if(response.data.status_code==200){
var list = response.data.params[0];
var total=0, num=0;
if(list.approval){
for(var i in list.approval)
{
if(list.approval[i].approval_at) num ++;
total ++;
}
}
setMeeting({...list, denominator:total, numerator:num});
} else if(response.data.status_code==400){
//TODO
}
});
}, []);
async function openModal() {
setOpen(true);
};
async function closeModal() {
setOpen(false);
};
async function handleAccept() {
try {
setSubmit(true);
axios.delete(`/api/admin/meetings/delete/${props.match.params?.meeting_id}`)
.then(response => {
closeModal();
setSubmit(false);
if(response.data.status_code == 200){
setSuccess('削除に成功しました!');
} else {
set400Error("削除に失敗しました。");
}
});
} catch (error) {
console.log('error', error);
}
};
return (
{
!loaded &&
}
{
loaded &&
(
meeting ?
- {meeting.numerator}
- {meeting.denominator}
{
meeting.approval?.map((x, k)=>
-
)
}
{ meeting.title }
{
meeting.meeting_image[0] &&
}
{
meeting.meeting_image?.map((x, k)=>
)
}
{ meeting.text }
setShowMemo(false)}
/>
setShowPdf(false)}
/>
:
データが存在していません。
)
}
{
_400error &&
set400Error('')}>{_400error}
}
{
_success &&
history.push({
pathname: "/admin/meeting",
state: {}
})}>{_success}
}
)
}
export default MeetingDetail;