Skip to content
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

Simulated Test Database #984

Merged
merged 17 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 18 additions & 2 deletions public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
"login_to_admin_portal": "Admin Portal Login",
"OR": "OR"
},
"latestEvents": {
"eventCardTitle": "Upcoming Events",
"eventCardSeeAll": "See All",
"noEvents": "No Upcoming Events"
},
"latestPosts": {
"latestPostsTitle": "Latest Posts",
"seeAllLink": "See All",
"noPostsCreated": "No Posts Created"
},
"listNavbar": {
"talawa_portal": "Talawa Admin Portal",
"roles": "Roles",
Expand Down Expand Up @@ -75,6 +85,7 @@
"searchByName": "Search By Name",
"organizations": "Organizations",
"createOrganization": "Create Organization",
"createSampleOrganization": "Create Sample Organization",
"description": "Description",
"location": "Location",
"isPublic": "Is Public",
Expand All @@ -85,18 +96,22 @@
"filter": "Filter",
"cancel": "Cancel",
"noOrgErrorTitle": "Organizations Not Found",
"sampleOrgDuplicate": "Only one sample organization allowed",
"noOrgErrorDescription": "Please create an organization through dashboard",
"endOfResults": "End of results",
"manageFeatures": "Manage Features",
"manageFeaturesInfo": "Creation Successful ! Please select features that you want to enale for this organization from the plugin store.",
"goToStore": "Go to Plugin Store",
"enableEverything": "Enable Everything",
"noResultsFoundFor": "No results found for "
"noResultsFoundFor": "No results found for",
"OR": "OR",
"sampleOrgSuccess": "Sample Organization Successfully Created"
},
"orgListCard": {
"admins": "Admins",
"members": "Members",
"manage": "Manage"
"manage": "Manage",
"sampleOrganization": "Sample Organization"
},
"paginationList": {
"rowsPerPage": "rows per page",
Expand Down Expand Up @@ -404,6 +419,7 @@
},
"deleteOrg": {
"deleteOrganization": "Delete Organization",
"deleteSampleOrganization": "Delete Sample Organization",
"deleteMsg": "Do you want to delete this organization?",
"cancel": "Cancel",
"confirmDelete": "Confirm Delete",
Expand Down
16 changes: 14 additions & 2 deletions public/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"login_to_admin_portal": "Connexion à l'administration du portail",
"OR": "OU"
},
"latestEvents": {
"eventCardTitle": "Événements à venir",
"eventCardSeeAll": "Voir Tout",
"noEvents": "Aucun événement à venir"
},
"listNavbar": {
"talawa_portal": "Portail D'Administrateur Talawa",
"roles": "Les rôles",
Expand Down Expand Up @@ -75,6 +80,7 @@
"searchByName": "Rechercher par nom",
"organizations": "Organisations",
"createOrganization": "Créer une organisation",
"createSampleOrganization": "Créer une organisation d'exemple",
"description": "La description",
"location": "Emplacement",
"isPublic": "Est publique",
Expand All @@ -86,14 +92,19 @@
"cancel": "Annuler",
"endOfResults": "Fin des résultats",
"noOrgErrorTitle": "Organisations non trouvées",
"sampleOrgDuplicate": "Seule une organisation d'exemple est autorisée.",
"noOrgErrorDescription": "Veuillez créer une organisation via le tableau de bord",
"noResultsFoundFor": "Aucun résultat trouvé pour "
"noResultsFoundFor": "Aucun résultat trouvé pour ",
"OR": "OU",
"sampleOrgSuccess": "Organisation d'exemple créée avec succès"
},
"orgListCard": {
"admins": "Administrateurs",
"members": "Membres",
"manage": "Faire en sorte"
"manage": "Faire en sorte",
"sampleOrganization": "Organisation d'exemple"
},

"paginationList": {
"rowsPerPage": "lignes par page",
"all": "Tout"
Expand Down Expand Up @@ -400,6 +411,7 @@
},
"deleteOrg": {
"deleteOrganization": "Supprimer l'organisation",
"deleteSampleOrganization": "Supprimer l'organisation d'exemple",
"deleteMsg": "Voulez-vous supprimer cette organisation ?",
"cancel": "Annuler",
"confirmDelete": "Confirmer la suppression",
Expand Down
15 changes: 13 additions & 2 deletions public/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"login_to_admin_portal": "एडमिन पोर्टल लॉगिन",
"OR": "या"
},
"latestEvents": {
"eventCardTitle": "आगामी घटनाएँ",
"eventCardSeeAll": "सभी देखें",
"noEvents": "कोई आगामी घटनाएँ नहीं"
},
"listNavbar": {
"talawa_portal": "तलावा प्रशासन पोर्टल",
"roles": "भूमिकाएँ",
Expand Down Expand Up @@ -75,6 +80,7 @@
"searchByName": "नाम से खोजें",
"organizations": "संगठन",
"createOrganization": "संगठन बनाएं",
"createSampleOrganization": " सैंपल संगठन बनाएं",
"description": "विवरण",
"location": "स्थान",
"isPublic": "सार्वजनिक है",
Expand All @@ -86,13 +92,17 @@
"cancel": "रद्द करना",
"endOfResults": "परिणामों का अंत",
"noOrgErrorTitle": "संगठन नहीं मिला",
"sampleOrgDuplicate": "केवल एक नमूना संगठन को अनुमति दी गई",
"noOrgErrorDescription": "कृपया डैशबोर्ड के माध्यम से एक संगठन बनाएं",
"noResultsFoundFor": "के लिए कोई परिणाम नहीं मिला "
"noResultsFoundFor": "के लिए कोई परिणाम नहीं मिला ",
"OR": "या",
"sampleOrgSuccess": "सैंपल संगठन सफलतापूर्वक बनाया गया"
},
"orgListCard": {
"admins": "व्यवस्थापक",
"members": "सदस्य",
"manage": "प्रबंधित करना"
"manage": "प्रबंधित करना",
"sampleOrganization": "सैंपल संगठन"
},
"paginationList": {
"rowsPerPage": "प्रति पृष्ठ पंक्तियाँ",
Expand Down Expand Up @@ -400,6 +410,7 @@
},
"deleteOrg": {
"deleteOrganization": "संगठन हटाएं",
"deleteSampleOrganization": "सैंपल संगठन को हटाएं",
"deleteMsg": "क्या आप इस संगठन को हटाना चाहते हैं?",
"cancel": "रद्द करना",
"confirmDelete": "हटाने की पुष्टि करें",
Expand Down
15 changes: 13 additions & 2 deletions public/locales/sp.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"login_to_admin_portal": "Inicio de sesión en el portal de administración",
"OR": "O"
},
"latestEvents": {
"eventCardTitle": "Próximos Eventos",
"eventCardSeeAll": "Ver Todos",
"noEvents": "No Hay Eventos Próximos"
},
"listNavbar": {
"talawa_portal": "Portal De Administración Talawa",
"roles": "Roles",
Expand Down Expand Up @@ -75,6 +80,7 @@
"searchByName": "Buscar por nombre",
"organizations": "Organizaciones",
"createOrganization": "Crear organización",
"createSampleOrganization": "Crear organización de muestra",
"description": "Descripción",
"location": "Ubicación",
"isPublic": "Es público",
Expand All @@ -86,13 +92,17 @@
"cancel": "Cancelar",
"endOfResults": "Fin de los resultados",
"noOrgErrorTitle": "Organizaciones no encontradas",
"sampleOrgDuplicate": "Solo se permite una organización de muestra",
"noOrgErrorDescription": "Por favor, crea una organización a través del panel de control",
"noResultsFoundFor": "No se encontraron resultados para "
"noResultsFoundFor": "No se encontraron resultados para ",
"OR": "O",
"sampleOrgSuccess": "Organización de ejemplo creada exitosamente"
},
"orgListCard": {
"admins": "Administradores",
"members": "Miembros",
"manage": "Administrar"
"manage": "Administrar",
"sampleOrganization": "Organización de muestra"
},
"paginationList": {
"rowsPerPage": "filas por página",
Expand Down Expand Up @@ -400,6 +410,7 @@
},
"deleteOrg": {
"deleteOrganization": "Eliminar organización",
"deleteSampleOrganization": "Eliminar organización de muestra",
"deleteMsg": "¿Desea eliminar esta organización?",
"cancel": "Cancelar",
"confirmDelete": "Confirmar eliminación",
Expand Down
15 changes: 13 additions & 2 deletions public/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"login_to_admin_portal": " 管理员门户登录 ",
"OR": "或者"
},
"latestEvents": {
"eventCardTitle": "即将举行的活动",
"eventCardSeeAll": "查看全部",
"noEvents": "暂无即将举行的活动"
},
"listNavbar": {
"talawa_portal": "塔拉瓦管理門戶",
"roles": "角色",
Expand Down Expand Up @@ -75,6 +80,7 @@
"searchByName": "按名稱搜索",
"organizations": "组织",
"createOrganization": "創建組織",
"createSampleOrganization": "创建示范组织",
"description": "描述",
"location": "地點",
"isPublic": "是否公開",
Expand All @@ -86,13 +92,17 @@
"cancel": "取消",
"endOfResults": "結果結束",
"noOrgErrorTitle": "找不到组织",
"sampleOrgDuplicate": "只允许一个样本组织",
"noOrgErrorDescription": "请通过仪表板创建一个组织",
"noResultsFoundFor": "未找到结果 "
"noResultsFoundFor": "未找到结果 ",
"OR": "或者",
"sampleOrgSuccess": "示例组织成功创建"
},
"orgListCard": {
"admins": "管理員",
"members": "成員",
"manage": "管理"
"manage": "管理",
"sampleOrganization": "示例组织"
},
"paginationList": {
"rowsPerPage": "每頁行數",
Expand Down Expand Up @@ -400,6 +410,7 @@
},
"deleteOrg": {
"deleteOrganization": "删除组织",
"deleteSampleOrganization": "删除示范组织",
"deleteMsg": "您是否要删除此组织?",
"cancel": "取消",
"confirmDelete": "确认删除",
Expand Down
12 changes: 12 additions & 0 deletions src/GraphQl/Mutations/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,18 @@ export const UPDATE_USER_ROLE_IN_ORG_MUTATION = gql`
}
`;

export const CREATE_SAMPLE_ORGANIZATION_MUTATION = gql`
mutation {
createSampleOrganization
}
`;

export const REMOVE_SAMPLE_ORGANIZATION_MUTATION = gql`
mutation {
removeSampleOrganization
}
`;

export const CREATE_DIRECT_CHAT = gql`
mutation createDirectChat($userIds: [ID!]!, $organizationId: ID!) {
createDirectChat(
Expand Down
6 changes: 6 additions & 0 deletions src/GraphQl/Queries/Queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -825,3 +825,9 @@ export const DIRECT_CHATS_LIST = gql`
}
}
`;

export const IS_SAMPLE_ORGANIZATION_QUERY = gql`
query ($isSampleOrganizationId: ID!) {
isSampleOrganization(id: $isSampleOrganizationId)
}
`;
1 change: 1 addition & 0 deletions src/assets/svgs/flask.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 36 additions & 14 deletions src/components/DeleteOrg/DeleteOrg.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { useMutation } from '@apollo/client';
import { DELETE_ORGANIZATION_MUTATION } from 'GraphQl/Mutations/mutations';
import React, { useState } from 'react';
import { Button, Card, Modal } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import { useMutation, useQuery } from '@apollo/client';
import { errorHandler } from 'utils/errorHandler';
import { toast } from 'react-toastify';
import { DELETE_ORGANIZATION_MUTATION } from 'GraphQl/Mutations/mutations';
import { REMOVE_SAMPLE_ORGANIZATION_MUTATION } from 'GraphQl/Mutations/mutations';
import { IS_SAMPLE_ORGANIZATION_QUERY } from 'GraphQl/Queries/Queries';
import styles from './DeleteOrg.module.css';

function deleteOrg(): JSX.Element {
Expand All @@ -14,22 +17,39 @@
const currentUrl = window.location.href.split('=')[1];
const canDelete = localStorage.getItem('UserType') === 'SUPERADMIN';
const toggleDeleteModal = (): void => setShowDeleteModal(!showDeleteModal);

const [del] = useMutation(DELETE_ORGANIZATION_MUTATION);
const [removeSampleOrganization] = useMutation(
REMOVE_SAMPLE_ORGANIZATION_MUTATION
);

const { data } = useQuery(IS_SAMPLE_ORGANIZATION_QUERY, {
variables: {
isSampleOrganizationId: currentUrl,
},
});

const deleteOrg = async (): Promise<void> => {
try {
const { data } = await del({
variables: {
id: currentUrl,
},
});
/* istanbul ignore next */
if (data) {
if (data && data.isSampleOrganization) {
removeSampleOrganization()
.then(() => {
toast.success('Successfully deleted sample Organization');

Check warning on line 36 in src/components/DeleteOrg/DeleteOrg.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DeleteOrg/DeleteOrg.tsx#L34-L36

Added lines #L34 - L36 were not covered by tests
})
.catch((error) => {
toast.error(error.message);

Check warning on line 39 in src/components/DeleteOrg/DeleteOrg.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DeleteOrg/DeleteOrg.tsx#L38-L39

Added lines #L38 - L39 were not covered by tests
});
window.location.replace('/orglist');

Check warning on line 41 in src/components/DeleteOrg/DeleteOrg.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DeleteOrg/DeleteOrg.tsx#L41

Added line #L41 was not covered by tests
} else {
try {
await del({
variables: {
id: currentUrl,
},
});
window.location.replace('/orglist');
} catch (error: any) {
errorHandler(t, error);

Check warning on line 51 in src/components/DeleteOrg/DeleteOrg.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DeleteOrg/DeleteOrg.tsx#L51

Added line #L51 was not covered by tests
}
} catch (error: any) {
/* istanbul ignore next */
errorHandler(t, error);
}
};

Expand All @@ -48,7 +68,9 @@
onClick={toggleDeleteModal}
data-testid="openDeleteModalBtn"
>
{t('deleteOrganization')}
{data && data.isSampleOrganization
? t('deleteSampleOrganization')

Check warning on line 72 in src/components/DeleteOrg/DeleteOrg.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DeleteOrg/DeleteOrg.tsx#L72

Added line #L72 was not covered by tests
: t('deleteOrganization')}
</Button>
</Card.Body>
</Card>
Expand Down
13 changes: 13 additions & 0 deletions src/components/OrgListCard/OrgListCard.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,16 @@
display: block;
}
}

.flaskIcon {
position: absolute;
top: 0;
right: 0;
margin: 10px 20px 0px 0px;
}

.manageBtn {
display: flex;
justify-content: space-around;
width: 150px;
}
Loading
Loading