Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 

100 Zeilen
2.5 KiB

  1. import {
  2. Box,
  3. Button,
  4. Dialog,
  5. DialogActions,
  6. DialogContent,
  7. DialogTitle,
  8. Stack,
  9. Typography,
  10. styled,
  11. } from "@mui/material";
  12. import PastEntryCalendar, {
  13. Props as PastEntryCalendarProps,
  14. } from "./PastEntryCalendar";
  15. import { useCallback, useState } from "react";
  16. import { useTranslation } from "react-i18next";
  17. import { ArrowBack } from "@mui/icons-material";
  18. interface Props extends Omit<PastEntryCalendarProps, "onDateSelect"> {
  19. open: boolean;
  20. handleClose: () => void;
  21. }
  22. const Indicator = styled(Box)(() => ({
  23. borderRadius: "50%",
  24. width: "1rem",
  25. height: "1rem",
  26. }));
  27. const PastEntryCalendarModal: React.FC<Props> = ({
  28. handleClose,
  29. open,
  30. timesheet,
  31. leaves,
  32. }) => {
  33. const { t } = useTranslation("home");
  34. const [selectedDate, setSelectedDate] = useState("");
  35. const clearDate = useCallback(() => {
  36. setSelectedDate("");
  37. }, []);
  38. const onClose = useCallback(() => {
  39. handleClose();
  40. }, [handleClose]);
  41. return (
  42. <Dialog onClose={onClose} open={open}>
  43. <DialogTitle>{t("Past Entries")}</DialogTitle>
  44. <DialogContent>
  45. {selectedDate ? (
  46. <Box>{selectedDate}</Box>
  47. ) : (
  48. <Box>
  49. <Stack>
  50. <Box display="flex" alignItems="center" gap={1}>
  51. <Indicator sx={{ backgroundColor: "info.light" }} />
  52. <Typography variant="caption">
  53. {t("Has timesheet entry")}
  54. </Typography>
  55. </Box>
  56. <Box display="flex" alignItems="center" gap={1}>
  57. <Indicator sx={{ backgroundColor: "warning.light" }} />
  58. <Typography variant="caption">
  59. {t("Has leave entry")}
  60. </Typography>
  61. </Box>
  62. <Box display="flex" alignItems="center" gap={1}>
  63. <Indicator sx={{ backgroundColor: "success.light" }} />
  64. <Typography variant="caption">
  65. {t("Has both timesheet and leave entry")}
  66. </Typography>
  67. </Box>
  68. </Stack>
  69. <PastEntryCalendar
  70. timesheet={timesheet}
  71. leaves={leaves}
  72. onDateSelect={setSelectedDate}
  73. />
  74. </Box>
  75. )}
  76. </DialogContent>
  77. {selectedDate && (
  78. <DialogActions>
  79. <Button
  80. variant="outlined"
  81. startIcon={<ArrowBack />}
  82. onClick={clearDate}
  83. >
  84. {t("Back")}
  85. </Button>
  86. </DialogActions>
  87. )}
  88. </Dialog>
  89. );
  90. };
  91. export default PastEntryCalendarModal;