Skip to content

Commit

Permalink
Fix group table being cleared after adding a new member
Browse files Browse the repository at this point in the history
  • Loading branch information
falbru committed Jan 28, 2024
1 parent 00a2861 commit 3b89bb3
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions app/routes/admin/groups/components/AddGroupMember.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { SubmitButton } from 'app/components/Form/SubmitButton';
import { useAppDispatch } from 'app/store/hooks';
import { roleOptions } from 'app/utils/constants';
import { createValidator, required } from 'app/utils/validation';
import { fetchMembershipsPagination } from 'app/actions/GroupActions';
import { defaultGroupMembersQuery } from 'app/routes/admin/groups/components/GroupMembers';
import useQuery from 'app/utils/useQuery';

const validate = createValidator({
user: [required()],
Expand All @@ -18,6 +21,7 @@ type Props = {

const AddGroupMember = ({ groupId }: Props) => {
const dispatch = useAppDispatch();
const { query } = useQuery(defaultGroupMembersQuery);

const handleSubmit = (values, form) => {
dispatch(
Expand All @@ -26,9 +30,19 @@ const AddGroupMember = ({ groupId }: Props) => {
userId: values.user.id,
role: values.role.value,
})
).then(() => {
form.reset();
});
)
.then(() =>
dispatch(
fetchMembershipsPagination({
groupId,
next: true,
query,
})
)
)
.then(() => {
form.reset();
});
};

return (
Expand Down

0 comments on commit 3b89bb3

Please sign in to comment.