summaryrefslogtreecommitdiff
path: root/src/components/RsvpForm.tsx
blob: 9dbc54c0f74eefb2aa9f46413370e2f97a6aff23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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 (
    <Paper>
      <Grid container spacing={2}>
        <Grid item xs={12} md={4} lg={4}>
          <Typography>Date: April 14, 2025</Typography>
        </Grid>
        <Grid item xs={12} md={4} lg={4}>
          <Typography>Location: </Typography>
        </Grid>
        <Grid item xs={12} md={4} lg={4}>
          <Typography>RSVP Deadline: </Typography>
        </Grid>
        <Grid item xs={12} md={4} lg={4}>
          <TextField required label="Name" variant="outlined" />
        </Grid>
        <Grid item xs={12} md={4} lg={4}>
          <FormControl>
            <FormLabel>Will you attend our wedding?</FormLabel>
            <RadioGroup>
              <FormControlLabel value="Yes" control={<Radio />} label="Yes" />
              <FormControlLabel value="No" control={<Radio />} label="No" />
            </RadioGroup>
          </FormControl>
        </Grid>
        <Grid item xs={12} md={4} lg={4}>
          <TextField required label="Plus-One" variant="outlined" />
        </Grid>
        <Grid item xs={12} md={4} lg={4}>
          <FormControl>
            <FormLabel>Meal Preference</FormLabel>
              <FormControlLabel
                value="Beef"
                control={<Radio />}
                label="Beef"
              />
              <FormControlLabel
                value="Chicken"
                control={<Radio />}
                label="Chicken"
              />
              <FormControlLabel
                value="Fish"
                control={<Radio />}
                label="Fish"
              />
              <FormControlLabel
                value="Vegetarian"
                control={<Radio />}
                label="Vegetarian"
              />
          </FormControl>
        </Grid>
        <Grid item xs={12} md={4} lg={4}>
          <TextField
            label="Dietary Restrictions"
            variant="outlined"
          />
        </Grid>
        <Grid item xs={12} md={4} lg={4}>
          <TextField
            label="Advice"
            variant="outlined"
          />
        </Grid>
        <Grid item>
          <Button onClick={handleSubmit} variant="contained">Submit</Button>
        </Grid>
      </Grid>
    </Paper>
  )
}

export default RsvpForm;