Skip to content

Commit

Permalink
fix(clerk-js): Mutate membership requests after accept or reject
Browse files Browse the repository at this point in the history
  • Loading branch information
panteliselef committed Aug 24, 2023
1 parent de4dbe6 commit e642012
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const AddDomainPage = withCardStateProvider(() => {
return null;
}

const canSubmit = organization.name !== nameField.value;
const canSubmit = nameField.value.trim() !== '';

const onSubmit = (e: React.FormEvent) => {
nameField.setError(undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import { handleError } from '../../utils';
import { DataTable, RowContainer } from './MemberListTable';

const ITEMS_PER_PAGE = 10;

const membershipRequestsParams = {
pageSize: ITEMS_PER_PAGE,
};
export const RequestToJoinList = () => {
const card = useCardState();
const { organization, membershipRequests } = useCoreOrganization({
membershipRequests: {
pageSize: ITEMS_PER_PAGE,
},
membershipRequests: membershipRequestsParams,
});

if (!organization) {
Expand Down Expand Up @@ -47,26 +49,24 @@ const RequestRow = withCardStateProvider(
(props: { request: OrganizationMembershipRequestResource; onError: ReturnType<typeof useCardState>['setError'] }) => {
const { request, onError } = props;
const card = useCardState();
const { membershipRequests } = useCoreOrganization();

const mutateSwrState = () => {
const unstable__mutate = (membershipRequests as any).unstable__mutate;
if (unstable__mutate && typeof unstable__mutate === 'function') {
unstable__mutate();
}
};
const { membershipRequests } = useCoreOrganization({
membershipRequests: membershipRequestsParams,
});

const onAccept = () => {
return card
.runAsync(request.accept, 'accept')
.then(mutateSwrState)
.runAsync(async () => {
await request.accept();
await (membershipRequests as any).unstable__mutate?.();
}, 'accept')
.catch(err => handleError(err, [], onError));
};

const onReject = () => {
return card
.runAsync(request.reject, 'reject')
.then(mutateSwrState)
.runAsync(async () => {
await request.reject();
await (membershipRequests as any).unstable__mutate?.();
}, 'reject')
.catch(err => handleError(err, [], onError));
};

Expand Down
4 changes: 2 additions & 2 deletions packages/localizations/src/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,9 @@ export const enUS: LocalizationResource = {
},
},
createDomainPage: {
title: 'Add email domain',
title: 'Add domain',
subtitle:
'Add the email domain to verify. Users with email addresses at this domain can join the organization automatically or request to join.',
'Add the domain to verify. Users with email addresses at this domain can join the organization automatically or request to join.',
},
verifyDomainPage: {
title: 'Verify domain',
Expand Down

0 comments on commit e642012

Please sign in to comment.