您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

77 行
2.4 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 FormControl from "@mui/material/FormControl";
  7. import Grid from "@mui/material/Grid";
  8. import InputLabel from "@mui/material/InputLabel";
  9. import MenuItem from "@mui/material/MenuItem";
  10. import Select from "@mui/material/Select";
  11. import { useTranslation } from "react-i18next";
  12. import ClaimFormInputGrid from "./ClaimFormInputGrid";
  13. import { expenseTypeCombo } from "@/app/utils/comboUtil";
  14. import { Controller, useFormContext } from "react-hook-form";
  15. import { ClaimInputFormByStaff } from "@/app/api/claims/actions";
  16. import { ProjectCombo } from "@/app/api/claims";
  17. import { TextField } from "@mui/material";
  18. interface Props {
  19. projectCombo: ProjectCombo[]
  20. }
  21. const ClaimFormInfo: React.FC<Props> = ({ projectCombo }) => {
  22. const { t } = useTranslation();
  23. const {
  24. control,
  25. register,
  26. } = useFormContext<ClaimInputFormByStaff>();
  27. return (
  28. <Card>
  29. <CardContent component={Stack} spacing={4}>
  30. <Box>
  31. <Grid container spacing={2} columns={{ xs: 6, sm: 12 }}>
  32. <Grid item xs={6}>
  33. <TextField
  34. fullWidth
  35. label={t("Claim Code")}
  36. {...register("code")}
  37. disabled={true}
  38. />
  39. </Grid>
  40. <Grid item xs={6}>
  41. <FormControl fullWidth>
  42. <InputLabel>{t("Expense Type")}</InputLabel>
  43. <Controller
  44. // defaultValue={expenseTypeCombo[0].value}
  45. control={control}
  46. name="expenseType"
  47. render={({ field }) => (
  48. <Select label={t("Expense Type")} {...field}>
  49. {
  50. expenseTypeCombo.map((type, index) => (
  51. <MenuItem key={`${type}-${index}`} value={type}>
  52. {t(type)}
  53. </MenuItem>
  54. ))
  55. }
  56. </Select>
  57. )}
  58. />
  59. </FormControl>
  60. </Grid>
  61. </Grid>
  62. </Box>
  63. <Card>
  64. <ClaimFormInputGrid projectCombo={projectCombo} />
  65. </Card>
  66. </CardContent>
  67. </Card>
  68. );
  69. };
  70. export default ClaimFormInfo;