export default function PlayerList()

in databases/hello-app-cloud-spanner/client/src/components/PlayerList.js [25:57]


export default function PlayerList({setError, players, setPlayers}) {
    const handleSubmit = async (uuid) => {
        try {
            await deletePlayer(uuid);
            setPlayers(players.filter(player => player.PlayerUuid !== uuid));
        } catch (error) {
            setError(error.response.data.error);
        }
    };

    return <TableContainer component={Paper}>
        <Table aria-label="players table">
            <TableHead>
                <TableRow>
                    <TableCell>Uuid</TableCell>
                    <TableCell>First name</TableCell>
                    <TableCell>Last name</TableCell>
                    <TableCell>Birth date</TableCell>
                    <TableCell></TableCell>
                </TableRow>
            </TableHead>
            <TableBody>
                {players.map(player =>
                    <TableRow key={player.PlayerUuid}>
                        <TableCell>{player.PlayerUuid}</TableCell>
                        <TableCell>{player.FirstName}</TableCell>
                        <TableCell>{player.LastName}</TableCell>
                        <TableCell>{player.BirthDate}</TableCell>
                        <TableCell>
                            <Button variant="contained" color="error" onClick={() => handleSubmit(player.PlayerUuid)}>Delete</Button>
                        </TableCell>
                    </TableRow>
                )}