import React, { useEffect, useState } from 'react'; import ModalAlert from '../../component/modal_alert'; const ChildAdd = () => { const [tel, setTel] = useState(''); const [textColor, setTextColor] = useState(null); const [showAlert, setShowAlert] = useState(false); const [messageAlert, setMessageAlert] = useState(null); const fatherId = document.getElementById('father_id').value; async function handleClick() { try { if(tel == '') { return; } const formdata = new FormData(); formdata.append('tel', tel); axios.post('/api/children/checkTel', formdata) .then(response => { if(response.data.status_code==201){ const formdata2 = new FormData(); formdata2.append('father_id ', fatherId); axios.post('/api/children/registerTemporary', formdata2) .then(response2 => { if(response2.data.status_code==200){ const formdata3 = new FormData(); formdata3.append('send_id ', 1); formdata3.append('receive_id', tel); formdata3.append('message', "危機管理アプリに招待URLが届きました。1時間以内に、URLから本登録を行ってください。https://○○○.com/register/c-account/{token}'"); axios.post('/api/smss/register', formdata3) .then(response3 => { if(response3.data.status_code==200){ setMessageAlert(response.data.success_messages); setTextColor("black"); } }); } }); } else if(response.data.status_code==200){ formdata.append('father_id', fatherId); axios.post('/api//father-relations/register', formdata) .then(response => { if(response.data.status_code==200){ setMessageAlert(response.data.success_messages); setTextColor("black"); } else { setMessageAlert(response.data.success_messages); } }); } }); } catch (error) { console.log('error', error); } } async function handleCloseAlert() { setShowAlert(false); }; return (

子追加

1
setTel(e.target.value)} value={tel} className="input-default input-tel input-h60 input-w480" id="tel" />
) } export default ChildAdd;