2021-12-18 16:05:52 +09:00
|
|
|
|
import React, { useRef, useEffect, useState } from 'react';
|
2021-12-30 13:57:05 +09:00
|
|
|
|
import { Link } from 'react-router-dom';
|
2021-11-09 16:53:39 +09:00
|
|
|
|
import moment from 'moment';
|
|
|
|
|
|
2021-12-31 12:33:35 +09:00
|
|
|
|
import Notification from '../../component/notification';
|
2021-11-09 16:53:39 +09:00
|
|
|
|
import Alert from '../../component/alert';
|
2021-12-22 05:32:06 +09:00
|
|
|
|
import PageLoader from '../../component/page_loader';
|
2021-11-09 16:53:39 +09:00
|
|
|
|
import InfiniteScroll from "react-infinite-scroll-component";
|
|
|
|
|
|
2021-11-18 16:46:31 +09:00
|
|
|
|
const INFINITE = 10;
|
2021-11-09 16:53:39 +09:00
|
|
|
|
const SCROLL_DELAY_TIME = 1500;
|
|
|
|
|
|
2021-10-31 12:26:19 +09:00
|
|
|
|
const ChildMeetings = () => {
|
2021-11-09 16:53:39 +09:00
|
|
|
|
|
2021-12-31 12:48:04 +09:00
|
|
|
|
const child_id = localStorage.getItem('kiki_acc_id');
|
2022-01-28 20:41:31 +09:00
|
|
|
|
const [notice, setNotice] = useState(-1);
|
2021-11-09 16:53:39 +09:00
|
|
|
|
const [tab_status, setTabStatus] = useState(false);
|
|
|
|
|
const [loaded, setLoaded] = useState(false);
|
|
|
|
|
const [loaded1, setLoaded1] = useState(false);
|
|
|
|
|
const [loaded2, setLoaded2] = useState(false);
|
|
|
|
|
const [meeting_list_non_approval, setMettingListNonApproval] = useState([]);
|
|
|
|
|
const [meeting_list_approval, setMettingListApproval] = useState([]);
|
|
|
|
|
const [fetch_meeting_list_non_approval, setFetchMettingListNonApproval] = useState([]);
|
|
|
|
|
const [fetch_meeting_list_approval, setFetchMettingListApproval] = useState([]);
|
|
|
|
|
const [_success, setSuccess] = useState('');
|
2021-11-18 12:14:22 +09:00
|
|
|
|
const [_400error, set400Error] = useState('');
|
2021-11-09 16:53:39 +09:00
|
|
|
|
|
2021-12-18 16:05:52 +09:00
|
|
|
|
const isMountedRef = useRef(true);
|
|
|
|
|
|
|
|
|
|
|
2021-11-09 16:53:39 +09:00
|
|
|
|
useEffect(()=>{
|
|
|
|
|
setLoaded(loaded1 && loaded2);
|
|
|
|
|
},[loaded1, loaded2])
|
2021-12-18 16:05:52 +09:00
|
|
|
|
|
|
|
|
|
|
2022-01-14 16:33:26 +09:00
|
|
|
|
useEffect(() => {
|
2021-12-18 16:05:52 +09:00
|
|
|
|
isMountedRef.current = false;
|
|
|
|
|
setLoaded(false);
|
2021-11-09 16:53:39 +09:00
|
|
|
|
|
2022-01-14 16:33:26 +09:00
|
|
|
|
axios.get('/api/children/meetings/listOfNonApprovalOfChild', {params:{child_id: child_id}})
|
|
|
|
|
.then(response => {
|
|
|
|
|
if(isMountedRef.current) return;
|
|
|
|
|
|
|
|
|
|
setLoaded1(true);
|
|
|
|
|
setNotice(response.data.notice);
|
|
|
|
|
if(response.data.status_code==200){
|
|
|
|
|
setMettingListNonApproval(response.data.params);
|
|
|
|
|
var len = response.data.params.length;
|
|
|
|
|
if(len > INFINITE)
|
|
|
|
|
setFetchMettingListNonApproval(response.data.params.slice(0, INFINITE));
|
|
|
|
|
else setFetchMettingListNonApproval(response.data.params.slice(0, len));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
set400Error("失敗しました。");
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
axios.get('/api/children/meetings/listOfApprovalOfChild', {params:{child_id: child_id}})
|
|
|
|
|
.then(response => {
|
|
|
|
|
if(isMountedRef.current) return;
|
2021-11-09 16:53:39 +09:00
|
|
|
|
|
2022-01-14 16:33:26 +09:00
|
|
|
|
setLoaded2(true);
|
|
|
|
|
setNotice(response.data.notice);
|
|
|
|
|
if(response.data.status_code==200){
|
|
|
|
|
setMettingListApproval(response.data.params);
|
|
|
|
|
var len = response.data.params.length;
|
|
|
|
|
if(len > INFINITE)
|
|
|
|
|
setFetchMettingListApproval(response.data.params.slice(0, INFINITE));
|
|
|
|
|
else setFetchMettingListApproval(response.data.params.slice(0, len));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
set400Error("失敗しました。");
|
|
|
|
|
}
|
|
|
|
|
})
|
2022-01-08 17:09:58 +09:00
|
|
|
|
|
2022-01-28 20:41:31 +09:00
|
|
|
|
return () => {
|
|
|
|
|
isMountedRef.current = true
|
2022-01-08 17:09:58 +09:00
|
|
|
|
}
|
2021-12-18 16:05:52 +09:00
|
|
|
|
},[]);
|
2021-11-09 16:53:39 +09:00
|
|
|
|
|
|
|
|
|
const fetchMoreListNonApproval = () => {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
var x = fetch_meeting_list_non_approval.length;
|
|
|
|
|
var y = meeting_list_non_approval.length;
|
|
|
|
|
var c = 0;
|
|
|
|
|
if(x+INFINITE < y) c = INFINITE;
|
|
|
|
|
else c = y - x;
|
|
|
|
|
setFetchMettingListNonApproval(meeting_list_non_approval.slice(0, x+c));
|
|
|
|
|
}, SCROLL_DELAY_TIME);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const fetchMoreListApproval = () => {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
var x = fetch_meeting_list_approval.length;
|
|
|
|
|
var y = meeting_list_approval.length;
|
|
|
|
|
var c = 0;
|
|
|
|
|
if(x+INFINITE < y) c = INFINITE;
|
|
|
|
|
else c = y - x;
|
|
|
|
|
setFetchMettingListApproval(meeting_list_approval.slice(0, x+c));
|
|
|
|
|
}, SCROLL_DELAY_TIME);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="l-content">
|
|
|
|
|
<div className="l-content__ttl">
|
|
|
|
|
<div className="l-content__ttl__left">
|
|
|
|
|
<h2>ミーティング一覧</h2>
|
|
|
|
|
</div>
|
2021-11-11 14:33:17 +09:00
|
|
|
|
<Notification notice={notice}/>
|
2021-11-09 16:53:39 +09:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="l-content-wrap">
|
|
|
|
|
<section className="meeting-tab-container">
|
|
|
|
|
<div className="meeting-tab-wrap">
|
|
|
|
|
<div className="meeting-head">
|
|
|
|
|
<input className="tab-switch" id="tab-01" type="radio" name="tab_btn"/>
|
|
|
|
|
<input className="tab-switch" id="tab-02" type="radio" name="tab_btn"/>
|
|
|
|
|
|
|
|
|
|
<div className="meeting-tab">
|
|
|
|
|
<label className={`tab-label ${!tab_status && 'is-active'} `} htmlFor="tab-01" onClick={()=>setTabStatus(false)}><span>未承知</span></label>
|
|
|
|
|
<label className={`tab-label ${ tab_status && 'is-active'} `} htmlFor="tab-02" onClick={()=>setTabStatus(true)}><span>承知済み</span></label>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{
|
2021-12-22 05:32:06 +09:00
|
|
|
|
!loaded && <PageLoader />
|
2021-11-09 16:53:39 +09:00
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
loaded &&
|
|
|
|
|
<div className="meeting-content">
|
|
|
|
|
{
|
|
|
|
|
!tab_status &&
|
|
|
|
|
<div className="meeting-content-wrap is-active" id="item01">
|
|
|
|
|
<InfiniteScroll
|
|
|
|
|
dataLength={fetch_meeting_list_non_approval.length}
|
|
|
|
|
next={fetchMoreListNonApproval}
|
|
|
|
|
hasMore={fetch_meeting_list_non_approval.length != meeting_list_non_approval.length}
|
|
|
|
|
loader={
|
|
|
|
|
<div id="dots3">
|
|
|
|
|
<span></span>
|
|
|
|
|
<span></span>
|
|
|
|
|
<span></span>
|
|
|
|
|
<span></span>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
style={{overflow:'none', position:'relative'}}
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
fetch_meeting_list_non_approval.length > 0 ?
|
|
|
|
|
fetch_meeting_list_non_approval?.map((item, id) =>
|
|
|
|
|
<div className="meeting-item" key={id}>
|
|
|
|
|
<div className="user-wrap user-sm">
|
|
|
|
|
<Link to={{
|
|
|
|
|
pathname: `/c-account/parent/detail/${item.father_id}`,
|
|
|
|
|
state: { tab_status: true}
|
|
|
|
|
}}>
|
|
|
|
|
<div className="user-avatar">
|
|
|
|
|
<img alt="name" className="father-img" src={item.father.image}/>
|
|
|
|
|
</div>
|
|
|
|
|
<p className="user-name">{item.father.company}</p>
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
<Link to={`/c-account/meeting/detail/${item.id}`} className="meeting-link">
|
|
|
|
|
<h3 className="meeting-ttl">{item.title}</h3>
|
|
|
|
|
<p className="meeting-txt">{item.text}</p>
|
|
|
|
|
</Link>
|
|
|
|
|
<div className="user-date">
|
|
|
|
|
<time dateTime="2021-07-30" className="user-updated-time">
|
|
|
|
|
<span className="user-updated">最終更新日:<span className="date">{moment(item.updated_at).format('YYYY/MM/DD')}</span></span>
|
|
|
|
|
</time>
|
|
|
|
|
<time dateTime="2021-07-30" className="user-awareness-time">
|
|
|
|
|
<span className="user-awareness">承知日:<span className="date"></span></span>
|
|
|
|
|
</time>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
: <p className="text-center py-5 ft-xs-17">データはありません。</p>
|
|
|
|
|
}
|
|
|
|
|
</InfiniteScroll>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
tab_status &&
|
|
|
|
|
<div className="meeting-content-wrap is-active" id="item02">
|
|
|
|
|
<InfiniteScroll
|
|
|
|
|
dataLength={fetch_meeting_list_approval.length}
|
|
|
|
|
next={fetchMoreListApproval}
|
|
|
|
|
hasMore={fetch_meeting_list_approval.length != meeting_list_approval.length}
|
|
|
|
|
loader={
|
|
|
|
|
<div id="dots3">
|
|
|
|
|
<span></span>
|
|
|
|
|
<span></span>
|
|
|
|
|
<span></span>
|
|
|
|
|
<span></span>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
style={{overflow:'none', position:'relative'}}
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
fetch_meeting_list_approval.length > 0 ?
|
|
|
|
|
fetch_meeting_list_approval?.map((item, id) =>
|
|
|
|
|
<div className="meeting-item" key={id}>
|
|
|
|
|
<div className="user-wrap user-sm">
|
|
|
|
|
<Link to = {`/c-account/parent/detail/${item.father_id}`}>
|
|
|
|
|
<div className="user-avatar">
|
|
|
|
|
<img alt="name" className="father-img" src={item.father.image}/>
|
|
|
|
|
</div>
|
|
|
|
|
<p className="user-name">{item.father.company}</p>
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
<Link to={`/c-account/meeting/detail/${item.id}`} className="meeting-link">
|
|
|
|
|
<h3 className="meeting-ttl">{item.title}</h3>
|
|
|
|
|
<p className="meeting-txt">{item.text}</p>
|
|
|
|
|
</Link>
|
|
|
|
|
<div className="user-date">
|
|
|
|
|
<time dateTime="2021-07-30" className="user-updated-time">
|
|
|
|
|
<span className="user-updated">最終更新日:
|
|
|
|
|
<span className="date">
|
|
|
|
|
{moment(item.updated_at).format('YYYY/MM/DD')}
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
</time>
|
|
|
|
|
<time dateTime="2021-07-30" className="user-awareness-time">
|
|
|
|
|
<span className="user-awareness">承知日:
|
|
|
|
|
<span className="date">
|
|
|
|
|
{ moment(item.approval.approval_at).format('YYYY/MM/DD') }
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
</time>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
: <p className="text-center py-5 ft-xs-17">データはありません。</p>
|
|
|
|
|
}
|
|
|
|
|
</InfiniteScroll>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
</section>
|
|
|
|
|
</div>
|
2021-11-18 12:14:22 +09:00
|
|
|
|
{ _400error && <Alert type="fail" hide={()=>set400Error('')}>{_400error}</Alert> }
|
|
|
|
|
{ _success && <Alert type="success" hide={()=>setSuccess('')}>{_success}</Alert> }
|
2021-11-09 16:53:39 +09:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-10-31 12:26:19 +09:00
|
|
|
|
export default ChildMeetings;
|