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 fatherId = document.getElementById('father_id').value; const history = useHistory(); useEffect(() => { axios.get(`/api/children/detail/${props.match.params?.id}`, {params: { father_id: fatherId }}).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("子の削除に成功しました!"); history.push({ pathname: "/p-account/child", state: {message : "子の削除に成功しました!"} }); } else { setMessageAlert("子の削除に失敗しました。"); } setShowAlert(true); }); setShow(false); } catch (error) { console.log('error', error); } }; async function handleCloseAlert() { setShowAlert(false); }; if (!child) return null; return (

子詳細

1
) } export default ChildDetail;