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