SelectedFileOptions.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import { FluidContainer } from 'components/Container';
  2. import { SelectionBar } from '../../Navbar/SelectionBar';
  3. import constants from 'utils/strings/constants';
  4. import React, { useContext } from 'react';
  5. import { Box, IconButton, styled, Tooltip } from '@mui/material';
  6. import { DeduplicateContext } from 'pages/deduplicate';
  7. import { AppContext } from 'pages/_app';
  8. import CloseIcon from '@mui/icons-material/Close';
  9. import BackButton from '@mui/icons-material/ArrowBackOutlined';
  10. import DeleteIcon from '@mui/icons-material/Delete';
  11. import { getTrashFilesMessage } from 'utils/ui';
  12. const VerticalLine = styled('div')`
  13. position: absolute;
  14. width: 1px;
  15. top: 0;
  16. bottom: 0;
  17. background: #303030;
  18. `;
  19. const CheckboxText = styled('div')`
  20. margin-left: 0.5em;
  21. font-size: 16px;
  22. margin-right: 0.8em;
  23. `;
  24. interface IProps {
  25. deleteFileHelper: () => void;
  26. close: () => void;
  27. count: number;
  28. clearSelection: () => void;
  29. }
  30. export default function DeduplicateOptions({
  31. deleteFileHelper,
  32. close,
  33. count,
  34. clearSelection,
  35. }: IProps) {
  36. const deduplicateContext = useContext(DeduplicateContext);
  37. const { setDialogMessage } = useContext(AppContext);
  38. const trashHandler = () =>
  39. setDialogMessage(getTrashFilesMessage(deleteFileHelper));
  40. return (
  41. <SelectionBar>
  42. <FluidContainer>
  43. {count ? (
  44. <IconButton onClick={clearSelection}>
  45. <CloseIcon />
  46. </IconButton>
  47. ) : (
  48. <IconButton onClick={close}>
  49. <BackButton />
  50. </IconButton>
  51. )}
  52. <Box ml={1.5}>
  53. {count} {constants.SELECTED}
  54. </Box>
  55. </FluidContainer>
  56. <input
  57. type="checkbox"
  58. style={{
  59. width: '1em',
  60. height: '1em',
  61. }}
  62. value={
  63. deduplicateContext.clubSameTimeFilesOnly ? 'true' : 'false'
  64. }
  65. onChange={() => {
  66. deduplicateContext.setClubSameTimeFilesOnly(
  67. !deduplicateContext.clubSameTimeFilesOnly
  68. );
  69. }}></input>
  70. <CheckboxText>{constants.CLUB_BY_CAPTURE_TIME}</CheckboxText>
  71. <div>
  72. <VerticalLine />
  73. </div>
  74. <Tooltip title={constants.DELETE}>
  75. <IconButton onClick={trashHandler}>
  76. <DeleteIcon />
  77. </IconButton>
  78. </Tooltip>
  79. </SelectionBar>
  80. );
  81. }