Why cant I implement date and time pickers i from Material Uin my project?

Viewed 18

So basically I have a form which i have tried to style somewhat like material Ui.But I would Like to add some date and time pickers.But im getting this error

Module not found: Can't resolve '@mui/x-date-pickers/AdapterDayjs' in '/Users/arundhati/Development/code/Mod5/capstone/client/src/components'

Also there is like lot of weird stuff given in the MUI document .And im confused how i can implement date and time picker here is my code.Thanks :)

function EditReservationForm({ reservation, onUpdateReservation }) {
  const { name, date, time, num, contact, occasion } = reservation;
  const [updateName, setUpdatedName] = useState(name);
  const [updateDate, setUpdatedDate] = useState(date);
  const [updateTime, setUpdatedTime] = useState(time);
  const [updateNum, setUpdatedNum] = useState(num);
  const [updateContact, setUpdatedContact] = useState(contact);
  const [updateOccasion, setUpdatedOccasion] = useState(occasion);

  function handleEditClick(e) {
    e.preventDefault();

    fetch(`/reservations/${reservation.id}`, {
      method: "PATCH",
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        name: updateName,
        date: updateDate,
        time: updateTime,
        num: updateNum,
        contact: updateContact,
        occasion: updateOccasion,
      }),
    })
      .then((r) => r.json())
      .then((updatedReservation) => {
        onUpdateReservation(updatedReservation);
      });
  }
  return (
    <>
      <Box
        component="form"
        sx={{
          "& > :not(style)": { m: 1 },
        }}
        noValidate
        autoComplete="off"
        onSubmit={handleEditClick}
      >
        <h2>Modify Reservation</h2>
        {/* <form onSubmit={handleEditClick}  > */}

        <FormControl>
          <InputLabel htmlFor="component-outlined">Name</InputLabel>
          <OutlinedInput
            type="text"
            // id="email"
            id="email"
            value={updateName}
            onChange={(e) => setUpdatedName(e.target.value)}
            label="Name"
          />
        </FormControl>
        <br />

        <FormControl>
          <InputLabel htmlFor="component-outlined">Date</InputLabel>
          <OutlinedInput
            type="date"
            // id="email"
            id="date"
            value={updateDate}
            onChange={(e) => setUpdatedDate(e.target.value)}
            label="Date"
          />
        </FormControl>
        <br />
        <FormControl>
          <InputLabel htmlFor="component-outlined">Time</InputLabel>
          <OutlinedInput
            type="time"
            name="time"
            id="time"
            value={updateTime}
            onChange={(e) => setUpdatedTime(e.target.value)}
          />
        </FormControl>
        <br />
        <FormControl>
          <InputLabel htmlFor="component-outlined">No. of Guests</InputLabel>
          <OutlinedInput
            type="number"
            name="num"
            value={updateNum}
            onChange={(e) => setUpdatedNum(e.target.value)}
          />
        </FormControl>
        <br />
        <FormControl>
          <InputLabel htmlFor="component-outlined">Contact</InputLabel>
          <OutlinedInput
            type="tel"
            name="contact"
            value={updateContact}
            onChange={(e) => setUpdatedContact(e.target.value)}
            placeholder="contact"
          />
        </FormControl>
        <br />
        <FormControl>
          <InputLabel htmlFor="component-outlined">Occasion</InputLabel>
          <OutlinedInput
            type="text"
            name="occasion"
            value={updateOccasion}
            onChange={(e) => setUpdatedOccasion(e.target.value)}
          />
        </FormControl>

        <Stack paddingLeft={15} direction="row" id="loginbutton">
          <ColorButton variant="contained" type="submit">
            {" "}
            Update Reservation
          </ColorButton>
        </Stack>
        {/* </form> */}
      </Box>
    </>
  );
}
export default EditReservationForm;

0 Answers
Related