Browse Source

fix: search secret users

stage
Vitalik 3 months ago
parent
commit
452961036a
  1. 9
      src/containers/SecretMod/components/users-table.component.tsx
  2. 4
      src/containers/SecretMod/states/add-users-modal.state.ts
  3. 2
      src/containers/SecretMod/states/search.state.ts
  4. 2
      src/containers/SecretMod/widgets/secret-users.widget.tsx

9
src/containers/SecretMod/components/users-table.component.tsx

@ -4,7 +4,7 @@ import { secretUsersTableColumns } from "../config"; @@ -4,7 +4,7 @@ import { secretUsersTableColumns } from "../config";
import { CustomTableRow } from "@/components/TableGrid/components";
import { usePaginationList } from "@/shared";
import { secretModApi } from "@/api/secret-mod/requests";
import { useSecretUsersList } from "../states";
import { useSearchState, useSecretUsersList } from "../states";
import { useSecretEventsListener } from "../events";
import "./style.scss";
import { useSecretUsersEdit } from "../hooks";
@ -12,6 +12,7 @@ import { useSecretUsersEdit } from "../hooks"; @@ -12,6 +12,7 @@ import { useSecretUsersEdit } from "../hooks";
export const SecretUsersTable = () => {
const navigateToUser = () => {};
const { remove } = useSecretUsersEdit();
const { value } = useSearchState();
const defaultColumnsActive = ["avatarUrl", "name", "email", "actions"];
@ -29,6 +30,12 @@ export const SecretUsersTable = () => { @@ -29,6 +30,12 @@ export const SecretUsersTable = () => {
useSecretUsersList.getState().setUsers(paginationList.items);
}, [paginationList.items]);
useEffect(() => {
if (value !== null) {
paginationList.setLoadParams({ searchString: value });
}
}, [value]);
useSecretEventsListener("addUsers", () => {
paginationList.resetFlatList();
});

4
src/containers/SecretMod/states/add-users-modal.state.ts

@ -24,8 +24,8 @@ export const useAddUsersModalState = create<State>()((set) => ({ @@ -24,8 +24,8 @@ export const useAddUsersModalState = create<State>()((set) => ({
},
select(userIds) {
set((state) => ({
usersIdsSelected: _.uniq([...state.usersIdsSelected, ...userIds]),
set(() => ({
usersIdsSelected: _.uniq(userIds),
}));
},
}));

2
src/containers/SecretMod/states/search.state.ts

@ -6,6 +6,6 @@ interface State { @@ -6,6 +6,6 @@ interface State {
}
export const useSearchState = create<State>()((set) => ({
value: "",
value: null,
onChange: (value) => set({ value }),
}));

2
src/containers/SecretMod/widgets/secret-users.widget.tsx

@ -11,10 +11,8 @@ export const SecretUsersWidget = () => { @@ -11,10 +11,8 @@ export const SecretUsersWidget = () => {
<div>
<CardBody>
<UsersTableHeader />
<SecretUsersTable />
</CardBody>
<AddUsersModal />
</div>
);

Loading…
Cancel
Save