chore: cannot have empty state group

This commit is contained in:
Aaryan Khandelwal 2023-02-24 16:22:49 +05:30
parent 3c6752807d
commit 522952fa59
2 changed files with 21 additions and 12 deletions

View File

@ -181,20 +181,29 @@ export const SingleState: React.FC<Props> = ({
</button> </button>
)} )}
<button
type="button"
className={`${state.default ? "cursor-not-allowed" : ""} grid place-items-center`}
onClick={handleDeleteState}
disabled={state.default}
>
<Tooltip tooltipContent="Cannot delete the default state." disabled={!state.default}>
<TrashIcon className="h-4 w-4 text-red-400" />
</Tooltip>
</button>
<button type="button" className="grid place-items-center" onClick={handleEditState}> <button type="button" className="grid place-items-center" onClick={handleEditState}>
<PencilSquareIcon className="h-4 w-4 text-gray-400" /> <PencilSquareIcon className="h-4 w-4 text-gray-400" />
</button> </button>
<button
type="button"
className={`${
state.default || groupLength === 1 ? "cursor-not-allowed" : ""
} grid place-items-center`}
onClick={handleDeleteState}
disabled={state.default || groupLength === 1}
>
{state.default ? (
<Tooltip tooltipContent="Cannot delete the default state.">
<TrashIcon className="h-4 w-4 text-red-400" />
</Tooltip>
) : groupLength === 1 ? (
<Tooltip tooltipContent="Cannot have an empty group.">
<TrashIcon className="h-4 w-4 text-red-400" />
</Tooltip>
) : (
<TrashIcon className="h-4 w-4 text-red-400" />
)}
</button>
</div> </div>
</div> </div>
); );

View File

@ -38,7 +38,7 @@ export const Tooltip: React.FC<Props> = ({
disabled={disabled} disabled={disabled}
content={ content={
<div <div
className={`flex flex-col justify-center items-start gap-1 max-w-[600px] text-xs rounded-md bg-white p-2 shadow-md capitalize text-left ${className}`} className={`flex flex-col justify-center items-start gap-1 max-w-[600px] text-xs rounded-md bg-white p-2 shadow-md text-left ${className}`}
> >
{tooltipHeading ? ( {tooltipHeading ? (
<> <>