2024-11-06 07:15:27 -05:00
|
|
|
import React from 'react';
|
|
|
|
|
import { Icons } from '../Icons';
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
2025-03-17 22:34:34 -04:00
|
|
|
import { useSegmentationTableContext } from './contexts';
|
2024-11-06 07:15:27 -05:00
|
|
|
|
|
|
|
|
export const AddSegmentationRow: React.FC<{ children?: React.ReactNode }> = ({
|
|
|
|
|
children = null,
|
|
|
|
|
}) => {
|
|
|
|
|
const { t } = useTranslation('SegmentationTable');
|
|
|
|
|
|
|
|
|
|
const { onSegmentationAdd, data, disableEditing, mode, disabled } =
|
2025-03-17 22:34:34 -04:00
|
|
|
useSegmentationTableContext('AddSegmentationRow');
|
2024-11-06 07:15:27 -05:00
|
|
|
|
|
|
|
|
const isEmpty = data.length === 0;
|
|
|
|
|
|
|
|
|
|
if (!isEmpty && mode === 'collapsed') {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (disableEditing) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
className={`group ${disabled ? 'pointer-events-none cursor-not-allowed opacity-70' : ''}`}
|
|
|
|
|
onClick={() => !disabled && onSegmentationAdd('')}
|
|
|
|
|
>
|
|
|
|
|
{children}
|
2025-04-04 12:11:29 -04:00
|
|
|
<div className="text-primary group-hover:bg-secondary-dark flex items-center rounded-[4px] pl-1 group-hover:cursor-pointer">
|
2024-11-06 07:15:27 -05:00
|
|
|
<div className="grid h-[28px] w-[28px] place-items-center">
|
|
|
|
|
{disabled ? <Icons.Info /> : <Icons.Add />}
|
|
|
|
|
</div>
|
|
|
|
|
<span className="text-[13px]">
|
|
|
|
|
{t(`${disabled ? 'Segmentation Not Supported' : 'Add Segmentation'}`)}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|