diff options
author | Michael Hunteman <michael@huntm.net> | 2024-02-21 19:43:07 -0600 |
---|---|---|
committer | Michael Hunteman <michael@huntm.net> | 2024-02-21 19:43:07 -0600 |
commit | 589e53f152d7363074049dfd1bd5a34286ae74d6 (patch) | |
tree | 187b98b25f7f3420ad2642171fd7d91a68713211 /src/components/Admin.tsx | |
parent | 32e0cacde5a468d8982d5c0d1fd7a242820cb60f (diff) |
Update example guests.json with RTK query
Diffstat (limited to 'src/components/Admin.tsx')
-rw-r--r-- | src/components/Admin.tsx | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/components/Admin.tsx b/src/components/Admin.tsx new file mode 100644 index 0000000..8f6ce12 --- /dev/null +++ b/src/components/Admin.tsx @@ -0,0 +1,35 @@ +import Paper from '@mui/material/Paper'; +import Typography from '@mui/material/Typography'; + +import { useGetGuestsQuery } from '../apiSlice' + +function Admin() { + const { + data: guests, + isLoading, + isSuccess, + isError, + error + } = useGetGuestsQuery() + + let content + + if (isLoading) { + content = <Typography variant="h4">Loading...</Typography> + } else if (isSuccess) { + content = JSON.stringify(guests) + } else if (isError) { + content = <>{error.toString()}</> + } + + return ( + <Paper> + <Typography variant="h4" component="h4"> + Admin + </Typography> + {content} + </Paper> + ) +} + +export default Admin; |