import React, { useEffect, useState } from 'react'; import { CircularProgress } from '@material-ui/core'; import axios from 'axios'; import { useHistory, Link } from 'react-router-dom'; import IconButton from '@mui/material/IconButton'; import SearchIcon from '@mui/icons-material/Search'; const Child = () => { const [keyword, setKeyword] = useState('') const [loaded, setLoaded] = useState(false); const [children_list, setChildrenList ] = useState(null); const [_422errors, set422errors] = useState({keyword:''}); const [_400error, set400error] = useState(''); useEffect(() => { setLoaded(false); axios.get('/api/admin/children/list') .then((response) => { if(response.data.status_code==200){ setChildrenList(response.data.params); } else if(response.data.status_code==400){ //TODO } setLoaded(true); }); //////////////////////////////////// }, []); const handleSearch = (e) => { e.preventDefault(); initErrors(); if(keyword == '') { document.getElementById('keyword').focus(); return; } setLoaded(false); setChildrenList(null); axios.get('/api/admin/children/search', {params:{keyword: keyword}}) .then((response) => { setLoaded(true); if(response.data.status_code==200){ setChildrenList(response.data.params); } else if(response.data.status_code==400){ //TODO } }); } const initErrors = () => { set422errors({keyword:''}); } return (

子一覧

setKeyword(e.target.value)} />
{ !loaded && } { loaded && ( children_list && children_list.length>0 ? children_list.map((child, k) =>
name

{ child.last_name } { child.first_name }

{ child.tel }

) :

データが存在していません。

) }
) } export default Child;