You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

86 rivejä
2.0 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. isSaturdayWorker: boolean;
  29. }
  30. export const TimesheetAmendmentModal: React.FC<Props> = ({
  31. open,
  32. onClose,
  33. leaveTypes,
  34. teamLeaves,
  35. teamTimesheets,
  36. companyHolidays,
  37. allProjects,
  38. miscTasks,
  39. isSaturdayWorker,
  40. userId
  41. }) => {
  42. const { t } = useTranslation("home");
  43. const isMobile = useIsMobile();
  44. const title = t("Timesheet Amendments");
  45. const content = (
  46. <TimesheetAmendment
  47. leaveTypes={leaveTypes}
  48. teamLeaves={teamLeaves}
  49. companyHolidays={companyHolidays}
  50. teamTimesheets={teamTimesheets}
  51. allProjects={allProjects}
  52. miscTasks={miscTasks}
  53. isSaturdayWorker={isSaturdayWorker}
  54. userId={userId}
  55. />
  56. );
  57. return isMobile ? (
  58. <FullscreenModal open={open} onClose={onClose} closeModal={onClose}>
  59. <Box display="flex" flexDirection="column" gap={2} height="100%">
  60. <Typography variant="h6" flex="none" padding={2}>
  61. {title}
  62. </Typography>
  63. <Box paddingInline={2}>{content}</Box>
  64. </Box>
  65. </FullscreenModal>
  66. ) : (
  67. <Modal open={open} onClose={onClose}>
  68. <Card sx={modalSx}>
  69. <CardContent>
  70. <Typography variant="overline" display="block" marginBlockEnd={1}>
  71. {title}
  72. </Typography>
  73. <Box maxHeight={900} overflow="scroll">
  74. {content}
  75. </Box>
  76. </CardContent>
  77. </Card>
  78. </Modal>
  79. );
  80. };