Shared:Selectors:Group Fixed disabling the button

This commit is contained in:
Akmal Isomadinov 2024-04-08 17:04:49 +05:00
parent 77729284e7
commit 4d341eeb3c

View File

@ -54,6 +54,8 @@ const GroupsSelector = (props: GroupsSelectorProps) => {
const [hasNextPage, setHasNextPage] = useState(false);
const [isNextPageLoading, setIsNextPageLoading] = useState(false);
const [itemsList, setItemsList] = useState<TSelectorItem[]>([]);
const [selectedItem, setSelectedItem] = useState<TSelectorItem | null>(null);
const isFirstLoad = useRef(true);
const afterSearch = useRef(false);
const totalRef = useRef(0);
@ -67,6 +69,12 @@ const GroupsSelector = (props: GroupsSelectorProps) => {
isDoubleClick: boolean,
doubleClickCallback: () => void,
) => {
setSelectedItem((el) => {
if (el?.id === item.id) return null;
return item;
});
if (isDoubleClick) {
doubleClickCallback();
}
@ -145,13 +153,14 @@ const GroupsSelector = (props: GroupsSelectorProps) => {
...headerProps,
headerLabel: headerProps?.headerLabel || t("Common:Groups"),
}}
alwaysShowFooter
withSearch
searchPlaceholder={t("Common:Search")}
onSearch={onSearch}
searchValue={searchValue}
onClearSearch={onClearSearch}
isSearchLoading={false}
disableSubmitButton={false}
disableSubmitButton={!selectedItem}
isMultiSelect={false}
items={itemsList}
submitButtonLabel={t("Common:SelectAction")}