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

316 行
12 KiB
React
Raw 通常表示 履歴

2021-10-01 17:45:39 +09:00
import React, { useEffect, useState } from 'react';
2021-10-05 00:35:47 +09:00
import moment from 'moment';
import axios from 'axios';
import ModalSettingNotify from '../../component/modal_setting_notify';
import { ToastContainer, toast } from 'react-toastify';
import ModalMemo from '../../component/modal_memo';
2021-10-05 00:35:47 +09:00
import ModalConfirm from '../../component/modal_confirm';
import ModalAlert from '../../component/modal_alert';
2021-11-15 15:35:26 +09:00
import ModalPdf from '../../component/pdf/modal_pdf';
import Notification from '../../component/notification';
2021-11-15 15:35:26 +09:00
import { useHistory, Link } from 'react-router-dom';
2021-11-13 20:17:15 +09:00
import { CircularProgress } from '@material-ui/core';
2021-10-05 00:35:47 +09:00
const MeetingDetail = (props) => {
2021-11-13 20:17:15 +09:00
2021-10-05 00:35:47 +09:00
const history = useHistory();
2021-11-13 20:17:15 +09:00
const [loaded, setLoaded] = useState(false);
2021-11-15 16:56:22 +09:00
const [submit, setSubmit] = useState(false);
2021-11-14 21:22:30 +09:00
const [ notice, setNotice] = useState(localStorage.getItem('notice'));
2021-11-15 16:56:22 +09:00
const [showConfirm, setShowConfirm] = useState(false);
const [showArea, setShowArea] = useState(false);
const [showMemo, setShowMemo] = useState(false);
const [showNotify, setShowNotify] = useState(false);
2021-10-05 00:35:47 +09:00
const [showAlert, setShowAlert] = useState(false);
2021-10-12 01:09:16 +09:00
const [showPdf, setShowPdf] = useState(false);
2021-10-05 00:35:47 +09:00
const [messageAlert, setMessageAlert] = useState(null);
const [typeAlert, setTypeAlert] = useState(null);
const [meeting, setMeeting] = useState(null);
2021-11-13 20:17:15 +09:00
const [thumbnail, setThumbnail] = useState(null);
const state = history.location.state
2021-10-05 00:35:47 +09:00
useEffect(() => {
2021-11-13 20:17:15 +09:00
let father_id = document.getElementById('father_id').value;
setLoaded(false);
axios.get(`/api/fathers/meetings/detail/${props.match.params?.id}`, {params: { father_id: father_id}})
.then((response) => {
setLoaded(true);
2021-11-15 15:35:26 +09:00
setNotice(response.data.notice);
2021-10-05 00:35:47 +09:00
if(response.data.status_code==200){
2021-11-13 20:17:15 +09:00
console.log(response.data.params);
2021-11-15 15:35:26 +09:00
var list = response.data.params;
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});
2021-11-13 20:17:15 +09:00
setThumbnail(response.data.params.meeting_image[0]?.image);
2021-10-05 00:35:47 +09:00
} else if(response.data.status_code==400){
//TODO
2021-11-13 20:17:15 +09:00
}
2021-10-05 00:35:47 +09:00
});
}, []);
2021-11-15 16:56:22 +09:00
async function showModalConfirm() {
setShowConfirm(true);
2021-10-05 00:35:47 +09:00
};
2021-11-15 16:56:22 +09:00
async function handleCloseConfirm() {
setShowConfirm(false);
2021-10-05 00:35:47 +09:00
};
2021-11-15 16:56:22 +09:00
async function handleAcceptDelete() {
2021-10-05 00:35:47 +09:00
try {
axios.delete(`/api/meetings/delete/${props.match.params?.id}`)
.then(response => {
if(response.data.status_code == 200){
axios.delete(`/api/meeting-images/deleteRelationMeeting/${props.match.params?.id}`)
.then(response => {});
axios.delete(`/api/meeting-approvals/deleteRelationMeeting/${props.match.params?.id}`)
.then(response => {
setMessageAlert("ミーティングの削除に成功しました!");
setTypeAlert("success");
});
} else {
setMessageAlert("ミーティングの削除に失敗しました。");
setTypeAlert("danger");
}
setShowAlert(true);
});
setShow(false);
} catch (error) {
console.log('error', error);
}
};
async function showModalMemo() {
setShowMemo(true);
};
async function showModalArea() {
setShowArea(true);
};
async function showModalNotify() {
setShowNotify(true);
};
async function handleCloseNotify() {
setShowNotify(false);
};
2021-10-12 01:09:16 +09:00
async function handleClosePdf() {
setShowPdf(false);
};
async function handleCloseMemo() {
setShowMemo(false);
};
async function handleAcceptNotify() {
try {
2021-11-15 15:35:26 +09:00
axios.post(`/api/fathers/children/listOfMeetingNotifyUnapprovel/${props.match.params?.id}`)
.then(response => {
if(response.data.status_code == 200){
axios.delete(`/api/smss/register/${props.match.params?.id}`)
.then(response => {
});
}
});
setShowNotify(false);
} catch (error) {
console.log('error', error);
}
};
2021-10-05 00:35:47 +09:00
async function handleCloseAlert() {
setShowAlert(false);
};
async function handleFavorite(meetingId, currentFavorite) {
const formdata = new FormData();
formdata.append('meeting_id', meetingId);
formdata.append('is_favorite', currentFavorite == 1 ? 0 : 1);
axios.post('/api/meetings/registerFavorite', formdata).then((response) => {})
const updatedItem = {
...meeting,
is_favorite: currentFavorite == 1 ? 0 : 1,
};
setMeeting(updatedItem);
};
2021-10-05 00:35:47 +09:00
if (!meeting) return null;
2021-10-01 17:45:39 +09:00
return (
<div className="l-content">
<ToastContainer />
2021-10-01 17:45:39 +09:00
<div className="l-content-w560">
<div className="l-content__ttl">
<div className="l-content__ttl__left">
<h2>ミーティング詳細</h2>
</div>
2021-11-15 15:35:26 +09:00
<Notification notice={notice}/>
2021-10-01 17:45:39 +09:00
</div>
2021-11-13 20:17:15 +09:00
{
!loaded &&
<CircularProgress color="secondary" className="css-loader"/>
}
{
loaded &&
<div className="l-content-wrap">
<div className="p-article">
<div className="p-article-wrap">
<article className="p-article__body">
<div className="p-article__content">
<div className="meeting-member">
<div className="meeting-member-wrap">
<div onClick={showModalArea} data-url="login.html" className="meeting-member-link">
<ul className="meeting-member-count">
2021-11-15 15:35:26 +09:00
<li className="numerator">{meeting?.numerator}</li>
<li className="denominator">{meeting?.denominator}</li>
2021-11-13 20:17:15 +09:00
</ul>
<ul className="meeting-member-list" role="list">
2021-11-15 15:35:26 +09:00
{ meeting?.approval.map((v, inx) =>
<li className="meeting-member__item" role="listitem" key={inx}>
2021-11-13 20:17:15 +09:00
<div className="avatar">
<img alt="name" className="avatar-img" src={v?.child.image} />
</div>
2021-11-15 15:35:26 +09:00
</li>
)
}
2021-11-13 20:17:15 +09:00
</ul>
2021-10-01 17:45:39 +09:00
</div>
</div>
</div>
2021-11-13 20:17:15 +09:00
<h3 className="meeting-ttl">{ meeting.title }</h3>
<time dateTime="2021-07-30" className="meeting-time">
2021-11-15 15:35:26 +09:00
<span className="meeting-date">{ moment(meeting.updated_at).format('YYYY/MM/DD') }</span>
2021-11-13 20:17:15 +09:00
</time>
<ul className="p-article-btn-list">
<li className="p-article-btn__item">
2021-11-15 15:35:26 +09:00
<Link to={`/p-account/meeting/edit/${props.match.params?.id}`}
className="btn-default btn-yellow btn-pdf btn-r8 btn-h48">編集</Link>
2021-11-13 20:17:15 +09:00
</li>
<li className="p-article-btn__item">
2021-11-15 16:56:22 +09:00
<a onClick={showModalConfirm} className="btn-default btn-yellow btn-pdf btn-r8 btn-h48">削除</a>
2021-11-13 20:17:15 +09:00
</li>
<li className="p-article-btn__item">
2021-11-15 15:35:26 +09:00
<Link to='/p-account/meeting/new'
className="btn-default btn-yellow btn-pdf btn-r8 btn-h48">複製</Link>
2021-11-13 20:17:15 +09:00
</li>
<li className="p-article-btn__item">
<a onClick={showModalNotify} className="btn-default btn-yellow btn-pdf btn-r8 btn-h48">再通知</a>
</li>
</ul>
<div className="p-article__context">
<div className="p-file-list">
<div className="p-file-for">
2021-11-15 15:35:26 +09:00
<figure>
{
thumbnail &&
<img src={thumbnail} alt="thumbnail"/>
}
</figure>
2021-11-13 20:17:15 +09:00
</div>
<div className="p-file-nav">
2021-11-15 15:35:26 +09:00
{
meeting?.meeting_image.map((v, inx) =>
<figure onClick={() => setThumbnail(v.image)} key={inx}>
<img src={v.image} alt="" />
</figure>
)
}
{
[...Array(10-meeting.meeting_image.length)].map((x, k)=>
<figure key={k}></figure>
)
}
2021-11-13 20:17:15 +09:00
</div>
</div>
<div className="p-article__pdf">
<div className="p-article__pdf__btn">
<a
onClick={e => {
e.preventDefault();
setShowPdf(true);
}}
className="btn-default btn-yellow btn-pdf btn-r8 btn-h52">
<span>PDFを確認する</span>
</a>
</div>
2021-11-15 15:35:26 +09:00
<button type="button" onClick={showModalMemo}
aria-label="メモ"
data-tooltip="メモ"
aria-pressed="false"
style={{marginRight:10}}
className="icon a-icon text-icon icon-text icon-starFill-wrap a-icon-size_medium"></button>
2021-11-13 20:17:15 +09:00
<button type="button"
onClick={e => {
e.preventDefault();
handleFavorite(meeting.id, meeting.is_favorite);
}}
aria-label="お気に入り" data-tooltip="お気に入り" aria-pressed="false" className={`icon a-icon like-icon ${meeting.is_favorite == 1 ? "icon-starFill icon-starFill-wrap" : "icon-star icon-star-wrap"} a-icon-size_medium`}></button>
2021-10-01 17:45:39 +09:00
</div>
2021-11-13 20:17:15 +09:00
<p className="p-article__txt">{ meeting.text }</p>
2021-10-01 17:45:39 +09:00
</div>
</div>
2021-11-13 20:17:15 +09:00
</article>
</div>
2021-10-01 17:45:39 +09:00
</div>
</div>
2021-11-13 20:17:15 +09:00
}
2021-10-01 17:45:39 +09:00
</div>
<ModalSettingNotify
show={showArea}
meetingId={meeting.id}
// message={"本当に削除しても\nよろしいでしょうか?"}
// handleClose={handleClose}
// handleAccept={handleAccept}
/>
<ModalMemo
show={showMemo}
title={"メモ"}
content={meeting?.memo}
handleClose={handleCloseMemo}
/>
2021-10-05 00:35:47 +09:00
<ModalConfirm
2021-11-15 16:56:22 +09:00
show={showConfirm}
2021-10-05 00:35:47 +09:00
message={"本当に削除しても\nよろしいでしょうか?"}
2021-11-15 16:56:22 +09:00
handleClose={handleCloseConfirm}
handleAccept={handleAcceptDelete}
loading={submit}
2021-10-05 00:35:47 +09:00
/>
<ModalConfirm
show={showNotify}
message={"本当に再通知しても\nよろしいでしょうか?"}
handleClose={handleCloseNotify}
handleAccept={handleAcceptNotify}
/>
2021-10-05 00:35:47 +09:00
<ModalAlert
show={showAlert}
message={messageAlert}
type={typeAlert}
handleClose={handleCloseAlert}
/>
2021-10-12 01:09:16 +09:00
<ModalPdf
show={showPdf}
pdfPath={meeting.pdf ?? '/pdf/test.pdf'}
handleClose={handleClosePdf}
/>
2021-10-01 17:45:39 +09:00
</div>
)
}
export default MeetingDetail;