このリポジトリは2023-09-09にアーカイブされています。 ファイルの閲覧とクローンは可能ですが、プッシュ、イシューの作成、プルリクエストはできません。
kikikan/backend/resources/js/admin/meeting/detail.jsx

252 行
10 KiB
React
Raw 通常表示 履歴

2021-10-10 06:26:44 +09:00
import React, { useEffect, useState } from 'react';
2021-10-10 18:24:19 +09:00
import { useHistory } from 'react-router-dom'
2021-10-10 06:26:44 +09:00
import moment from 'moment';
import axios from 'axios';
2021-10-10 18:24:19 +09:00
2021-10-10 06:26:44 +09:00
import ModalConfirm from '../../component/modal_confirm';
import ModalAlert from '../../component/modal_alert';
2021-10-22 22:03:05 +09:00
import { LoadingButton } from '@material-ui/lab';
import { CircularProgress } from '@material-ui/core';
import Alert from '../../component/alert';
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';
const Transition = React.forwardRef(function Transition(props, ref) {
return <Slide direction="up" ref={ref} {...props} />;
});
2021-10-10 06:26:44 +09:00
const MeetingDetail = (props) => {
2021-10-22 22:03:05 +09:00
2021-10-10 06:26:44 +09:00
const history = useHistory();
2021-10-22 22:03:05 +09:00
const [open, setOpen] = useState(false);
const [loaded, setLoaded] = useState(false);
const [submit, setSubmit] = useState(false);
2021-10-10 06:26:44 +09:00
const [meeting, setMeeting] = useState(null);
2021-10-22 22:03:05 +09:00
const [_400error, set400error] = useState('');
const [_success, setSuccess] = useState('');
2021-10-10 06:26:44 +09:00
useEffect(() => {
2021-10-10 18:24:19 +09:00
2021-10-22 22:03:05 +09:00
setLoaded(false);
axios.get(`/api/admin/meetings/detail/${props.match.params?.meeting_id}`, {params: { father_id: 1 }})
.then((response) => {
setLoaded(true);
2021-10-10 06:26:44 +09:00
if(response.data.status_code==200){
2021-10-22 22:03:05 +09:00
console.log(response.data.params);
2021-10-10 06:26:44 +09:00
setMeeting(response.data.params[0]);
} else if(response.data.status_code==400){
//TODO
}
});
}, []);
2021-10-22 22:03:05 +09:00
async function openModal() {
setOpen(true);
2021-10-10 06:26:44 +09:00
};
2021-10-22 22:03:05 +09:00
async function closeModal() {
setOpen(false);
2021-10-10 06:26:44 +09:00
};
async function handleAccept() {
try {
2021-10-22 22:03:05 +09:00
setSubmit(true);
axios.delete(`/api/admin/meetings/delete/${props.match.params?.meeting_id}`)
2021-10-10 06:26:44 +09:00
.then(response => {
2021-10-22 22:03:05 +09:00
closeModal();
setSubmit(false);
2021-10-10 06:26:44 +09:00
if(response.data.status_code == 200){
2021-10-22 22:03:05 +09:00
setSuccess('ミーティングの削除に成功しました!');
2021-10-10 06:26:44 +09:00
} else {
2021-10-22 22:03:05 +09:00
set400error("ミーティングの削除に失敗しました。");
2021-10-10 06:26:44 +09:00
}
});
} catch (error) {
console.log('error', error);
}
};
return (
<div className="l-content">
<div className="l-content-w560">
<div className="l-content__ttl">
<div className="l-content__ttl__left">
<h2>ミーティング詳細</h2>
</div>
</div>
<div className="l-content-wrap">
<div className="p-article">
2021-10-22 22:03:05 +09:00
<div className="p-article-wrap position-relative" style={{ minHeight:'500px'}}>
{
!loaded &&
<CircularProgress color="secondary" style={{top:'150px', left:'calc(50% - 22px)', color:'green', position:'absolute'}}/>
}
{
loaded &&
(
meeting ?
2021-10-10 06:26:44 +09:00
<article className="p-article__body">
<div className="p-article__content">
<div className="meeting-member">
<div className="meeting-member-wrap">
<div data-url="login.html" className="meeting-member-link">
<ul className="meeting-member-count">
<li className="numerator">3</li>
<li className="denominator">4</li>
</ul>
<ul className="meeting-member-list" role="list">
<li className="meeting-member__item" role="listitem">
<div className="avatar">
2021-10-22 09:35:32 +09:00
<img alt="name" className="avatar-img" src="/assets/img/avatar/avatar-sample01@2x.png" />
2021-10-10 06:26:44 +09:00
</div>
</li>
<li className="meeting-member__item" role="listitem">
<div className="avatar">
2021-10-22 09:35:32 +09:00
<img alt="name" className="avatar-img" src="/assets/img/avatar/avatar-sample02@2x.png" />
2021-10-10 06:26:44 +09:00
</div>
</li>
<li className="meeting-member__item" role="listitem">
<div className="avatar">
2021-10-22 09:35:32 +09:00
<img alt="name" className="avatar-img" src="/assets/img/avatar/avatar-sample03@2x.png" />
2021-10-10 06:26:44 +09:00
</div>
</li>
</ul>
<div className="meeting-member__read">
<p>3人既読</p>
</div>
</div>
</div>
</div>
<h3 className="meeting-ttl">{ meeting.title }</h3>
<time dateTime="2021-07-30" className="meeting-time">
2021-10-10 18:24:19 +09:00
<span className="meeting-date">{ moment(meeting.updated_at).format('YYYY/MM/DD') || '' }</span>
2021-10-10 06:26:44 +09:00
</time>
<ul className="p-article-btn-list">
2021-10-10 18:24:19 +09:00
<li className="p-article__pdf__btn">
2021-10-10 06:26:44 +09:00
<a
onClick={e => {
e.preventDefault();
history.push({
2021-10-10 18:24:19 +09:00
pathname: `/admin/meeting/edit/${props.match.params?.meeting_id}`,
2021-10-10 06:26:44 +09:00
state: {}
});
}}
className="btn-default btn-yellow btn-pdf btn-r8 btn-h48">
編集
</a>
</li>
2021-10-10 18:24:19 +09:00
<li className="p-article__pdf__btn mr-0">
2021-10-22 22:03:05 +09:00
<a onClick={openModal} className="btn-default btn-yellow btn-pdf btn-r8 btn-h48">削除</a>
2021-10-10 06:26:44 +09:00
</li>
</ul>
<div className="p-article__context">
<div className="p-file-list">
<div className="p-file-for">
<figure><img src="../../../assets/img/dummy/post-dummy01.jpg" alt="" /></figure>
</div>
<div className="p-file-nav">
<figure><img src="../../../assets/img/dummy/post-dummy01.jpg" alt="" /></figure>
<figure><img src="../../../assets/img/dummy/post-dummy02.jpg" alt="" /></figure>
<figure><img src="../../../assets/img/dummy/post-dummy03.jpg" alt="" /></figure>
<figure><img src="../../../assets/img/dummy/post-dummy04.jpg" alt="" /></figure>
<figure><img src="../../../assets/img/dummy/post-dummy05.jpg" alt="" /></figure>
<figure><img src="../../../assets/img/dummy/post-dummy01.jpg" alt="" /></figure>
<figure><img src="../../../assets/img/dummy/post-dummy02.jpg" alt="" /></figure>
<figure><img src="../../../assets/img/dummy/post-dummy03.jpg" alt="" /></figure>
<figure><img src="../../../assets/img/dummy/post-dummy04.jpg" alt="" /></figure>
<figure><img src="../../../assets/img/dummy/post-dummy05.jpg" alt="" /></figure>
<figure><img src="../../../assets/img/dummy/post-dummy03.jpg" alt="" /></figure>
<figure><img src="../../../assets/img/dummy/post-dummy04.jpg" alt="" /></figure>
<figure><img src="../../../assets/img/dummy/post-dummy05.jpg" alt="" /></figure>
</div>
</div>
<div className="p-article__pdf">
<div className="p-article__pdf__btn">
<a data-v-ade1d018="" className="btn-default btn-yellow btn-pdf btn-r8 btn-h52">
<span>PDFを確認する</span>
</a>
</div>
2021-10-22 16:41:39 +09:00
<button type="button" aria-label="お気に入り" data-tooltip="お気に入り" aria-pressed="false" className="icon a-icon text-icon icon-text icon-star-wrap a-icon-size_medium" style={{border:'1px solid #f0de00'}}>
</button>
2021-10-10 06:26:44 +09:00
</div>
<p className="p-article__txt">{ meeting.text }</p>
</div>
</div>
</article>
2021-10-22 22:03:05 +09:00
: <p className="text-center pt-5">データが存在していません</p>
)
}
2021-10-10 06:26:44 +09:00
</div>
</div>
</div>
</div>
2021-10-22 22:03:05 +09:00
{/* <ModalConfirm
2021-10-10 06:26:44 +09:00
show={show}
message={"本当に削除しても\nよろしいでしょうか?"}
handleClose={handleClose}
handleAccept={handleAccept}
2021-10-22 22:03:05 +09:00
/> */}
<Dialog
open={open}
TransitionComponent={Transition}
keepMounted
aria-describedby="alert-dialog-slide-description"
>
<DialogContent style={{width:'290px', padding:'25px 10px 10px 10px'}}>
<DialogContentText id="alert-dialog-slide-description" style={{fontSize:'16px', textAlign:'center'}}>
本当に削除しても<br/>よろしいでしょうか
</DialogContentText>
</DialogContent>
<DialogActions style={{justifyContent:'space-evenly', padding:'0 20px 20px 20px'}}>
<Button
onClick={closeModal}
size="large"
style={{fontSize:'16px'}}>いいえ</Button>
<LoadingButton
variant="text"
onClick={handleAccept}
loading={submit}
size="large"
style={{fontSize:'16px'}}>はい</LoadingButton>
</DialogActions>
</Dialog>
{
_400error && <Alert type="fail" hide={()=>set400error('')}>{_400error}</Alert>
}
{
_success &&
<Alert type="success"
hide={()=>
history.push({
pathname: "/admin/meeting",
state: {}
})}>{_success}</Alert>
}
</div>
2021-10-10 06:26:44 +09:00
)
}
export default MeetingDetail;