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

84 行
2.1 KiB

  1. import React, { useCallback, useState } from 'react';
  2. import {
  3. Modal,
  4. Box,
  5. Typography,
  6. Button,
  7. SxProps,
  8. CardContent,
  9. CardActions,
  10. Card
  11. } from '@mui/material';
  12. import { useTranslation } from 'react-i18next';
  13. import { FormProvider, SubmitHandler, useForm } from 'react-hook-form';
  14. import { Check, Close } from "@mui/icons-material";
  15. import InvoiceTable from './InvoiceTable';
  16. interface Props {
  17. isOpen: boolean,
  18. onClose: () => void;
  19. }
  20. const modalSx: SxProps= {
  21. position: "absolute",
  22. top: "50%",
  23. left: "50%",
  24. transform: "translate(-50%, -50%)",
  25. width: { xs: "calc(100% - 2rem)", sm: "90%" },
  26. maxHeight: "90%",
  27. maxWidth: 1400,
  28. bgcolor: 'background.paper',
  29. };
  30. const CreateInvoiceModal: React.FC<Props> = ({isOpen, onClose}) => {
  31. const { t } = useTranslation()
  32. const formProps = useForm<any>();
  33. const onSubmit = useCallback<SubmitHandler<any>>(
  34. (data) => {
  35. console.log(data)
  36. }
  37. , [])
  38. return (
  39. <FormProvider {...formProps}>
  40. <Modal
  41. open={isOpen}
  42. onClose={onClose}
  43. >
  44. <Card sx={modalSx}>
  45. <CardContent
  46. component="form"
  47. onSubmit={formProps.handleSubmit(onSubmit)}
  48. >
  49. <Typography variant="overline" display="block" marginBlockEnd={1}>
  50. {t("Invoice Creation")}
  51. </Typography>
  52. <Box
  53. sx={{
  54. marginInline: -4,
  55. marginBlock: 4,
  56. }}
  57. >
  58. <InvoiceTable/>
  59. </Box>
  60. <CardActions sx={{ justifyContent: "flex-end" }}>
  61. <Button
  62. variant="outlined"
  63. startIcon={<Close />}
  64. onClick={onClose}
  65. >
  66. {t("Cancel")}
  67. </Button>
  68. <Button variant="contained" startIcon={<Check />} type="submit">
  69. {t("Save")}
  70. </Button>
  71. </CardActions>
  72. </CardContent>
  73. </Card>
  74. </Modal>
  75. </FormProvider>
  76. );
  77. };
  78. export default CreateInvoiceModal;