1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00
unleash.unleash/frontend/src/component/segments/EditSegmentButton/EditSegmentButton.tsx

34 lines
1.1 KiB
TypeScript
Raw Normal View History

import { ISegment } from 'interfaces/segment';
import { Edit } from '@mui/icons-material';
import PermissionIconButton from 'component/common/PermissionIconButton/PermissionIconButton';
import { UPDATE_SEGMENT } from 'component/providers/AccessProvider/permissions';
import { useNavigate } from 'react-router-dom';
import { useOptionalPathParam } from 'hooks/useOptionalPathParam';
interface IEditSegmentButtonProps {
segment: ISegment;
}
export const EditSegmentButton = ({ segment }: IEditSegmentButtonProps) => {
const projectId = useOptionalPathParam('projectId');
const navigate = useNavigate();
return (
<PermissionIconButton
onClick={() => {
if (projectId) {
navigate(
`/projects/${projectId}/settings/segments/edit/${segment.id}`
);
} else {
navigate(`/segments/edit/${segment.id}`);
}
}}
permission={UPDATE_SEGMENT}
tooltipProps={{ title: 'Edit segment' }}
>
<Edit data-loading />
</PermissionIconButton>
);
};