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 Parent = () => { const [keyword, setKeyword] = useState('') const [loaded, setLoaded] = useState(false); const [father_list, setFatherList ] = useState(null); const [_422errors, set422errors] = useState({keyword:''}); const [_400error, set400error] = useState(''); useEffect(() => { setLoaded(false); axios.get('/api/admin/fathers/list') .then((response) => { if(response.data.status_code==200){ console.log(response.data.params) setFatherList(response.data.params); } setLoaded(true); }); //////////////////////////////////// }, []); const handleSearch = (e) => { e.preventDefault(); initErrors(); if(keyword == '') { document.getElementById('keyword').focus(); return; } setLoaded(false); setFatherList(null); axios.get('/api/admin/fathers/search',{params: {keyword: keyword}}) .then((response) => { setLoaded(true); if(response.data.status_code==200){ setFatherList(response.data.params); } else if(response.data.status_code==400){ //TODO } }); } const initErrors = () => { set422errors({keyword:''}); } return (

親一覧

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

{ father.company }

{ father.email }

) :

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

) }
) } export default Parent;