Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

99 wiersze
3.2 KiB

  1. "use client";
  2. import Stack from "@mui/material/Stack";
  3. import Box from "@mui/material/Box";
  4. import Card from "@mui/material/Card";
  5. import CardContent from "@mui/material/CardContent";
  6. import Grid from "@mui/material/Grid";
  7. import TextField from "@mui/material/TextField";
  8. import Typography from "@mui/material/Typography";
  9. import { useTranslation } from "react-i18next";
  10. import CardActions from "@mui/material/CardActions";
  11. import RestartAlt from "@mui/icons-material/RestartAlt";
  12. import Button from "@mui/material/Button";
  13. import { Controller, useFormContext } from "react-hook-form";
  14. import { FormControl, InputLabel, MenuItem, Select } from "@mui/material";
  15. import { useCallback } from "react";
  16. import { CreateSkillInputs } from "@/app/api/skill/actions";
  17. const SkillInfo: React.FC = () => {
  18. const { t } = useTranslation();
  19. const {
  20. register,
  21. formState: { errors, defaultValues },
  22. control,
  23. reset,
  24. resetField,
  25. setValue,
  26. } = useFormContext<CreateSkillInputs>();
  27. return (
  28. <>
  29. <Card sx={{ display: "block" }}>
  30. <CardContent component={Stack} spacing={4}>
  31. <Box>
  32. <Typography variant="overline" display="block" marginBlockEnd={1}>
  33. {t("Skill Info")}
  34. </Typography>
  35. <Grid container spacing={2} columns={{ xs: 6, sm: 12 }}>
  36. <Grid item xs={6}>
  37. <TextField
  38. label={t("Skill Name")}
  39. fullWidth
  40. rows={4}
  41. {...register("name", {
  42. required: true,
  43. })}
  44. error={Boolean(errors.name)}
  45. helperText={
  46. Boolean(errors.name) &&
  47. (errors.name?.message
  48. ? t(errors.name.message)
  49. : `${t("Please input correct ")}${t("name")}`
  50. )}
  51. />
  52. </Grid>
  53. <Grid item xs={6}>
  54. <TextField
  55. label={t("Code")}
  56. fullWidth
  57. rows={4}
  58. {...register("code", {
  59. required: true,
  60. })}
  61. error={Boolean(errors.code)}
  62. helperText={
  63. Boolean(errors.code) &&
  64. (errors.code?.message
  65. ? t(errors.code.message)
  66. : `${t("Please input correct ")}${t("code")}`
  67. )}
  68. />
  69. </Grid>
  70. <Grid item xs={12}>
  71. <TextField
  72. label={t("Description")}
  73. fullWidth
  74. multiline
  75. rows={4}
  76. {...register("description", {
  77. required: true,
  78. })}
  79. error={Boolean(errors.description)}
  80. helperText={
  81. Boolean(errors.description) &&
  82. (errors.description?.message
  83. ? t(errors.description.message)
  84. : `${t("Please input correct ")}${t("description")}`
  85. )}
  86. />
  87. </Grid>
  88. </Grid>
  89. </Box>
  90. </CardContent>
  91. </Card>
  92. </>
  93. );
  94. };
  95. export default SkillInfo;