Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 

81 righe
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 LeaveCalendar, { Props as LeaveCalendarProps } from "./LeaveCalendar";
  14. const modalSx: SxProps = {
  15. position: "absolute",
  16. top: "50%",
  17. left: "50%",
  18. transform: "translate(-50%, -50%)",
  19. width: { xs: "calc(100% - 2rem)", sm: "90%" },
  20. maxHeight: "90%",
  21. maxWidth: 1400,
  22. };
  23. interface Props extends LeaveCalendarProps {
  24. open: boolean;
  25. onClose: () => void;
  26. }
  27. const LeaveModal: React.FC<Props> = ({
  28. open,
  29. onClose,
  30. leaveTypes,
  31. companyHolidays,
  32. allProjects,
  33. leaveRecords,
  34. timesheetRecords,
  35. isFullTime,
  36. }) => {
  37. const { t } = useTranslation("home");
  38. const isMobile = useIsMobile();
  39. const title = t("Record leave");
  40. const content = (
  41. <LeaveCalendar
  42. isFullTime={isFullTime}
  43. leaveTypes={leaveTypes}
  44. companyHolidays={companyHolidays}
  45. allProjects={allProjects}
  46. leaveRecords={leaveRecords}
  47. timesheetRecords={timesheetRecords}
  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. };
  74. export default LeaveModal;