FPSMS-frontend
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

8 месяцев назад
7 месяцев назад
8 месяцев назад
8 месяцев назад
1 месяц назад
8 месяцев назад
8 месяцев назад
8 месяцев назад
1 месяц назад
8 месяцев назад
1 месяц назад
1 месяц назад
8 месяцев назад
1 месяц назад
8 месяцев назад
1 месяц назад
1 месяц назад
1 месяц назад
1 месяц назад
1 месяц назад
8 месяцев назад
1 месяц назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. makeStyles,
  12. } from "@mui/material";
  13. import { useFormContext } from "react-hook-form";
  14. import { useTranslation } from "react-i18next";
  15. const UserDetail: React.FC = () => {
  16. const { t } = useTranslation("user");
  17. const {
  18. register,
  19. formState: { errors },
  20. control,
  21. watch,
  22. } = useFormContext<UserInputs>();
  23. const password = watch("password");
  24. const username = watch("username");
  25. const staffNo = watch("staffNo");
  26. const name = watch("name");
  27. return (
  28. <Card>
  29. <CardContent component={Stack} spacing={4}>
  30. <Typography variant="overline" display="block" marginBlockEnd={1}>
  31. {t("User Detail")}
  32. </Typography>
  33. <Grid container spacing={2} columns={{ xs: 6, sm: 12 }}>
  34. <Grid item xs={6}>
  35. <TextField
  36. label={t("username")}
  37. fullWidth
  38. variant="filled"
  39. InputLabelProps={{
  40. shrink: !!username,
  41. sx: { fontSize: "0.9375rem" },
  42. }}
  43. InputProps={{
  44. sx: { paddingTop: "8px" },
  45. }}
  46. {...register("username", {
  47. required: "username required!",
  48. })}
  49. error={Boolean(errors.username)}
  50. />
  51. </Grid>
  52. <Grid item xs={6}>
  53. <TextField
  54. label={t("staffNo")}
  55. fullWidth
  56. variant="filled"
  57. InputLabelProps={{
  58. shrink: !!staffNo,
  59. sx: { fontSize: "0.9375rem" },
  60. }}
  61. InputProps={{
  62. sx: { paddingTop: "8px" },
  63. }}
  64. {...register("staffNo")}
  65. error={Boolean(errors.staffNo)}
  66. helperText={
  67. Boolean(errors.staffNo) && errors.staffNo?.message
  68. ? t(errors.staffNo.message)
  69. : ""
  70. }
  71. />
  72. </Grid>
  73. <Grid item xs={6}>
  74. <TextField
  75. label={t("name")}
  76. fullWidth
  77. variant="filled"
  78. InputLabelProps={{
  79. shrink: !!name,
  80. sx: { fontSize: "0.9375rem" },
  81. }}
  82. InputProps={{
  83. sx: { paddingTop: "8px" },
  84. }}
  85. {...register("name", {
  86. required: "name required!",
  87. })}
  88. error={Boolean(errors.name)}
  89. helperText={
  90. Boolean(errors.name) && errors.name?.message
  91. ? t(errors.name.message)
  92. : ""
  93. }
  94. />
  95. </Grid>
  96. <Grid item xs={6}>
  97. <TextField
  98. label={t("password")}
  99. fullWidth
  100. type="password"
  101. variant="filled"
  102. InputLabelProps={{
  103. shrink: !!password,
  104. sx: { fontSize: "0.9375rem" },
  105. }}
  106. InputProps={{
  107. sx: { paddingTop: "8px" },
  108. }}
  109. {...register("password")}
  110. helperText={
  111. Boolean(errors.password) &&
  112. (errors.password?.message
  113. ? t(errors.password.message)
  114. : t("Please input correct password"))
  115. }
  116. error={Boolean(errors.password)}
  117. />
  118. </Grid>
  119. </Grid>
  120. </CardContent>
  121. </Card>
  122. );
  123. };
  124. export default UserDetail;