Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

65 lignes
1.4 KiB

  1. "use client";
  2. import { UserResult } from "@/app/api/user";
  3. import { UserInputs } from "@/app/api/user/actions";
  4. import {
  5. Card,
  6. CardContent,
  7. Grid,
  8. Stack,
  9. TextField,
  10. Typography,
  11. } from "@mui/material";
  12. import { useFormContext } from "react-hook-form";
  13. import { useTranslation } from "react-i18next";
  14. interface Props {
  15. data: UserResult
  16. }
  17. const UserDetail: React.FC<Props> = ({
  18. data
  19. }) => {
  20. const { t } = useTranslation();
  21. const {
  22. register,
  23. formState: { errors },
  24. control,
  25. } = useFormContext<UserInputs>();
  26. return (
  27. <Card>
  28. <CardContent component={Stack} spacing={4}>
  29. <Typography variant="overline" display="block" marginBlockEnd={1}>
  30. {t("User Detail")}
  31. </Typography>
  32. <Grid container spacing={2} columns={{ xs: 6, sm: 12 }}>
  33. <Grid item xs={6}>
  34. <TextField
  35. label={t("username")}
  36. fullWidth
  37. {...register("name", {
  38. required: "username required!",
  39. })}
  40. error={Boolean(errors.name)}
  41. />
  42. </Grid>
  43. <Grid item xs={6}>
  44. <TextField
  45. label={t("email")}
  46. fullWidth
  47. {...register("email", {
  48. required: "email required!",
  49. })}
  50. error={Boolean(errors.email)}
  51. />
  52. </Grid>
  53. </Grid>
  54. </CardContent>
  55. </Card>
  56. );
  57. };
  58. export default UserDetail;