2022-05-25 12:36:58 +02:00
|
|
|
import { VFC } from 'react';
|
2022-05-20 10:29:23 +02:00
|
|
|
import { useNavigate } from 'react-router-dom';
|
2022-05-25 12:36:58 +02:00
|
|
|
import { useMediaQuery } from '@mui/material';
|
2022-05-20 10:29:23 +02:00
|
|
|
import { Add } from '@mui/icons-material';
|
|
|
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
|
|
|
import { CREATE_CONTEXT_FIELD } from 'component/providers/AccessProvider/permissions';
|
2022-05-24 10:58:06 +02:00
|
|
|
import PermissionButton from 'component/common/PermissionButton/PermissionButton';
|
|
|
|
import PermissionIconButton from 'component/common/PermissionIconButton/PermissionIconButton';
|
2022-05-20 10:29:23 +02:00
|
|
|
|
|
|
|
interface IAddContextButtonProps {}
|
|
|
|
|
|
|
|
export const AddContextButton: VFC<IAddContextButtonProps> = () => {
|
|
|
|
const smallScreen = useMediaQuery('(max-width:700px)');
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ConditionallyRender
|
2022-05-24 10:58:06 +02:00
|
|
|
condition={smallScreen}
|
2022-05-20 10:29:23 +02:00
|
|
|
show={
|
2022-05-24 10:58:06 +02:00
|
|
|
<PermissionIconButton
|
|
|
|
permission={CREATE_CONTEXT_FIELD}
|
|
|
|
onClick={() => navigate('/context/create')}
|
|
|
|
size="large"
|
|
|
|
tooltipProps={{ title: 'Add context type' }}
|
|
|
|
>
|
|
|
|
<Add />
|
|
|
|
</PermissionIconButton>
|
|
|
|
}
|
|
|
|
elseShow={
|
|
|
|
<PermissionButton
|
|
|
|
onClick={() => navigate('/context/create')}
|
|
|
|
permission={CREATE_CONTEXT_FIELD}
|
|
|
|
color="primary"
|
|
|
|
variant="contained"
|
|
|
|
>
|
|
|
|
New context field
|
|
|
|
</PermissionButton>
|
2022-05-20 10:29:23 +02:00
|
|
|
}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|