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

218 行
13 KiB
React
Raw 通常表示 履歴

2021-10-22 09:35:32 +09:00
import React, { useEffect, useState } from 'react';
import axios from 'axios';
2021-10-23 03:34:35 +09:00
import { CircularProgress } from '@material-ui/core';
2021-10-23 11:53:54 +09:00
import { LoadingButton } from '@material-ui/lab';
2021-10-23 03:34:35 +09:00
2021-10-22 09:35:32 +09:00
const MeetingEdit = (props) => {
const [meeting, setMeeting] = useState(null);
2021-10-23 03:34:35 +09:00
const [title, setTitle] = useState('');
const [memo, setMemo] = useState('');
const [text, setText] = useState('');
2021-10-23 11:53:54 +09:00
const [pdf, setPdf] = useState('');
2021-10-23 03:34:35 +09:00
2021-10-23 11:53:54 +09:00
const [_422errors, set422Errors] = useState({title:'', text:'', memo:'', pdf:''})
2021-10-23 03:34:35 +09:00
2021-10-23 11:53:54 +09:00
const [loaded, setLoaded] = useState(false);
const [submit, setSubmit] = useState(false);
2021-10-23 03:34:35 +09:00
2021-10-22 09:35:32 +09:00
useEffect(() => {
2021-10-23 03:34:35 +09:00
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){
console.log(response.data.params[0]);
setMeeting(response.data.params[0]);
setTitle(response.data.params[0]?.title);
setMemo(response.data.params[0]?.memo);
setText(response.data.params[0]?.text);
} else if(response.data.status_code==400){
//TODO
}
2021-10-22 09:35:32 +09:00
});
}, []);
2021-10-23 11:53:54 +09:00
async function handleSubmit() {
set422Errors({
title:'',
memo:'',
text:'',
pdf:'',
images:''
});
2021-10-22 09:35:32 +09:00
try {
const formdata = new FormData();
formdata.append('father_id', fatherId);
formdata.append('title', title);
formdata.append('memo', memo);
formdata.append('text', text);
// formdata.append('pdf', pdf);
// formdata.append('images', images);
2021-10-23 11:53:54 +09:00
setSubmit(true);
2021-10-22 09:35:32 +09:00
// axios.post('/api/meetings/register', formdata)
// .then(response => {
// if(response.data.status_code==200){
// history.push({
// pathname: "/p-account/meetings/detail/1",
// state: {message : "ミーティングを作成しました!"}
// });
// } else {
// setMessageAlert('error');
// setShowAlert(true);
// }
// });
} catch (error) {
console.log('error', error);
}
}
2021-10-23 03:34:35 +09:00
2021-10-22 09:35:32 +09:00
return (
<div className="l-content">
2021-10-23 03:34:35 +09:00
<div className="l-content-w560">
<div className="l-content__ttl">
<div className="l-content__ttl__left">
<h2>ミーティング編集</h2>
2021-10-22 09:35:32 +09:00
</div>
</div>
2021-10-23 03:34:35 +09:00
<div className="l-content-wrap">
<div className="p-article">
<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 &&
<article className="p-article__body">
<div className="p-article__content">
<div className="p-article__context">
2021-10-23 11:53:54 +09:00
<form className="edit-form" onSubmit={handleSubmit}>
2021-10-23 03:34:35 +09:00
<div className="edit-set">
<label className="control-label" htmlFor="title">タイトル</label>
2021-10-23 11:53:54 +09:00
<input type="text" name="title" value={ title } onChange={e=>setTitle(e.target.value)} className={`input-default input-title input-h60 input-w480 ${ _422errors.title && 'is-invalid c-input__target'} `} id="title" />
{
_422errors.title &&
<span className="l-alert__text--error ft-16 ft-md-14">
{_422errors.title}
</span>
}
2021-10-23 03:34:35 +09:00
</div>
<div className="edit-set">
<label className="control-label" htmlFor="meeting_textarea">本文</label>
2021-10-23 11:53:54 +09:00
<textarea value={ text } onChange={e=>setText(e.target.value)} rows="8" className={`textarea-default ${ _422errors.text && 'is-invalid c-input__target'} `} id="meeting_textarea" />
{
_422errors.text &&
<span className="l-alert__text--error ft-16 ft-md-14">
{_422errors.text}
</span>
}
2021-10-23 03:34:35 +09:00
</div>
<div className="edit-set">
<label className="control-label" htmlFor="meeting_textarea">メモ</label>
2021-10-23 11:53:54 +09:00
<textarea value={ memo } onChange={e=>setMemo(e.target.value)} rows="8" className={`textarea-default ${ _422errors.memo && 'is-invalid c-input__target'} `} id="meeting_textarea" />
{
_422errors.memo &&
<span className="l-alert__text--error ft-16 ft-md-14">
{_422errors.memo}
</span>
}
2021-10-23 03:34:35 +09:00
</div>
<div className="edit-set edit-set-mt15">
<label className="edit-set-file-label" htmlFor="file_pdf">
PDFアップロード
<input type="file" name="file_pdf" accept=".pdf" id="file_pdf" />
</label>
2021-10-23 11:53:54 +09:00
{
_422errors.pdf &&
<span className="l-alert__text--error ft-16 ft-md-14">
{_422errors.pdf}
</span>
}
2021-10-23 03:34:35 +09:00
</div>
<div className="edit-set edit-set-mt15">
<label className="edit-set-file-label" htmlFor="file_image">
画像アップロード
<input type="file" name="file_image" accept=".png, .jpg, .jpeg" id="file_image" />
</label>
2021-10-23 11:53:54 +09:00
{
_422errors.pdf &&
<span className="l-alert__text--error ft-16 ft-md-14">
{_422errors.pdf}
</span>
}
2021-10-23 03:34:35 +09:00
</div>
<div className="p-file-image">
<figure className="image-upload"><img src="../../../assets/img/dummy/post-dummy01.jpg" alt="" /></figure>
<figure className="image-upload"><img src="../../../assets/img/dummy/post-dummy02.jpg" alt="" /></figure>
<figure className="image-upload"><img src="../../../assets/img/dummy/post-dummy03.jpg" alt="" /></figure>
<figure className="image-upload"><img src="../../../assets/img/dummy/post-dummy04.jpg" alt="" /></figure>
<figure className="image-upload"><img src="../../../assets/img/dummy/post-dummy05.jpg" alt="" /></figure>
<figure className="image-upload"><img src="../../../assets/img/dummy/post-dummy01.jpg" alt="" /></figure>
<figure className="image-upload"><img src="../../../assets/img/dummy/post-dummy02.jpg" alt="" /></figure>
<figure className="image-upload"><img src="../../../assets/img/dummy/post-dummy03.jpg" alt="" /></figure>
<figure className="image-upload"><img src="../../../assets/img/dummy/post-dummy04.jpg" alt="" /></figure>
<figure className="image-upload"><img src="../../../assets/img/dummy/post-dummy05.jpg" alt="" /></figure>
</div>
<div className="edit-set edit-set-send">
<label htmlFor="allmember_send">
<input className="boolean optional" type="checkbox" name="allmember_send" id="allmember_send" />全員に送信</label>
</div>
<div className="edit-set-mt5 edit-set-send">
<label htmlFor="pickup_send">
<input className="boolean optional" type="checkbox" name="pickup_send" id="pickup_send" />選んで送信</label>
</div>
<div className="checkbox-wrap edit-bg">
<div className="checkbox">
<label htmlFor="user_name01">
<input className="boolean optional" type="checkbox" name="chk[]" id="user_name01" />田中 達也</label>
</div>
<div className="checkbox">
<label htmlFor="user_name02">
<input className="boolean optional" type="checkbox" name="chk[]" id="user_name02" />田中 達也</label>
</div>
<div className="checkbox">
<label htmlFor="user_name03">
<input className="boolean optional" type="checkbox" name="chk[]" id="user_name03" />田中 達也</label>
</div>
<div className="checkbox">
<label htmlFor="user_name04">
<input className="boolean optional" type="checkbox" name="chk[]" id="user_name04" />田中 達也</label>
</div>
<div className="checkbox">
<label htmlFor="user_name05">
<input className="boolean optional" type="checkbox" name="chk[]" id="user_name05" />田中 達也</label>
</div>
</div>
2021-10-23 11:53:54 +09:00
<LoadingButton
type="submit"
loading={submit}
className="btn-edit btn-default btn-h70 btn-r14 btn-yellow rounded-20"
style={{fontSize:'18px',fontWeight:'bold', backgroundColor:'#ffed4a'}}>ミーティングを更新</LoadingButton>
2021-10-23 03:34:35 +09:00
</form>
</div>
2021-10-22 09:35:32 +09:00
</div>
2021-10-23 03:34:35 +09:00
</article>
}
</div>
2021-10-22 09:35:32 +09:00
</div>
</div>
</div>
</div>
)
}
export default MeetingEdit;