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

fixed super admin profile #2340

Closed
Closed
56 changes: 56 additions & 0 deletions src/GraphQl/Queries/Queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,62 @@ export const EVENT_FEEDBACKS = gql`
}
`;

// Query to take the Organization with data
export const ORGANIZATIONS_LIST_BY_CREATOR_ID = gql`
query OrganizationsByCreator($creatorId: ID!) {
organizations(where: { creatorId: $creatorId }) {
_id
image
creator {
firstName
lastName
email
}
name
description
address {
city
countryCode
dependentLocality
line1
line2
postalCode
sortingCode
state
}
userRegistrationRequired
visibleInSearch
members {
_id
firstName
lastName
email
}
admins {
_id
firstName
lastName
email
createdAt
}
membershipRequests {
_id
user {
firstName
lastName
email
}
}
blockedUsers {
_id
firstName
lastName
email
}
ARYANSHAH1567 marked this conversation as resolved.
Show resolved Hide resolved
ARYANSHAH1567 marked this conversation as resolved.
Show resolved Hide resolved
}
}
`;
ARYANSHAH1567 marked this conversation as resolved.
Show resolved Hide resolved

// Query to take the Organization with data
export const ORGANIZATIONS_LIST = gql`
query Organizations($id: ID!) {
Expand Down
158 changes: 71 additions & 87 deletions src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,53 @@ import LeftDrawerOrg from './LeftDrawerOrg';
import { Provider } from 'react-redux';
import { MockedProvider } from '@apollo/react-testing';
import { store } from 'state/store';
import { ORGANIZATIONS_LIST } from 'GraphQl/Queries/Queries';
import { ORGANIZATIONS_LIST_BY_CREATOR_ID } from 'GraphQl/Queries/Queries';
import { StaticMockLink } from 'utils/StaticMockLink';
import { REVOKE_REFRESH_TOKEN } from 'GraphQl/Mutations/mutations';
import useLocalStorage from 'utils/useLocalstorage';

const { setItem } = useLocalStorage();

const props: InterfaceLeftDrawerProps = {
orgId: '123',
orgId: '64378abd85008f171cf2990d',
targets: [
{
name: 'Dashboard',
url: '/orgdash/123',
url: '/orgdash/6437904485008f171cf29924',
},
{
name: 'People',
url: '/orgpeople/123',
url: '/orgpeople/6437904485008f171cf29924',
},
{
name: 'Events',
url: '/orgevents/123',
url: '/orgevents/6437904485008f171cf29924',
},
{
name: 'Posts',
url: '/orgpost/123',
url: '/orgpost/6437904485008f171cf29924',
},
{
name: 'Block/Unblock',
url: '/blockuser/123',
url: '/blockuser/6437904485008f171cf29924',
},
{
name: 'Plugins',
subTargets: [
{
name: 'Plugin Store',
url: '/orgstore/123',
url: '/orgstore/6437904485008f171cf29924',
icon: 'fa-store',
},
],
},
{
name: 'Settings',
url: '/orgsetting/123',
url: '/orgsetting/6437904485008f171cf29924',
},
{
name: 'All Organizations',
url: '/orglist/123',
url: '/orglist/6437904485008f171cf29924',
},
],
hideDrawer: false,
Expand All @@ -77,59 +77,49 @@ const MOCKS = [
},
{
request: {
query: ORGANIZATIONS_LIST,
variables: { id: '123' },
query: ORGANIZATIONS_LIST_BY_CREATOR_ID,
variables: { id: '64378abd85008f171cf2990d' },
},
result: {
data: {
organizations: [
{
_id: '123',
_id: '6437904485008f171cf29924',
image: null,
creator: {
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
},
name: 'Test Organization',
description: 'Testing this organization',
name: 'Unity Foundation',
description:
'A foundation aimed at uniting the world and making it a better place for all.',
address: {
city: 'Delhi',
countryCode: 'IN',
city: 'Bronx',
countryCode: 'US',
dependentLocality: 'Some Dependent Locality',
line1: '123 Random Street',
line2: 'Apartment 456',
postalCode: '110001',
postalCode: '10451',
sortingCode: 'ABC-123',
state: 'Delhi',
state: 'NYC',
},
userRegistrationRequired: true,
userRegistrationRequired: false,
visibleInSearch: true,
members: [
{
_id: 'john123',
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
},
{
_id: 'jane123',
firstName: 'Jane',
lastName: 'Doe',
email: '[email protected]',
},
],
admins: [
{
_id: 'john123',
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
createdAt: '12-03-2024',
},
'64378abd85008f171cf2990d',
'658930fd2caa9d8d6908745c',
'6589386a2caa9d8d69087484',
'6589387e2caa9d8d69087485',
'6589388b2caa9d8d69087486',
'6589389d2caa9d8d69087487',
'658938a62caa9d8d69087488',
'658938b02caa9d8d69087489',
'658938ba2caa9d8d6908748a',
],
admins: ['64378abd85008f171cf2990d'],
groupChats: [],
posts: [],
pinnedPosts: [],
membershipRequests: [],
blockedUsers: [],
creatorId: '64378abd85008f171cf2990d',
createdAt: '2023-04-13T05:16:52.827Z',
},
],
},
Expand All @@ -140,60 +130,50 @@ const MOCKS = [
const MOCKS_WITH_IMAGE = [
{
request: {
query: ORGANIZATIONS_LIST,
variables: { id: '123' },
query: ORGANIZATIONS_LIST_BY_CREATOR_ID,
variables: { id: '64378abd85008f171cf2990d' },
},
result: {
data: {
organizations: [
{
_id: '123',
_id: '6437904485008f171cf29924',
image:
'https://api.dicebear.com/5.x/initials/svg?seed=Test%20Organization',
creator: {
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
},
name: 'Test Organization',
description: 'Testing this organization',
'https://api.dicebear.com/5.x/initials/svg?seed=Unity%20Foundation', // Unity Foundation image
name: 'Unity Foundation',
description:
'A foundation aimed at uniting the world and making it a better place for all.',
address: {
city: 'Delhi',
countryCode: 'IN',
city: 'Bronx',
countryCode: 'US',
dependentLocality: 'Some Dependent Locality',
line1: '123 Random Street',
line2: 'Apartment 456',
postalCode: '110001',
postalCode: '10451',
sortingCode: 'ABC-123',
state: 'Delhi',
state: 'NYC',
},
userRegistrationRequired: true,
userRegistrationRequired: false,
visibleInSearch: true,
members: [
{
_id: 'john123',
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
},
{
_id: 'jane123',
firstName: 'Jane',
lastName: 'Doe',
email: '[email protected]',
},
],
admins: [
{
_id: 'john123',
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
createdAt: '12-03-2024',
},
'64378abd85008f171cf2990d',
'658930fd2caa9d8d6908745c',
'6589386a2caa9d8d69087484',
'6589387e2caa9d8d69087485',
'6589388b2caa9d8d69087486',
'6589389d2caa9d8d69087487',
'658938a62caa9d8d69087488',
'658938b02caa9d8d69087489',
'658938ba2caa9d8d6908748a',
],
admins: ['64378abd85008f171cf2990d'],
groupChats: [],
posts: [],
pinnedPosts: [],
membershipRequests: [],
blockedUsers: [],
creatorId: '64378abd85008f171cf2990d',
createdAt: '2023-04-13T05:16:52.827Z',
},
],
},
Expand All @@ -204,8 +184,8 @@ const MOCKS_WITH_IMAGE = [
const MOCKS_EMPTY = [
{
request: {
query: ORGANIZATIONS_LIST,
variables: { id: '123' },
query: ORGANIZATIONS_LIST_BY_CREATOR_ID,
variables: { id: '64378abd85008f171cf2990d' },
},
result: {
data: {
Expand Down Expand Up @@ -326,7 +306,9 @@ describe('Testing LeftDrawerOrg component for SUPERADMIN', () => {
);
await wait();
userEvent.click(screen.getByText('Dashboard'));
expect(global.window.location.pathname).toContain('/orgdash/123');
expect(global.window.location.pathname).toContain(
'/orgdash/6437904485008f171cf29924',
);
});

test('Testing when screen size is less than 820px', async () => {
Expand All @@ -350,7 +332,9 @@ describe('Testing LeftDrawerOrg component for SUPERADMIN', () => {
const peopelBtn = screen.getByTestId(/People/i);
userEvent.click(peopelBtn);
await wait();
expect(window.location.pathname).toContain('/orgpeople/123');
expect(window.location.pathname).toContain(
'/orgpeople/6437904485008f171cf29924',
);
});

test('Testing when image is present for Organization', async () => {
Expand Down
8 changes: 4 additions & 4 deletions src/components/LeftDrawerOrg/LeftDrawerOrg.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useQuery } from '@apollo/client';
import { WarningAmberOutlined } from '@mui/icons-material';
import { ORGANIZATIONS_LIST } from 'GraphQl/Queries/Queries';
import { ORGANIZATIONS_LIST_BY_CREATOR_ID } from 'GraphQl/Queries/Queries';
import CollapsibleDropdown from 'components/CollapsibleDropdown/CollapsibleDropdown';
import IconComponent from 'components/IconComponent/IconComponent';
import React, { useEffect, useState } from 'react';
Expand Down Expand Up @@ -50,8 +50,8 @@ const leftDrawerOrg = ({
| { organizations: InterfaceQueryOrganizationsListObject[] }
| undefined;
loading: boolean;
} = useQuery(ORGANIZATIONS_LIST, {
variables: { id: orgId },
} = useQuery(ORGANIZATIONS_LIST_BY_CREATOR_ID, {
variables: { creatorId: orgId },
});

// Set organization data when query data is available
Expand Down Expand Up @@ -116,7 +116,7 @@ const leftDrawerOrg = ({
</button>
</>
) : (
<button className={styles.profileContainer} data-testid="OrgBtn">
<button className={styles.profileContainer} data-testid="orgBtn">
<div className={styles.imageContainer}>
{organization.image ? (
<img src={organization.image} alt={`profile picture`} />
Expand Down
Loading