import React, { useEffect, useState } from 'react'; import moment from 'moment'; import axios from 'axios'; import ModalConfirm from '../../component/modal_confirm'; import ModalAlert from '../../component/modal_alert'; import { useHistory } from 'react-router-dom' const ChildDetail = (props) => { const [child, setChild] = useState(null); const [show, setShow] = useState(false); const [showAlert, setShowAlert] = useState(false); const [messageAlert, setMessageAlert] = useState(null); const [typeAlert, setTypeAlert] = useState(null); const history = useHistory(); useEffect(() => { axios.get(`/api/children/detail/${props.match.params?.id}`, {params: { father_id: 1 }}).then((response) => { 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){ setMessageAlert("子の削除に成功しました!"); setTypeAlert("success"); } else { setMessageAlert("子の削除に失敗しました。"); setTypeAlert("danger"); } setShowAlert(true); }); setShow(false); } catch (error) { console.log('error', error); } }; async function handleCloseAlert() { setShowAlert(false); }; if (!child) return null; return (

子詳細

1
{/* */}

{ child.last_name } { child.first_name }

メール

{ child.email }

電話

{ child.tel }

会社名

{ child.company }

日付

{ moment(child.father_relation?.hire_at).format('YYYY/MM/DD HH:mm') || '' }

) } export default ChildDetail;