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 ModalConfirm from '../../component/modal_confirm';
|
2021-11-16 02:31:44 +09:00
|
|
|
|
import { useHistory } from 'react-router-dom';
|
|
|
|
|
import Alert from '../../component/alert';
|
2021-10-05 00:35:47 +09:00
|
|
|
|
|
|
|
|
|
const ChildDetail = (props) => {
|
2021-11-16 02:31:44 +09:00
|
|
|
|
const [_success, setSuccess] = useState('');
|
2021-10-05 00:35:47 +09:00
|
|
|
|
const [child, setChild] = useState(null);
|
|
|
|
|
const [show, setShow] = useState(false);
|
|
|
|
|
const [showAlert, setShowAlert] = useState(false);
|
|
|
|
|
const [messageAlert, setMessageAlert] = useState(null);
|
2021-10-07 14:54:28 +09:00
|
|
|
|
const fatherId = document.getElementById('father_id').value;
|
2021-10-05 00:35:47 +09:00
|
|
|
|
const history = useHistory();
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2021-10-07 14:54:28 +09:00
|
|
|
|
axios.get(`/api/children/detail/${props.match.params?.id}`, {params: { father_id: fatherId }}).then((response) => {
|
2021-10-05 00:35:47 +09:00
|
|
|
|
if(response.data.status_code==200){
|
|
|
|
|
console.log(response.data.params[0]);
|
|
|
|
|
setChild(response.data.params[0]);
|
|
|
|
|
} else if(response.data.status_code==400){
|
|
|
|
|
//TODO
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
async function showModal() {
|
|
|
|
|
setShow(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
async function handleClose() {
|
|
|
|
|
setShow(false);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
async function handleAccept() {
|
|
|
|
|
try {
|
|
|
|
|
axios.delete(`/api/children/delete/${props.match.params?.id}`)
|
|
|
|
|
.then(response => {
|
|
|
|
|
if(response.data.status_code == 200){
|
2021-10-06 14:25:48 +09:00
|
|
|
|
// setMessageAlert("子の削除に成功しました!");
|
|
|
|
|
history.push({
|
|
|
|
|
pathname: "/p-account/child",
|
|
|
|
|
state: {message : "子の削除に成功しました!"}
|
|
|
|
|
});
|
2021-10-05 00:35:47 +09:00
|
|
|
|
} else {
|
|
|
|
|
setMessageAlert("子の削除に失敗しました。");
|
|
|
|
|
}
|
|
|
|
|
setShowAlert(true);
|
|
|
|
|
});
|
|
|
|
|
setShow(false);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log('error', error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
async function handleCloseAlert() {
|
|
|
|
|
setShowAlert(false);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!child) return null;
|
2021-10-01 17:45:39 +09:00
|
|
|
|
|
|
|
|
|
return (
|
2021-10-03 02:08:39 +09:00
|
|
|
|
<div className="l-content">
|
|
|
|
|
<div className="l-content-w560">
|
|
|
|
|
<div className="l-content__ttl">
|
|
|
|
|
<div className="l-content__ttl__left">
|
|
|
|
|
<h2>子詳細</h2>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="p-notification">
|
|
|
|
|
<div className="p-notification-icon">
|
|
|
|
|
<div className="p-notification-icon-wrap">
|
|
|
|
|
<div className="count">1</div>
|
|
|
|
|
<div className="p-notification-icon-bg"></div>
|
2021-10-05 00:35:47 +09:00
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22.742 19.855" className="icon svg-icon svg-fill svg-y50" >
|
|
|
|
|
<g fill="none" stroke="#080808" strokeLinecap="round" strokeLinejoin="round" data-name="Icon feather-alert-triangle" transform="translate(0.777 0.75)">
|
|
|
|
|
<path d="M11.188,5.322,2.6,19.659A2.028,2.028,0,0,0,4.334,22.7H21.51a2.028,2.028,0,0,0,1.734-3.042L14.656,5.322a2.028,2.028,0,0,0-3.468,0Z" data-name="パス 3" transform="translate(-2.328 -4.346)"/>
|
|
|
|
|
<path d="M18,13.5v6.91" data-name="パス 4" transform="translate(-7.406 -8.547)"/>
|
|
|
|
|
<path d="M18,25.5h0" data-name="パス 5" transform="translate(-7.406 -11.2)"/>
|
|
|
|
|
</g>
|
|
|
|
|
</svg>
|
2021-10-01 17:45:39 +09:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2021-10-03 02:08:39 +09:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="l-content-wrap">
|
|
|
|
|
<div className="profile-container">
|
|
|
|
|
<div className="profile-wrap">
|
|
|
|
|
<div className="profile-content">
|
|
|
|
|
<div className="profile-thumb">
|
|
|
|
|
{/* <label> */}
|
|
|
|
|
<input id="profile-file" type="file" className="profile-thumb-img" />
|
2021-10-05 00:35:47 +09:00
|
|
|
|
<img src={ child.image } id="profile-file-preview" className="profile-thumb__image" alt="" />
|
2021-10-03 02:08:39 +09:00
|
|
|
|
{/* </label> */}
|
|
|
|
|
</div>
|
2021-10-05 00:35:47 +09:00
|
|
|
|
<p className="profile-name">{ child.last_name } { child.first_name }</p>
|
2021-10-03 02:08:39 +09:00
|
|
|
|
<div className="profile-info">
|
|
|
|
|
<div className="profile-info__item">
|
|
|
|
|
<p className="profile-info__icon">
|
|
|
|
|
<img src="../../../assets/img/icon/mail.svg" alt="メール" />
|
|
|
|
|
</p>
|
2021-10-06 14:25:48 +09:00
|
|
|
|
<p className="txt"><a href={"mailto:" + child.email}>{ child.email }</a></p>
|
2021-10-01 17:45:39 +09:00
|
|
|
|
</div>
|
2021-10-03 02:08:39 +09:00
|
|
|
|
<div className="profile-info__item">
|
|
|
|
|
<p className="profile-info__icon">
|
|
|
|
|
<img src="../../../assets/img/icon/phone.svg" alt="電話" />
|
|
|
|
|
</p>
|
2021-10-06 14:25:48 +09:00
|
|
|
|
<p className="txt"><a href={"tel:" + child.tel}>{ child.tel }</a></p>
|
2021-10-01 17:45:39 +09:00
|
|
|
|
</div>
|
2021-10-03 02:08:39 +09:00
|
|
|
|
<div className="profile-info__item">
|
|
|
|
|
<p className="profile-info__icon">
|
|
|
|
|
<img src="../../../assets/img/icon/building.svg" alt="会社名" />
|
|
|
|
|
</p>
|
2021-10-05 00:35:47 +09:00
|
|
|
|
<p className="txt">{ child.company }</p>
|
2021-10-01 17:45:39 +09:00
|
|
|
|
</div>
|
2021-10-03 02:08:39 +09:00
|
|
|
|
<div className="profile-info__item">
|
|
|
|
|
<p className="profile-info__icon">
|
|
|
|
|
<img src="../../../assets/img/icon/calendar.svg" alt="日付" />
|
|
|
|
|
</p>
|
2021-10-05 00:35:47 +09:00
|
|
|
|
<p className="txt">{ moment(child.father_relation?.hire_at).format('YYYY/MM/DD HH:mm') || '' }</p>
|
2021-10-01 17:45:39 +09:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2021-10-03 02:08:39 +09:00
|
|
|
|
|
|
|
|
|
<div className="p-profile-btn">
|
2021-10-05 00:35:47 +09:00
|
|
|
|
<a
|
|
|
|
|
onClick={e => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
history.push({
|
|
|
|
|
pathname: `/p-account/child/edit/hire-date/${props.match.params?.id}`,
|
|
|
|
|
state: {}
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
data-v-ade1d018=""
|
|
|
|
|
className="btn-default btn-yellow btn-profile btn-r8 btn-h52">
|
|
|
|
|
<span>入社日を変更</span>
|
2021-10-03 02:08:39 +09:00
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="p-profile-txtLink">
|
2021-10-05 00:35:47 +09:00
|
|
|
|
<button type="button" onClick={showModal} className="a-icon txt-link">削除する</button>
|
2021-10-03 02:08:39 +09:00
|
|
|
|
</div>
|
2021-10-01 17:45:39 +09:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2021-10-05 00:35:47 +09:00
|
|
|
|
<ModalConfirm
|
|
|
|
|
show={show}
|
|
|
|
|
message={"全てのミーティングの情報から \n 消えますがよろしいでしょうか。"}
|
|
|
|
|
handleClose={handleClose}
|
|
|
|
|
handleAccept={handleAccept}
|
|
|
|
|
/>
|
2021-11-16 02:31:44 +09:00
|
|
|
|
{ _success && <Alert type="success">{_success}</Alert> }
|
2021-10-03 02:08:39 +09:00
|
|
|
|
</div>
|
2021-10-01 17:45:39 +09:00
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-03 02:08:39 +09:00
|
|
|
|
export default ChildDetail;
|