選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

79 行
1.9 KiB

  1. import useIsMobile from "@/app/utils/useIsMobile";
  2. import React from "react";
  3. import FullscreenModal from "../FullscreenModal";
  4. import {
  5. Box,
  6. Card,
  7. CardContent,
  8. Modal,
  9. SxProps,
  10. Typography,
  11. } from "@mui/material";
  12. import { useTranslation } from "react-i18next";
  13. import TimesheetAmendment, {
  14. Props as TimesheetAmendmentProps,
  15. } from "./TimesheetAmendment";
  16. const modalSx: SxProps = {
  17. position: "absolute",
  18. top: "50%",
  19. left: "50%",
  20. transform: "translate(-50%, -50%)",
  21. width: { xs: "calc(100% - 2rem)", sm: "90%" },
  22. maxHeight: "90%",
  23. maxWidth: 1400,
  24. };
  25. interface Props extends TimesheetAmendmentProps {
  26. open: boolean;
  27. onClose: () => void;
  28. }
  29. export const TimesheetAmendmentModal: React.FC<Props> = ({
  30. open,
  31. onClose,
  32. leaveTypes,
  33. teamLeaves,
  34. teamTimesheets,
  35. companyHolidays,
  36. allProjects,
  37. }) => {
  38. const { t } = useTranslation("home");
  39. const isMobile = useIsMobile();
  40. const title = t("Timesheet Amendment");
  41. const content = (
  42. <TimesheetAmendment
  43. leaveTypes={leaveTypes}
  44. teamLeaves={teamLeaves}
  45. companyHolidays={companyHolidays}
  46. teamTimesheets={teamTimesheets}
  47. allProjects={allProjects}
  48. />
  49. );
  50. return isMobile ? (
  51. <FullscreenModal open={open} onClose={onClose} closeModal={onClose}>
  52. <Box display="flex" flexDirection="column" gap={2} height="100%">
  53. <Typography variant="h6" flex="none" padding={2}>
  54. {title}
  55. </Typography>
  56. <Box paddingInline={2}>{content}</Box>
  57. </Box>
  58. </FullscreenModal>
  59. ) : (
  60. <Modal open={open} onClose={onClose}>
  61. <Card sx={modalSx}>
  62. <CardContent>
  63. <Typography variant="overline" display="block" marginBlockEnd={1}>
  64. {title}
  65. </Typography>
  66. <Box maxHeight={900} overflow="scroll">
  67. {content}
  68. </Box>
  69. </CardContent>
  70. </Card>
  71. </Modal>
  72. );
  73. };