V6.5 Geofences page, Mobile, Remove Problem

Byhturka month ago

On mobile, the region cannot be removed from the menu on the geofences page. Is there a possible temporary solution?
remove button does not work.

Ekran görüntüsü 2024-10-14 020619.png

Cristiana month ago
Cristiana month ago

I found this solution using React's Portal component
https://mui.com/base-ui/react-portal/

import React from 'react';
import Button from '@mui/material/Button';
import { Snackbar } from '@mui/material';
import makeStyles from '@mui/styles/makeStyles';
import { useTranslation } from './LocalizationProvider';
import { useCatch } from '../../reactHelper';
import { snackBarDurationLongMs } from '../util/duration';
import { Portal } from '@mui/base/Portal';


const useStyles = makeStyles((theme) => ({
  root: {
    [theme.breakpoints.down('md')]: {
      bottom: `calc(${theme.dimensions.bottomBarHeight}px + ${theme.spacing(1)})`,
    },
  },
  button: {
    height: 'auto',
    marginTop: 0,
    marginBottom: 0,
  },
}));

const RemoveDialog = ({
  open, endpoint, itemId, onResult,
}) => {
  const classes = useStyles();
  const t = useTranslation();

  const handleRemove = useCatch(async () => {
    const response = await fetch(`/api/${endpoint}/${itemId}`, { method: 'DELETE' });
    if (response.ok) {
      onResult(true);
    } else {
      throw Error(await response.text());
    }
  });

  return (
    <Portal>
      <Snackbar
        className={classes.root}
        open={open}
        autoHideDuration={snackBarDurationLongMs}
        onClose={() => onResult(false)}
        message={t('sharedRemoveConfirm')}
        action={(
          <Button size="small" className={classes.button} color="error" onClick={handleRemove}>
            {t('sharedRemove')}
          </Button>
        )}
      />
    </Portal>
  );
};

export default RemoveDialog;

Captura de pantalla 2024-10-13 a la(s) 9.20.50 p.m..png

Anton Tananaeva month ago
Byhturka month ago

Yes, the problem is solved. Thank you for your efforts.