Skip to content

Commit

Permalink
fix(clerk-js): Revalidate invitations table after invitation screen s…
Browse files Browse the repository at this point in the history
…ubmit (#2195) (#2197)
  • Loading branch information
panteliselef authored Nov 23, 2023
1 parent bfa1b78 commit e7d8730
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/grumpy-suns-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Revalidate invitations table after invitation screen submit.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ type InviteMembersFormProps = {
export const InviteMembersForm = (props: InviteMembersFormProps) => {
const { navigate } = useRouter();
const { onSuccess, onReset = () => navigate('..'), resetButtonLabel } = props;
const { organization } = useCoreOrganization();
const { organization, invitations } = useCoreOrganization({
invitations: {
pageSize: 10,
keepPreviousData: true,
},
});
const card = useCardState();
const { t, locale } = useLocalizations();
const [isValidUnsubmittedEmail, setIsValidUnsubmittedEmail] = useState(false);
Expand Down Expand Up @@ -73,7 +78,10 @@ export const InviteMembersForm = (props: InviteMembersFormProps) => {
emailAddresses: emailAddressField.value.split(','),
role: submittedData.get('role') as MembershipRole,
})
.then(onSuccess)
.then(async () => {
await invitations?.revalidate?.();
return onSuccess();
})
.catch(err => {
if (isClerkAPIResponseError(err)) {
removeInvalidEmails(err.errors[0]);
Expand Down

0 comments on commit e7d8730

Please sign in to comment.