Skip to content

Feat : User can leave the org by clicking on button #2298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"updatedSuccessfully": "{{item}} updated Successfully",
"removedSuccessfully": "{{item}} removed Successfully",
"successfullyUpdated": "Successfully Updated",
"confirm": "Confirm",
"sessionWarning": "Your session will expire soon due to inactivity. Please interact with the page to extend your session.",
"sessionLogOut": "Your session has expired due to inactivity. Please log in again to continue.",
"sort": "Sort"
Expand Down
14 changes: 12 additions & 2 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@
"roleUpdated": "Role Updated.",
"joinNow": "Join Now",
"visit": "Visit",
"withdraw": "Widthdraw",
"leave": "Leave",
"withdraw": "Withdraw",
"removeUserFrom": "Remove User from {{org}}",
"removeConfirmation": "Are you sure you want to remove '{{name}}' from organization '{{org}}'?",
"searchByName": "searchByName",
Expand Down Expand Up @@ -982,6 +983,7 @@
"logout": "Logout",
"settings": "Settings",
"chat": "Chat",
"leave": "Leave Organization",
"menu": "menu"
},
"organizationSidebar": {
Expand Down Expand Up @@ -1205,7 +1207,8 @@
"deleteCategory": "Delete Category",
"deleteCategoryMsg": "Are you sure you want to delete this Action Item Category?",
"createButton": "createButton",
"editButton": "editButton"
"editButton": "editButton",
"categoryDetails": "categoryDetails"
Comment on lines +1210 to +1211
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Update placeholder values for new keys.

The addition of "editButton" and "categoryDetails" is appropriate. However, they have placeholder values that need to be replaced with proper translations.

Please update the following keys with appropriate translations:

-    "editButton": "editButton",
+    "editButton": "Edit",
-    "categoryDetails": "categoryDetails"
+    "categoryDetails": "Category Details"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"editButton": "editButton",
"categoryDetails": "categoryDetails"
"editButton": "Edit",
"categoryDetails": "Category Details"

},
"organizationVenues": {
"title": "Venues",
Expand Down Expand Up @@ -1319,5 +1322,12 @@
},
"userPledges": {
"title": "My Pledges"
},
"orgLeave": {
"confirmation": "Are you sure you want to leave the organization? ",
"heading": "Leaving organization ?",
"description": "Are you sure you want to leave the organization? This action cannot be undone. If the organization requires approval, you will not be able to rejoin without it. Any related data or permissions may also be lost.",
"errorOccured": "An error occurred. Please try again later.",
"orgLeft": "You have left the organization."
}
}
1 change: 1 addition & 0 deletions public/locales/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"updatedSuccessfully": "{{item}} mis à jour avec succès",
"removedSuccessfully": "{{item}} supprimé avec succès",
"successfullyUpdated": "Mis à jour avec succès",
"confirm": "Confirmer",
"sessionWarning": "Votre session expirera bientôt en raison de l'inactivité. Veuillez interagir avec la page pour prolonger votre session.",
"sessionLogOut": "Votre session a expiré en raison de l'inactivité. Veuillez vous reconnecter pour continuer."
}
12 changes: 11 additions & 1 deletion public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"roleUpdated": "Rôle mis à jour.",
"joinNow": "Adhérer maintenant",
"visit": "Visite",
"leave": "partir",
"withdraw": "Largeur de tirage",
"removeUserFrom": "Supprimer l'Utilisateur de {{org}}",
"removeConfirmation": "Êtes-vous sûr de vouloir supprimer '{{name}}' de l'organisation '{{org}}' ?",
Expand Down Expand Up @@ -977,6 +978,7 @@
"talawaUserPortal": "Portail utilisateur Talawa",
"my organizations": "Mes organisations",
"communityProfile": "Profil de la communauté",
"leave": "Quitter l'organisation",
"users": "utilisateurs",
"requests": "demandes",
"logout": "se déconnecter",
Expand Down Expand Up @@ -1205,7 +1207,8 @@
"deleteCategory": "Supprimer la catégorie",
"deleteCategoryMsg": "Êtes-vous sûr de vouloir supprimer cette catégorie d'élément d'action ?",
"createButton": "Créer",
"editButton": "Modifier"
"editButton": "Modifier",
"categoryDetails": "Détails de la catégorie"
},
"organizationVenues": {
"title": "Lieux",
Expand Down Expand Up @@ -1319,5 +1322,12 @@
},
"userPledges": {
"title": "Mes Promesses"
},
"orgLeave": {
"confirmation": "Etes-vous sûr de vouloir quitter l'organisation ? ",
"heading": "Quitter l'organisation ?",
"description": "Etes-vous sûr de vouloir quitter l'organisation ? Cette action ne peut pas être annulée. Si l'organisation nécessite une approbation, vous ne pourrez pas la rejoindre sans cette approbation. Toutes les données ou autorisations associées peuvent également être perdues.",
"errorOccured": "Une erreur s'est produite. Veuillez réessayer plus tard.",
"orgLeft": "Vous avez quitté l'organisation."
}
}
1 change: 1 addition & 0 deletions public/locales/hi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"updatedSuccessfully": "{{item}} सफलतापूर्वक अपडेट किया गया",
"removedSuccessfully": "{{item}} सफलतापूर्वक हटाया गया",
"successfullyUpdated": "सफलतापूर्वक अपडेट किया गया",
"confirm": "पुष्टि करें",
"sessionWarning": "आपका सत्र निष्क्रियता के कारण जल्द ही समाप्त हो जाएगा। कृपया अपने सत्र को बढ़ाने के लिए पृष्ठ के साथ बातचीत करें।",
"sessionLogOut": "निष्क्रियता के कारण आपका सत्र समाप्त हो गया है। कृपया जारी रखने के लिए पुनः लॉगिन करें।"
}
12 changes: 11 additions & 1 deletion public/locales/hi/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
"withdraw": "वापस लें",
"removeUserFrom": "{{org}} से उपयोगकर्ता को हटाएं",
"removeConfirmation": "क्या आप वाकई '{{name}}' को संगठन '{{org}}' से हटाना चाहते हैं?",
"leave": "छोड़ो",
"searchByName": "नाम से खोजें",
"users": "उपयोगकर्ता",
"name": "नाम",
Expand Down Expand Up @@ -977,6 +978,7 @@
"talawaUserPortal": "तलावा उपयोगकर्ता पोर्टल",
"my organizations": "मेरे संगठन",
"communityProfile": "सामुदायिक प्रोफ़ाइल",
"leave": "संगठन छोड़ें",
"users": "उपयोगकर्ता",
"requests": "अनुरोध",
"logout": "लॉग आउट",
Expand Down Expand Up @@ -1205,7 +1207,8 @@
"deleteCategory": "श्रेणी हटाएं",
"deleteCategoryMsg": "क्या आप वाकई इस कार्रवाई आइटम श्रेणी को हटाना चाहते हैं?",
"createButton": "बटन बनाएं",
"editButton": "संपादित बटन"
"editButton": "संपादित बटन",
"categoryDetails": "श्रेणी विवरण"
},
"organizationVenues": {
"title": "स्थानों",
Expand Down Expand Up @@ -1319,5 +1322,12 @@
},
"userPledges": {
"title": "मेरी प्रतिज्ञाएँ"
},
"orgLeave": {
"confirmation": "क्या आप वाकई संगठन छोड़ना चाहते हैं?",
"heading": "संगठन छोड़ रहे हैं?",
"description": "क्या आप वाकई संगठन छोड़ना चाहते हैं? इस एक्शन को वापस नहीं किया जा सकता। यदि संगठन को अनुमोदन की आवश्यकता है, तो आप इसके बिना पुनः शामिल नहीं हो पाएंगे। कोई भी संबंधित डेटा या अनुमतियाँ भी खो सकती हैं।",
"errorOccured": "एक त्रुटि पाई गई। कृपया बाद में पुन: प्रयास करें।",
"orgLeft": "आपने संगठन छोड़ दिया है."
}
}
1 change: 1 addition & 0 deletions public/locales/sp/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"updatedSuccessfully": "{{item}} actualizado con éxito",
"removedSuccessfully": "{{item}} eliminado con éxito",
"successfullyUpdated": "Actualizado con éxito",
"confirm": "Confirmar",
"sessionWarning": "Su sesión expirará pronto debido a la inactividad. Por favor, interactúe con la página para extender su sesión.",
"sessionLogOut": "Su sesión ha expirado debido a la inactividad. Por favor, inicie sesión nuevamente para continuar."
}
28 changes: 19 additions & 9 deletions public/locales/sp/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
"errorOccured": "Se produjo un error. Por favor, inténtalo de nuevo más tarde.",
"removeUserFrom": "Eliminar Usuario de {{org}}",
"removeConfirmation": "¿Está seguro de que desea eliminar a '{{name}}' de la organización '{{org}}'?",
"leave": "Dejar",
"noOrgError": "Error sin organización"
},
"communityProfile": {
Expand Down Expand Up @@ -760,13 +761,13 @@
},
"orgSettings": {
"title": "Configuración Talawa",
"pageName": "Configuración",
"general": "General",
"actionItemCategories": "Categorías de elementos de acción",
"updateYourDetails": "Actualiza tus datos",
"updateYourPassword": "Actualice su contraseña",
"updateOrganization": "Actualizar Organización",
"seeRequest": "Ver Solicitud",
"pageName": "Configuración",
"updateYourDetails": "Actualiza tus datos",
"updateYourPassword": "Actualice su contraseña",
"settings": "Ajustes",
"noData": "Sin datos",
"otherSettings": "Otras Configuraciones",
Expand Down Expand Up @@ -983,6 +984,7 @@
"communityProfile": "Perfil de la comunidad",
"logout": "Cerrar sesión",
"settings": "Ajustes",
"leave": "Dejar la organización",
"chat": "Chat"
},
"organizationSidebar": {
Expand Down Expand Up @@ -1090,8 +1092,8 @@
"donate": "Donar",
"nothingToShow": "Nada que mostrar aquí.",
"success": "Donación exitosa",
"invalidAmount": "Ingrese un valor numérico para el monto de la donación.",
"donationAmountDescription": "Ingrese el valor numérico del monto de la donación.",
"invalidAmount": "Por favor, ingrese un valor numérico para el monto de la donación.",
"donationAmountDescription": "Por favor, ingrese el valor numérico para el monto de la donación.",
"donationOutOfRange": "El monto de la donación debe estar entre {{min}} y {{max}}."
},
"userEvents": {
Expand Down Expand Up @@ -1202,11 +1204,12 @@
"sameNameConflict": "Cambie el nombre para realizar una actualización",
"categoryEnabled": "Categoría de elemento de acción habilitada",
"categoryDisabled": "Categoría de elemento de acción deshabilitada",
"noActionItemCategories": "No hay categorías de elementos de acción",
"noActionItemCategories": "No hay Categorías del Ítem de Acción",
"status": "Estado",
"categoryDeleted": "Categoría de elemento de acción eliminada",
"deleteCategory": "Eliminar categoría",
"deleteCategoryMsg": "¿Está seguro de que desea eliminar esta categoría de elemento de acción?"
"categoryDeleted": "Categoría del Ítem de Acción eliminada con éxito",
"deleteCategory": "Eliminar Categoría",
"deleteCategoryMsg": "¿Está seguro de que desea eliminar esta Categoría del Ítem de Acción?",
"categoryDetails": "Detalles de la categoría"
},
"organizationVenues": {
"title": "Lugares",
Expand Down Expand Up @@ -1320,5 +1323,12 @@
},
"userPledges": {
"title": "Mis Promesas"
},
"orgLeave": {
"confirmation": "¿Estás segura de que quieres dejar la organización?",
"heading": "¿Dejar la organización?",
"description": "¿Estás seguro de que quieres dejar la organización? Esta acción no se puede deshacer. Si la organización requiere aprobación, no podrás volver a unirte sin ella. También se pueden perder todos los datos o permisos relacionados.",
"errorOccured": "Se produjo un error. Inténtelo de nuevo más tarde.",
"orgLeft": "Has abandonado la organización."
Comment on lines +1328 to +1332
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Address typo and formality inconsistency in "orgLeave" section

The translations in the new "orgLeave" section are generally correct, but there are two issues to address:

  1. There's a typo in the key "errorOccured" (should be "errorOccurred").
  2. There's an inconsistency in the level of formality used across the translations.

Please make the following corrections:

  1. Fix the typo in the key name:
-    "errorOccured": "Se produjo un error. Inténtelo de nuevo más tarde.",
+    "errorOccurred": "Se produjo un error. Inténtelo de nuevo más tarde.",
  1. Maintain consistent formality (using informal "tú" form throughout):
-    "confirmation": "¿Estás segura de que quieres dejar la organización?",
+    "confirmation": "¿Estás seguro de que quieres dejar la organización?",
     "heading": "¿Dejar la organización?",
     "description": "¿Estás seguro de que quieres dejar la organización? Esta acción no se puede deshacer. Si la organización requiere aprobación, no podrás volver a unirte sin ella. También se pueden perder todos los datos o permisos relacionados.",
-    "errorOccurred": "Se produjo un error. Inténtelo de nuevo más tarde.",
+    "errorOccurred": "Se produjo un error. Inténtalo de nuevo más tarde.",
     "orgLeft": "Has abandonado la organización."

Note: If formal language is preferred, you should update all translations to use the formal "usted" form consistently.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"confirmation": "¿Estás segura de que quieres dejar la organización?",
"heading": "¿Dejar la organización?",
"description": "¿Estás seguro de que quieres dejar la organización? Esta acción no se puede deshacer. Si la organización requiere aprobación, no podrás volver a unirte sin ella. También se pueden perder todos los datos o permisos relacionados.",
"errorOccured": "Se produjo un error. Inténtelo de nuevo más tarde.",
"orgLeft": "Has abandonado la organización."
"confirmation": "¿Estás seguro de que quieres dejar la organización?",
"heading": "¿Dejar la organización?",
"description": "¿Estás seguro de que quieres dejar la organización? Esta acción no se puede deshacer. Si la organización requiere aprobación, no podrás volver a unirte sin ella. También se pueden perder todos los datos o permisos relacionados.",
"errorOccurred": "Se produjo un error. Inténtalo de nuevo más tarde.",
"orgLeft": "Has abandonado la organización."

}
}
1 change: 1 addition & 0 deletions public/locales/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"updatedSuccessfully": "{{item}} 更新成功",
"removedSuccessfully": "{{item}} 删除成功",
"successfullyUpdated": "更新成功",
"confirm": "确认",
"sessionWarning": "由于不活动,您的会话即将过期。请与页面互动以延长您的会话。",
"sessionLogOut": "由于不活动,您的会话已过期。请重新登录以继续。"
}
18 changes: 14 additions & 4 deletions public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@
"orgJoined": "已加入组织",
"MembershipRequestSent": "会员请求已发送",
"AlreadyJoined": "已加入",
"errorOccured": "发生错误"
"errorOccured": "发生错误",
"leave": "离开"
},
"communityProfile": {
"title": "社区简介",
Expand Down Expand Up @@ -407,7 +408,7 @@
"assignmentDate": "分配日期",
"active": "积极的",
"clearFilters": "清除过滤器",
"completed": "完全的",
"completed": "已完成",
"completionDate": "完成日期",
"createActionItem": "创建操作项",
"deleteActionItem": "删除操作项",
Expand Down Expand Up @@ -982,7 +983,8 @@
"logout": "登出",
"settings": "设置",
"chat": "聊天",
"menu": "菜单"
"menu": "菜单",
"leave": "离开"
},
"organizationSidebar": {
"viewAll": "查看全部",
Expand Down Expand Up @@ -1205,7 +1207,8 @@
"deleteCategory": "删除类别",
"deleteCategoryMsg": "您确定要删除此操作项目类别吗?",
"createButton": "创建按钮",
"editButton": "编辑按钮"
"editButton": "编辑按钮",
"categoryDetails": "类别详情"
},
"organizationVenues": {
"title": "场地",
Expand Down Expand Up @@ -1319,5 +1322,12 @@
},
"userPledges": {
"title": "我的承诺"
},
"orgLeave": {
"confirmation": "您确定要离开该组织吗?",
"heading": "离开组织?",
"description": "您确定要离开该组织吗?此操作无法撤销。如果该组织需要批准,您将无法在没有批准的情况下重新加入。任何相关的数据或权限可能也会丢失。",
"errorOccured": "发生错误。请稍后再试。",
"orgLeft": "您已离开该组织。"
}
}
8 changes: 8 additions & 0 deletions src/GraphQl/Mutations/OrganizationMutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ export const JOIN_PUBLIC_ORGANIZATION = gql`
}
`;

export const LEAVE_ORGANIZATION = gql`
mutation ($organizationId: ID!) {
leaveOrganization(organizationId: $organizationId) {
_id
}
}
`;

export const CANCEL_MEMBERSHIP_REQUEST = gql`
mutation ($membershipRequestId: ID!) {
cancelMembershipRequest(membershipRequestId: $membershipRequestId) {
Expand Down
1 change: 1 addition & 0 deletions src/GraphQl/Mutations/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ export {
CREATE_DIRECT_CHAT,
CREATE_SAMPLE_ORGANIZATION_MUTATION,
JOIN_PUBLIC_ORGANIZATION,
LEAVE_ORGANIZATION,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Missing implementation for LEAVE_ORGANIZATION mutation

The LEAVE_ORGANIZATION mutation is being exported, but its implementation is not visible in the provided code. This could lead to runtime errors when attempting to use the mutation.

Please add the implementation for the LEAVE_ORGANIZATION mutation before exporting it. The mutation should typically follow this structure:

export const LEAVE_ORGANIZATION = gql`
  mutation LeaveOrganization($orgId: ID!) {
    leaveOrganization(organizationId: $orgId) {
      _id
    }
  }
`;

Ensure that the mutation name and parameters match the backend GraphQL schema.

PLUGIN_SUBSCRIPTION,
REMOVE_CUSTOM_FIELD,
REMOVE_SAMPLE_ORGANIZATION_MUTATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@
width: 8rem;
}

.leaveBtn {
display: flex;
justify-content: space-around;
width: 8rem; /* You can adjust the width based on your needs */
margin-right: 9rem;
}

.orgName {
text-overflow: ellipsis;
white-space: nowrap;
Expand Down Expand Up @@ -139,9 +146,17 @@
margin-left: auto;
display: block;
}

.orgCard .btnContainer {
display: flex;
flex-direction: column;
gap: 0.5rem;
}

.joinBtn,
.joinedBtn,
.withdrawBtn {
.withdrawBtn,
.leaveBtn {
display: flex;
justify-content: space-around;
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,52 @@ describe('Testing OrganizationCard Component [User Portal]', () => {
await wait();
});

test('should navigate to organization page and open leave confirmation modal', async () => {
const cardProps = {
...props,
membershipRequestStatus: 'accepted', // Set status to accepted
};

render(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
<Provider store={store}>
<I18nextProvider i18n={i18nForTest}>
<OrganizationCard {...cardProps} />
</I18nextProvider>
</Provider>
</BrowserRouter>
</MockedProvider>,
);

await wait();

// Assert that "Visit" and "Leave" buttons are present
expect(screen.getByTestId('manageBtn')).toBeInTheDocument();
expect(screen.getByTestId('leaveBtn')).toBeInTheDocument();

// Click the "Visit" button and assert the navigate function is called
fireEvent.click(screen.getByTestId('manageBtn'));
expect(window.location.pathname).toBe(`/user/organization/${cardProps.id}`); // Simulate navigation

// Click the "Leave" button and assert that the modal opens
fireEvent.click(screen.getByTestId('leaveBtn'));
await wait();

// Modal should be shown
expect(screen.getByText('Leaving organization ?')).toBeInTheDocument(); // Adjust this as per your modal content

const closeButton = screen.getByText('Cancel'); // Assuming the modal has a "Close" button, adjust as per your modal content
fireEvent.click(closeButton);

await wait();

// Assert that the modal is no longer in the document
expect(
screen.queryByText('Leaving organization ?'),
).not.toBeInTheDocument();
});

test('Component should be rendered properly if organization Image is not undefined', async () => {
props = {
...props,
Expand Down
Loading
Loading