From 589e53f152d7363074049dfd1bd5a34286ae74d6 Mon Sep 17 00:00:00 2001 From: Michael Hunteman Date: Wed, 21 Feb 2024 19:43:07 -0600 Subject: Update example guests.json with RTK query --- src/components/RsvpForm.tsx | 109 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 src/components/RsvpForm.tsx (limited to 'src/components/RsvpForm.tsx') diff --git a/src/components/RsvpForm.tsx b/src/components/RsvpForm.tsx new file mode 100644 index 0000000..9dbc54c --- /dev/null +++ b/src/components/RsvpForm.tsx @@ -0,0 +1,109 @@ +import { useState } from 'react'; +import Button from '@mui/material/Button'; +import Paper from '@mui/material/Paper'; +import Grid from '@mui/material/Grid'; +import TextField from '@mui/material/TextField'; +import Typography from '@mui/material/Typography'; +import Radio from '@mui/material/Radio'; +import RadioGroup from '@mui/material/RadioGroup'; +import FormControlLabel from '@mui/material/FormControlLabel'; +import FormControl from '@mui/material/FormControl'; +import FormLabel from '@mui/material/FormLabel'; + +import { useGetGuestsQuery, useUpdateGuestMutation } from '../apiSlice'; + +function RsvpForm() { + const { + data: guests, + isLoading, + isSuccess, + isError, + error + } = useGetGuestsQuery() + + const [updateGuest] = useUpdateGuestMutation() + + const handleSubmit = (e) => { + e.preventDefault() + console.log('handle') + let guest = guests[0] + if (guest.attendance === 'true') { + updateGuest({...guest, attendance: 'false'}) + } else { + updateGuest({...guest, attendance: 'true'}) + } + } + + return ( + + + + Date: April 14, 2025 + + + Location: + + + RSVP Deadline: + + + + + + + Will you attend our wedding? + + } label="Yes" /> + } label="No" /> + + + + + + + + + Meal Preference + } + label="Beef" + /> + } + label="Chicken" + /> + } + label="Fish" + /> + } + label="Vegetarian" + /> + + + + + + + + + + + + + + ) +} + +export default RsvpForm; -- cgit v1.2.3