feat: disallow removing all comment thread targets (#779)

* feat: disallow removing all comment thread targets

Closes #431

* Rename variables

* Fix console error

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Thaïs
2023-07-21 01:17:43 +02:00
committed by GitHub
parent 872ec9e6bb
commit a2087da624
6 changed files with 174 additions and 155 deletions

View File

@ -79,7 +79,8 @@ export function Checkbox({
indeterminate,
variant = CheckboxVariant.Primary,
}: OwnProps) {
const [isInternalChecked, setIsInternalChecked] = React.useState(false);
const [isInternalChecked, setIsInternalChecked] =
React.useState<boolean>(false);
React.useEffect(() => {
setIsInternalChecked(checked);

View File

@ -23,17 +23,16 @@ export function MultipleEntitySelect<
CustomEntityForSelect extends EntityForSelect,
>({
entities,
onItemCheckChange,
onChange,
onSearchFilterChange,
searchFilter,
value,
}: {
entities: EntitiesForMultipleEntitySelect<CustomEntityForSelect>;
searchFilter: string;
onSearchFilterChange: (newSearchFilter: string) => void;
onItemCheckChange: (
newCheckedValue: boolean,
entity: CustomEntityForSelect,
) => void;
onChange: (value: Record<string, boolean>) => void;
value: Record<string, boolean>;
}) {
const debouncedSetSearchFilter = debounce(onSearchFilterChange, 100, {
leading: true,
@ -61,13 +60,9 @@ export function MultipleEntitySelect<
{entitiesInDropdown?.map((entity) => (
<DropdownMenuCheckableItem
key={entity.id}
checked={
entities.selectedEntities
?.map((selectedEntity) => selectedEntity.id)
?.includes(entity.id) ?? false
}
checked={value[entity.id]}
onChange={(newCheckedValue) =>
onItemCheckChange(newCheckedValue, entity)
onChange({ ...value, [entity.id]: newCheckedValue })
}
>
<Avatar