From 8519c15a5c0ccbb8eb66d5e71856f527c6888ee4 Mon Sep 17 00:00:00 2001 From: Jamari McFarlane <71823011+JamarTG@users.noreply.github.com> Date: Wed, 15 Nov 2023 17:20:03 -0500 Subject: [PATCH] Simulated Test Database (#984) * Dynamic Organization Dashboard * Dynamic Organization Dashboard * Sample Org Implementation * removed unnecessary changes * removed unnecessary svgs * removed unnecessary import * added appropriate button style * fixed OrgListCard tests * Fixed OrgList and OrgListCard Tests * Removed Unnecessary 'container' Variable * Added Missing Translations and removed unused variable --- public/locales/en.json | 20 ++++- public/locales/fr.json | 16 +++- public/locales/hi.json | 15 +++- public/locales/sp.json | 15 +++- public/locales/zh.json | 15 +++- src/GraphQl/Mutations/mutations.ts | 12 +++ src/GraphQl/Queries/Queries.ts | 6 ++ src/assets/svgs/flask.svg | 1 + src/components/DeleteOrg/DeleteOrg.tsx | 50 ++++++++---- .../OrgListCard/OrgListCard.module.css | 13 +++ .../OrgListCard/OrgListCard.test.tsx | 62 +++++++++----- src/components/OrgListCard/OrgListCard.tsx | 25 +++++- src/screens/OrgList/OrgList.module.css | 74 +++++++++++++++++ src/screens/OrgList/OrgList.test.tsx | 14 ++-- src/screens/OrgList/OrgList.tsx | 81 +++++++++++++------ 15 files changed, 344 insertions(+), 75 deletions(-) create mode 100644 src/assets/svgs/flask.svg diff --git a/public/locales/en.json b/public/locales/en.json index 6f3d16b201..fb5d78bc2f 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -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", @@ -75,6 +85,7 @@ "searchByName": "Search By Name", "organizations": "Organizations", "createOrganization": "Create Organization", + "createSampleOrganization": "Create Sample Organization", "description": "Description", "location": "Location", "isPublic": "Is Public", @@ -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", @@ -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", diff --git a/public/locales/fr.json b/public/locales/fr.json index 1386bd8d96..97116881e9 100644 --- a/public/locales/fr.json +++ b/public/locales/fr.json @@ -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", @@ -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", @@ -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" @@ -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", diff --git a/public/locales/hi.json b/public/locales/hi.json index f7091382ab..490b5b5d04 100644 --- a/public/locales/hi.json +++ b/public/locales/hi.json @@ -28,6 +28,11 @@ "login_to_admin_portal": "एडमिन पोर्टल लॉगिन", "OR": "या" }, + "latestEvents": { + "eventCardTitle": "आगामी घटनाएँ", + "eventCardSeeAll": "सभी देखें", + "noEvents": "कोई आगामी घटनाएँ नहीं" + }, "listNavbar": { "talawa_portal": "तलावा प्रशासन पोर्टल", "roles": "भूमिकाएँ", @@ -75,6 +80,7 @@ "searchByName": "नाम से खोजें", "organizations": "संगठन", "createOrganization": "संगठन बनाएं", + "createSampleOrganization": " सैंपल संगठन बनाएं", "description": "विवरण", "location": "स्थान", "isPublic": "सार्वजनिक है", @@ -86,13 +92,17 @@ "cancel": "रद्द करना", "endOfResults": "परिणामों का अंत", "noOrgErrorTitle": "संगठन नहीं मिला", + "sampleOrgDuplicate": "केवल एक नमूना संगठन को अनुमति दी गई", "noOrgErrorDescription": "कृपया डैशबोर्ड के माध्यम से एक संगठन बनाएं", - "noResultsFoundFor": "के लिए कोई परिणाम नहीं मिला " + "noResultsFoundFor": "के लिए कोई परिणाम नहीं मिला ", + "OR": "या", + "sampleOrgSuccess": "सैंपल संगठन सफलतापूर्वक बनाया गया" }, "orgListCard": { "admins": "व्यवस्थापक", "members": "सदस्य", - "manage": "प्रबंधित करना" + "manage": "प्रबंधित करना", + "sampleOrganization": "सैंपल संगठन" }, "paginationList": { "rowsPerPage": "प्रति पृष्ठ पंक्तियाँ", @@ -400,6 +410,7 @@ }, "deleteOrg": { "deleteOrganization": "संगठन हटाएं", + "deleteSampleOrganization": "सैंपल संगठन को हटाएं", "deleteMsg": "क्या आप इस संगठन को हटाना चाहते हैं?", "cancel": "रद्द करना", "confirmDelete": "हटाने की पुष्टि करें", diff --git a/public/locales/sp.json b/public/locales/sp.json index dd53814d12..33cb77ed64 100644 --- a/public/locales/sp.json +++ b/public/locales/sp.json @@ -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", @@ -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", @@ -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", @@ -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", diff --git a/public/locales/zh.json b/public/locales/zh.json index dbb937c94e..8de1d7c5d9 100644 --- a/public/locales/zh.json +++ b/public/locales/zh.json @@ -28,6 +28,11 @@ "login_to_admin_portal": " 管理员门户登录 ", "OR": "或者" }, + "latestEvents": { + "eventCardTitle": "即将举行的活动", + "eventCardSeeAll": "查看全部", + "noEvents": "暂无即将举行的活动" + }, "listNavbar": { "talawa_portal": "塔拉瓦管理門戶", "roles": "角色", @@ -75,6 +80,7 @@ "searchByName": "按名稱搜索", "organizations": "组织", "createOrganization": "創建組織", + "createSampleOrganization": "创建示范组织", "description": "描述", "location": "地點", "isPublic": "是否公開", @@ -86,13 +92,17 @@ "cancel": "取消", "endOfResults": "結果結束", "noOrgErrorTitle": "找不到组织", + "sampleOrgDuplicate": "只允许一个样本组织", "noOrgErrorDescription": "请通过仪表板创建一个组织", - "noResultsFoundFor": "未找到结果 " + "noResultsFoundFor": "未找到结果 ", + "OR": "或者", + "sampleOrgSuccess": "示例组织成功创建" }, "orgListCard": { "admins": "管理員", "members": "成員", - "manage": "管理" + "manage": "管理", + "sampleOrganization": "示例组织" }, "paginationList": { "rowsPerPage": "每頁行數", @@ -400,6 +410,7 @@ }, "deleteOrg": { "deleteOrganization": "删除组织", + "deleteSampleOrganization": "删除示范组织", "deleteMsg": "您是否要删除此组织?", "cancel": "取消", "confirmDelete": "确认删除", diff --git a/src/GraphQl/Mutations/mutations.ts b/src/GraphQl/Mutations/mutations.ts index fb303cb840..dca9e713c3 100644 --- a/src/GraphQl/Mutations/mutations.ts +++ b/src/GraphQl/Mutations/mutations.ts @@ -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( diff --git a/src/GraphQl/Queries/Queries.ts b/src/GraphQl/Queries/Queries.ts index 14b2cf4249..500dde6192 100644 --- a/src/GraphQl/Queries/Queries.ts +++ b/src/GraphQl/Queries/Queries.ts @@ -825,3 +825,9 @@ export const DIRECT_CHATS_LIST = gql` } } `; + +export const IS_SAMPLE_ORGANIZATION_QUERY = gql` + query ($isSampleOrganizationId: ID!) { + isSampleOrganization(id: $isSampleOrganizationId) + } +`; diff --git a/src/assets/svgs/flask.svg b/src/assets/svgs/flask.svg new file mode 100644 index 0000000000..599220a9d2 --- /dev/null +++ b/src/assets/svgs/flask.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/DeleteOrg/DeleteOrg.tsx b/src/components/DeleteOrg/DeleteOrg.tsx index 91fe4263f4..b7ceafbd5c 100644 --- a/src/components/DeleteOrg/DeleteOrg.tsx +++ b/src/components/DeleteOrg/DeleteOrg.tsx @@ -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 { @@ -14,22 +17,39 @@ function deleteOrg(): JSX.Element { 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 => { - 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'); + }) + .catch((error) => { + toast.error(error.message); + }); + window.location.replace('/orglist'); + } else { + try { + await del({ + variables: { + id: currentUrl, + }, + }); window.location.replace('/orglist'); + } catch (error: any) { + errorHandler(t, error); } - } catch (error: any) { - /* istanbul ignore next */ - errorHandler(t, error); } }; @@ -48,7 +68,9 @@ function deleteOrg(): JSX.Element { onClick={toggleDeleteModal} data-testid="openDeleteModalBtn" > - {t('deleteOrganization')} + {data && data.isSampleOrganization + ? t('deleteSampleOrganization') + : t('deleteOrganization')} diff --git a/src/components/OrgListCard/OrgListCard.module.css b/src/components/OrgListCard/OrgListCard.module.css index 90be5a088f..1f1e5e2974 100644 --- a/src/components/OrgListCard/OrgListCard.module.css +++ b/src/components/OrgListCard/OrgListCard.module.css @@ -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; +} diff --git a/src/components/OrgListCard/OrgListCard.test.tsx b/src/components/OrgListCard/OrgListCard.test.tsx index b7ba9db776..ffcf92981f 100644 --- a/src/components/OrgListCard/OrgListCard.test.tsx +++ b/src/components/OrgListCard/OrgListCard.test.tsx @@ -8,6 +8,24 @@ import type { InterfaceOrgListCardProps } from './OrgListCard'; import OrgListCard from './OrgListCard'; import userEvent from '@testing-library/user-event'; import { BrowserRouter } from 'react-router-dom'; +import { IS_SAMPLE_ORGANIZATION_QUERY } from 'GraphQl/Queries/Queries'; +import { StaticMockLink } from 'utils/StaticMockLink'; +import { MockedProvider } from '@apollo/react-testing'; + +const MOCKS = [ + { + request: { + query: IS_SAMPLE_ORGANIZATION_QUERY, + }, + result: { + data: { + isSampleOrganization: true, + }, + }, + }, +]; + +const link = new StaticMockLink(MOCKS, true); const props: InterfaceOrgListCardProps = { data: { @@ -38,11 +56,13 @@ describe('Testing the Super Dash List', () => { localStorage.setItem('id', '123'); // Means the user is an admin render( - - - - - + + + + + + + ); expect(screen.getByAltText(/Dogs Care image/i)).toBeInTheDocument(); expect(screen.getByText('Admins:')).toBeInTheDocument(); @@ -56,11 +76,13 @@ describe('Testing the Super Dash List', () => { window.location.assign('/orgdash'); render( - - - - - + + + + + + + ); expect(window.location).toBeAt('/orgdash'); @@ -72,20 +94,24 @@ describe('Testing the Super Dash List', () => { ...{ data: { ...props.data, ...{ image: null } } }, }; render( - - - + + + + + ); expect(screen.getByTestId(/emptyContainerForImage/i)).toBeInTheDocument(); }); test('Testing if user is redirected to orgDash screen', () => { render( - - - - - + + + + + + + ); userEvent.click(screen.getByTestId('manageBtn')); expect(window.location).toBeAt('/orgdash/id=xyz'); diff --git a/src/components/OrgListCard/OrgListCard.tsx b/src/components/OrgListCard/OrgListCard.tsx index 5568c78d30..191a689bc0 100644 --- a/src/components/OrgListCard/OrgListCard.tsx +++ b/src/components/OrgListCard/OrgListCard.tsx @@ -1,10 +1,13 @@ import React from 'react'; +import { ReactComponent as FlaskIcon } from 'assets/svgs/flask.svg'; import Button from 'react-bootstrap/Button'; import { useTranslation } from 'react-i18next'; import styles from './OrgListCard.module.css'; import { useHistory } from 'react-router-dom'; import type { InterfaceOrgConnectionInfoType } from 'utils/interfaces'; import LocationOnIcon from '@mui/icons-material/LocationOn'; +import { IS_SAMPLE_ORGANIZATION_QUERY } from 'GraphQl/Queries/Queries'; +import { useQuery } from '@apollo/client'; export interface InterfaceOrgListCardProps { data: InterfaceOrgConnectionInfoType; @@ -13,6 +16,12 @@ export interface InterfaceOrgListCardProps { function orgListCard(props: InterfaceOrgListCardProps): JSX.Element { const { _id, admins, image, location, members, name } = props.data; + const { data } = useQuery(IS_SAMPLE_ORGANIZATION_QUERY, { + variables: { + isSampleOrganizationId: _id, + }, + }); + const history = useHistory(); function handleClick(): void { @@ -46,7 +55,6 @@ function orgListCard(props: InterfaceOrgListCardProps): JSX.Element { )}
-
{name}
{location} @@ -57,9 +65,22 @@ function orgListCard(props: InterfaceOrgListCardProps): JSX.Element {
{t('members')}: {members.length}
+
{name}
- diff --git a/src/screens/OrgList/OrgList.module.css b/src/screens/OrgList/OrgList.module.css index a8822e226c..e1f1729d18 100644 --- a/src/screens/OrgList/OrgList.module.css +++ b/src/screens/OrgList/OrgList.module.css @@ -7,6 +7,80 @@ display: flex; } +.orgCreationBtn { + width: 100%; + border: None; +} + +.line::before { + content: ''; + display: inline-block; + width: 100px; + border-top: 1px solid #000; + margin: 0 10px; +} + +.line::before { + left: 0; +} + +.line::after { + right: 0; +} + +.flexContainer { + display: flex; + justify-content: center; + align-items: center; + width: 100%; +} + +.orText { + display: block; + position: absolute; + top: calc(-0.7rem + 0.5rem); + left: calc(50% - 2.6rem); + margin: 0 auto; + padding: 0.5rem 2rem; + z-index: 100; + background: var(--bs-white); + color: var(--bs-secondary); +} +.sampleOrgSection { + display: grid; + grid-template-columns: repeat(1, 1fr); + row-gap: 1em; +} + +.sampleOrgCreationBtn { + width: 100%; + background-color: transparent; + color: #707070; + border-color: #707070; + display: flex; + justify-content: center; + align-items: center; +} + +.sampleHover:hover { + border-color: grey; + color: grey; +} + +.sampleOrgSection { + font-family: Arial, Helvetica, sans-serif; + width: 100%; + display: grid; + grid-auto-columns: repeat(1, 1fr); + justify-content: center; + flex-direction: column; + align-items: center; +} + +.sampleModalTitle { + background-color: green; +} + .btnsContainer .btnsBlock button { margin-left: 1rem; display: flex; diff --git a/src/screens/OrgList/OrgList.test.tsx b/src/screens/OrgList/OrgList.test.tsx index 118ac52198..ca2e89ad98 100644 --- a/src/screens/OrgList/OrgList.test.tsx +++ b/src/screens/OrgList/OrgList.test.tsx @@ -26,6 +26,8 @@ afterEach(() => { }); describe('Organisations Page testing as SuperAdmin', () => { + localStorage.setItem('id', '123'); + const link = new StaticMockLink(MOCKS, true); const link2 = new StaticMockLink(MOCKS_EMPTY, true); @@ -61,7 +63,7 @@ describe('Organisations Page testing as SuperAdmin', () => { window.location.assign('/'); localStorage.setItem('id', '123'); - const { container } = render( + render( @@ -74,10 +76,10 @@ describe('Organisations Page testing as SuperAdmin', () => { ); await wait(); - expect(container.textContent).toMatch('Organizations Not Found'); - expect(container.textContent).toMatch( - 'Please create an organization through dashboard' - ); + expect(screen.queryByText('Organizations Not Found')).toBeInTheDocument(); + expect( + screen.queryByText('Please create an organization through dashboard') + ).toBeInTheDocument(); expect(window.location).toBeAt('/'); }); @@ -114,7 +116,7 @@ describe('Organisations Page testing as SuperAdmin', () => { const createOrgBtn = screen.getByTestId(/createOrganizationBtn/i); expect(createOrgBtn).toBeInTheDocument(); userEvent.click(createOrgBtn); - userEvent.click(screen.getByTestId(/closeOrganizationModal/i)); + userEvent.click(screen.getByTestId(/closeModalBtn/i)); }); test('Create organization model should work properly', async () => { diff --git a/src/screens/OrgList/OrgList.tsx b/src/screens/OrgList/OrgList.tsx index d2229b2339..7e0f71ffb9 100644 --- a/src/screens/OrgList/OrgList.tsx +++ b/src/screens/OrgList/OrgList.tsx @@ -7,6 +7,9 @@ import { ORGANIZATION_CONNECTION_LIST, USER_ORGANIZATION_LIST, } from 'GraphQl/Queries/Queries'; + +import { CREATE_SAMPLE_ORGANIZATION_MUTATION } from 'GraphQl/Mutations/mutations'; + import OrgListCard from 'components/OrgListCard/OrgListCard'; import SuperAdminScreen from 'components/SuperAdminScreen/SuperAdminScreen'; import type { ChangeEvent } from 'react'; @@ -31,8 +34,6 @@ import styles from './OrgList.module.css'; function orgList(): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'orgList' }); const [dialogModalisOpen, setdialogModalIsOpen] = useState(false); - /* eslint-disable @typescript-eslint/no-unused-vars */ - const [modalisOpen, setmodalIsOpen] = useState(false); const [dialogRedirectOrgId, setDialogRedirectOrgId] = useState(''); /* eslint-disable @typescript-eslint/explicit-function-return-type */ function openDialogModal(redirectOrgId: string) { @@ -68,6 +69,10 @@ function orgList(): JSX.Element { const [create] = useMutation(CREATE_ORGANIZATION_MUTATION); + const [createSampleOrganization] = useMutation( + CREATE_SAMPLE_ORGANIZATION_MUTATION + ); + const { data: userData, error: errorUser, @@ -116,11 +121,7 @@ function orgList(): JSX.Element { }, []); useEffect(() => { - if (loading && isLoadingMore == false) { - setIsLoading(true); - } else { - setIsLoading(false); - } + setIsLoading(loading && isLoadingMore); }, [loading]); /* istanbul ignore next */ @@ -141,6 +142,17 @@ function orgList(): JSX.Element { } }; + const triggerCreateSampleOrg = () => { + createSampleOrganization() + .then(() => { + toast.success(t('sampleOrgSuccess')); + window.location.reload(); + }) + .catch(() => { + toast.error(t('sampleOrgDuplicate')); + }); + }; + const createOrg = async (e: ChangeEvent): Promise => { e.preventDefault(); @@ -397,7 +409,7 @@ function orgList(): JSX.Element { ))} ) : userData && userData.user.userType == 'SUPERADMIN' ? ( - orgsData?.organizationsConnection.map((item, index) => { + orgsData?.organizationsConnection.map((item) => { return (
@@ -425,7 +437,6 @@ function orgList(): JSX.Element { @@ -544,23 +555,36 @@ function orgList(): JSX.Element { }} data-testid="organisationImage" /> + + + +
+
+ {t('OR')} +
+ {userData && + ((userData.user.userType === 'ADMIN' && + userData.user.adminFor.length > 0) || + userData.user.userType === 'SUPERADMIN') && ( +
+ +
+ )} + - - - -
{' '} {/* Plugin Notification Modal after Org is Created */} @@ -582,6 +606,13 @@ function orgList(): JSX.Element { }} > +

{t('manageFeaturesInfo')}