Skip to content

Commit

Permalink
Bug Report: Join Organization Error on "View All Organizations" Page …
Browse files Browse the repository at this point in the history
…Fixed ✅ (PalisadoesFoundation#1660)

* Create authorized-change.py

* Update authorized-changes-detection.yml

* Update authorized-changes-detection.yml

* Update count_changed_files.py

* Update count_changed_files.py

* Update count_changed_files.py

* Create sensitive_files.txt

* Update pull-requests.yml

* Update pull-requests.yml

* Update pull-requests.yml

* Update pull-requests.yml

* Update pull-requests.yml

* Update pull-requests.yml

* Update pull-requests.yml

* Update count_changed_files.py

* Update count_changed_files.py

* Update count_changed_files.py

* Delete .github/workflows/authorized-change.py

* reviews changes done

* fetch-depth testing

* Update pull-requests.yml

* Update check_files.py

* Update pull-requests.yml

* renamed

* changes

* ..

* reviewed changes

* optimize system exits

* added node-version path

* black formatting added

* base branch checks removed

* Update pull-request.yml

* Update bug-report.md

* Revert "Update bug-report.md"

This reverts commit 6bca290.

* Update check_files.py

* Update pull-request.yml

* Update pull-request.yml

* verbose update

* Update check_files.py

* Update pull-request.yml

* Update pull-request.yml

* Revert "Update pull-request.yml"

This reverts commit 904cf09.

* Revert "Update pull-request.yml"

This reverts commit 3f5cdf0.

* upgrade python version

* Update check_files.py

* Update check_files.py

* Update check_files.py

* Update check_files.py

* Update check_files.py

* Update check_files.py

* Update check_files.py

* Update check_files.py

* Update check_files.py

* testing another action jitterbit

* Revert "testing another action jitterbit"

This reverts commit 1f415b5.

* another approach

* changed

* Revert "changed"

This reverts commit 0833ea8.

* Revert "another approach"

This reverts commit c42e521.

* Revert "Revert "testing another action jitterbit""

This reverts commit 5808e81.

* Revert "testing another action jitterbit"

This reverts commit 1f415b5.

* Revert "Update check_files.py"

This reverts commit a7bea70.

* Revert "Update check_files.py"

This reverts commit ce2f0f4.

* Revert "Update check_files.py"

This reverts commit 0ebe09f.

* Revert "Update check_files.py"

This reverts commit cdfed59.

* Revert "Update check_files.py"

This reverts commit f3b7581.

* Revert "Update check_files.py"

This reverts commit dd03048.

* Revert "Update check_files.py"

This reverts commit 64946f9.

* Revert "Update check_files.py"

This reverts commit 4b0a96b.

* Revert "Revert "Update pull-request.yml""

This reverts commit bab432c.

* Revert "Update pull-request.yml"

This reverts commit 3f5cdf0.

* Revert "Update check_files.py"

This reverts commit aec56d1.

* cards,toaster,error handling,tests added

* matched develop dir

* jest.mock added

* minor

* coverage

* naming

* renamed toasts

---------

Co-authored-by: Peter Harrison <[email protected]>
  • Loading branch information
2 people authored and kanhaiya04 committed Mar 5, 2024
1 parent 3a27f8b commit cda3e27
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 21 deletions.
6 changes: 5 additions & 1 deletion public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@
"members": "Members",
"joinNow": "Join Now",
"joined": "Joined",
"withdraw": "Widthdraw"
"withdraw": "Widthdraw",
"orgJoined": "Joined organization successfully",
"MembershipRequestSent": "Membership request sent successfully",
"AlreadyJoined": "You are already a member of this organization.",
"errorOccured": "An error occurred. Please try again later."
},
"dashboard": {
"title": "Dashboard",
Expand Down
6 changes: 5 additions & 1 deletion public/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@
"members": "Membres",
"joinNow": "Adhérer maintenant",
"joined": "Rejointes",
"withdraw": "Retirer"
"withdraw": "Retirer",
"orgJoined": "Organisation rejointe avec succès",
"MembershipRequestSent": "Demande d'adhésion envoyée avec succès",
"AlreadyJoined": "Vous êtes déjà membre de cette organisation.",
"errorOccured": "Une erreur s'est produite. Veuillez réessayer plus tard."
},
"dashboard": {
"title": "Tableau de bord",
Expand Down
6 changes: 5 additions & 1 deletion public/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@
"members": "सदस्य",
"joinNow": "अब शामिल हों",
"joined": "शामिल हुए",
"withdraw": "अनुरोध वापस लें"
"withdraw": "अनुरोध वापस लें",
"orgJoined": "संगठन सफलतापूर्वक जुड़ा गया",
"MembershipRequestSent": "सदस्यता अनुरोध सफलतापूर्वक भेजा गया",
"AlreadyJoined": "आप इस संगठन के पहले से ही सदस्य हैं।",
"errorOccured": "कुछ गड़बड़ हो गई है। कृपया बाद में पुन: प्रयास करें।"
},
"dashboard": {
"title": "डैशबोर्ड",
Expand Down
6 changes: 5 additions & 1 deletion public/locales/sp.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@
"members": "Miembros",
"joinNow": "Únete ahora",
"joined": "Unido",
"withdraw": "retirar"
"withdraw": "retirar",
"orgJoined": "Unido a la organización exitosamente",
"MembershipRequestSent": "Solicitud de membresía enviada exitosamente",
"AlreadyJoined": "Ya eres miembro de esta organización.",
"errorOccured": "Se produjo un error. Por favor, inténtalo de nuevo más tarde."
},
"dashboard": {
"title": "Panel de",
Expand Down
6 changes: 5 additions & 1 deletion public/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@
"members": "成員",
"joinNow": "现在加入",
"joined": "加入",
"withdraw": "提取"
"withdraw": "提取",
"orgJoined": "成功加入组织",
"MembershipRequestSent": "会员申请已成功发送",
"AlreadyJoined": "您已经是该组织的成员。",
"errorOccured": "发生错误,请稍后重试。"
},
"dashboard": {
"title": "儀表板",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@ import {
SEND_MEMBERSHIP_REQUEST,
JOIN_PUBLIC_ORGANIZATION,
} from 'GraphQl/Mutations/OrganizationMutations';
import { toast } from 'react-toastify';

const { getItem } = useLocalStorage();

jest.mock('react-toastify', () => ({
toast: {
success: jest.fn(),
error: jest.fn(),
},
}));

const MOCKS = [
{
request: {
Expand Down Expand Up @@ -239,6 +247,11 @@ describe('Testing OrganizationCard Component [User Portal]', () => {
expect(screen.getByTestId('joinBtn')).toBeInTheDocument();

fireEvent.click(screen.getByTestId('joinBtn'));
await wait();

expect(toast.success).toHaveBeenCalledWith(
'Membership request sent successfully',
);
});

test('send membership request to public org', async () => {
Expand Down Expand Up @@ -266,6 +279,11 @@ describe('Testing OrganizationCard Component [User Portal]', () => {
expect(screen.getByTestId('joinBtn')).toBeInTheDocument();

fireEvent.click(screen.getByTestId('joinBtn'));
await wait();

expect(toast.success).toHaveBeenCalledWith(
'Joined organization successfully',
);
});

test('withdraw membership request', async () => {
Expand Down
44 changes: 28 additions & 16 deletions src/components/UserPortal/OrganizationCard/OrganizationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Button } from 'react-bootstrap';
import { Tooltip } from '@mui/material';
import { useTranslation } from 'react-i18next';
import LocationOnIcon from '@mui/icons-material/LocationOn';
import { toast } from 'react-toastify';
import {
CANCEL_MEMBERSHIP_REQUEST,
JOIN_PUBLIC_ORGANIZATION,
Expand Down Expand Up @@ -53,38 +54,49 @@ function organizationCard(props: InterfaceOrganizationCardProps): JSX.Element {
});
const [sendMembershipRequest] = useMutation(SEND_MEMBERSHIP_REQUEST, {
refetchQueries: [
{ query: USER_ORGANIZATION_CONNECTION, variables: { id: userId } },
{ query: USER_ORGANIZATION_CONNECTION, variables: { id: props.id } },
],
});
const [joinPublicOrganization] = useMutation(JOIN_PUBLIC_ORGANIZATION, {
refetchQueries: [
{ query: USER_ORGANIZATION_CONNECTION, variables: { id: userId } },
{ query: USER_ORGANIZATION_CONNECTION, variables: { id: props.id } },
],
});
const [cancelMembershipRequest] = useMutation(CANCEL_MEMBERSHIP_REQUEST, {
refetchQueries: [
{ query: USER_ORGANIZATION_CONNECTION, variables: { id: userId } },
{ query: USER_ORGANIZATION_CONNECTION, variables: { id: props.id } },
],
});
const { refetch } = useQuery(USER_JOINED_ORGANIZATIONS, {
variables: { id: userId },
});

async function joinOrganization(): Promise<void> {
if (props.userRegistrationRequired) {
await sendMembershipRequest({
variables: {
organizationId: props.id,
},
});
} else {
await joinPublicOrganization({
variables: {
organizationId: props.id,
},
});
try {
if (props.userRegistrationRequired) {
await sendMembershipRequest({
variables: {
organizationId: props.id,
},
});
toast.success(t('MembershipRequestSent'));
} else {
await joinPublicOrganization({
variables: {
organizationId: props.id,
},
});
toast.success(t('orgJoined'));
}
refetch();
} catch (error: any) {
/* istanbul ignore next */
if (error.message === 'User is already a member') {
toast.error(t('AlreadyJoined'));
} else {
toast.error(t('errorOccured'));
}
}
refetch();
}

async function withdrawMembershipRequest(): Promise<void> {
Expand Down

0 comments on commit cda3e27

Please sign in to comment.