diff --git a/src/GraphQl/Mutations/mutations.ts b/src/GraphQl/Mutations/mutations.ts
index 68b5d7c23b..e5ae86cd12 100644
--- a/src/GraphQl/Mutations/mutations.ts
+++ b/src/GraphQl/Mutations/mutations.ts
@@ -94,7 +94,6 @@ export const UPDATE_USER_MUTATION = gql`
$empStatus: EmploymentStatus
$maritalStatus: MaritalStatus
$address: String
- $city: String
$state: String
$country: String
$image: String
@@ -110,12 +109,7 @@ export const UPDATE_USER_MUTATION = gql`
educationGrade: $grade
employmentStatus: $empStatus
maritalStatus: $maritalStatus
- address: {
- line1: $address
- state: $state
- countryCode: $country
- city: $city
- }
+ address: { line1: $address, state: $state, countryCode: $country }
}
file: $image
) {
@@ -139,7 +133,9 @@ export const UPDATE_USER_PASSWORD_MUTATION = gql`
confirmNewPassword: $confirmNewPassword
}
) {
- _id
+ user {
+ _id
+ }
}
}
`;
@@ -253,7 +249,9 @@ export const CREATE_ORGANIZATION_MUTATION = gql`
export const DELETE_ORGANIZATION_MUTATION = gql`
mutation RemoveOrganization($id: ID!) {
removeOrganization(id: $id) {
- _id
+ user {
+ _id
+ }
}
}
`;
@@ -276,8 +274,8 @@ export const CREATE_EVENT_MUTATION = gql`
$location: String
$frequency: Frequency
$weekDays: [WeekDays]
- $interval: PositiveInt
$count: PositiveInt
+ $interval: PositiveInt
$weekDayOccurenceInMonth: Int
) {
createEvent(
diff --git a/src/GraphQl/Queries/PlugInQueries.ts b/src/GraphQl/Queries/PlugInQueries.ts
index 95ce00c664..ff908ac57f 100644
--- a/src/GraphQl/Queries/PlugInQueries.ts
+++ b/src/GraphQl/Queries/PlugInQueries.ts
@@ -27,15 +27,19 @@ export const PLUGIN_GET = gql`
export const ADVERTISEMENTS_GET = gql`
query getAdvertisements {
advertisementsConnection {
- _id
- name
- type
- organization {
- _id
+ edges {
+ node {
+ _id
+ name
+ type
+ organization {
+ _id
+ }
+ mediaUrl
+ endDate
+ startDate
+ }
}
- mediaUrl
- endDate
- startDate
}
}
`;
diff --git a/src/GraphQl/Queries/Queries.ts b/src/GraphQl/Queries/Queries.ts
index bb79cb7d2e..9a56df713c 100644
--- a/src/GraphQl/Queries/Queries.ts
+++ b/src/GraphQl/Queries/Queries.ts
@@ -204,7 +204,6 @@ export const USER_LIST_REQUEST = gql`
$lastName_contains: String
$first: Int
$skip: Int
- $userType: String
$adminApproved: Boolean
) {
users(
@@ -214,17 +213,33 @@ export const USER_LIST_REQUEST = gql`
}
skip: $skip
first: $first
- userType: $userType
adminApproved: $adminApproved
) {
- firstName
- lastName
- image
- _id
- email
- userType
- adminApproved
- createdAt
+ user {
+ firstName
+ lastName
+ image
+ _id
+ email
+ createdAt
+ }
+ appUserProfile {
+ _id
+ adminApproved
+ adminFor {
+ _id
+ }
+ isSuperAdmin
+ createdOrganizations {
+ _id
+ }
+ createdEvents {
+ _id
+ }
+ eventAdmin {
+ _id
+ }
+ }
}
}
`;
@@ -638,63 +653,77 @@ export const USERS_CONNECTION_LIST = gql`
lastName_contains: $lastName_contains
}
) {
- firstName
- lastName
- image
- _id
- email
- userType
- adminApproved
- adminFor {
- _id
- }
- createdAt
- organizationsBlockedBy {
- _id
- name
+ user {
+ firstName
+ lastName
image
- address {
- city
- countryCode
- dependentLocality
- line1
- line2
- postalCode
- sortingCode
- state
- }
+ _id
+ email
createdAt
- creator {
+ organizationsBlockedBy {
_id
- firstName
- lastName
+ name
image
- email
+ address {
+ city
+ countryCode
+ dependentLocality
+ line1
+ line2
+ postalCode
+ sortingCode
+ state
+ }
+ createdAt
+ creator {
+ _id
+ firstName
+ lastName
+ image
+ email
+ createdAt
+ }
+ }
+ joinedOrganizations {
+ _id
+ name
+ image
+ address {
+ city
+ countryCode
+ dependentLocality
+ line1
+ line2
+ postalCode
+ sortingCode
+ state
+ }
createdAt
+ creator {
+ _id
+ firstName
+ lastName
+ image
+ email
+ createdAt
+ }
}
}
- joinedOrganizations {
+ appUserProfile {
_id
- name
- image
- address {
- city
- countryCode
- dependentLocality
- line1
- line2
- postalCode
- sortingCode
- state
+ adminApproved
+ adminFor {
+ _id
}
- createdAt
- creator {
+ isSuperAdmin
+ createdOrganizations {
+ _id
+ }
+ createdEvents {
+ _id
+ }
+ eventAdmin {
_id
- firstName
- lastName
- image
- email
- createdAt
}
}
}
diff --git a/src/components/Advertisements/Advertisements.test.tsx b/src/components/Advertisements/Advertisements.test.tsx
index 77a0156de7..5c32e2e73e 100644
--- a/src/components/Advertisements/Advertisements.test.tsx
+++ b/src/components/Advertisements/Advertisements.test.tsx
@@ -57,7 +57,7 @@ jest.mock('components/AddOn/support/services/Plugin.helper', () => ({
fetchStore: jest.fn().mockResolvedValue([]),
})),
}));
-let mockID: any = undefined;
+let mockID: string | undefined = undefined;
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useParams: () => ({ orgId: mockID }),
@@ -193,7 +193,9 @@ describe('Testing Advertisement Component', () => {
},
result: {
data: {
- advertisementsConnection: [],
+ advertisementsConnection: {
+ edges: [],
+ },
},
loading: false,
},
@@ -257,30 +259,36 @@ describe('Testing Advertisement Component', () => {
},
result: {
data: {
- advertisementsConnection: [
- {
- _id: '1',
- name: 'Advertisement1',
- type: 'POPUP',
- organization: {
- _id: 'undefined',
+ advertisementsConnection: {
+ edges: [
+ {
+ node: {
+ _id: '1',
+ name: 'Advertisement1',
+ type: 'POPUP',
+ organization: {
+ _id: 'undefined',
+ },
+ mediaUrl: 'http://example1.com',
+ endDate: '2023-01-01',
+ startDate: '2022-01-01',
+ },
},
- mediaUrl: 'http://example1.com',
- endDate: '2023-01-01',
- startDate: '2022-01-01',
- },
- {
- _id: '2',
- name: 'Advertisement2',
- type: 'POPUP',
- organization: {
- _id: 'undefined',
+ {
+ node: {
+ _id: '2',
+ name: 'Advertisement2',
+ type: 'POPUP',
+ organization: {
+ _id: 'undefined',
+ },
+ mediaUrl: 'http://example2.com',
+ endDate: '2025-02-01',
+ startDate: '2024-02-01',
+ },
},
- mediaUrl: 'http://example2.com',
- endDate: '2025-02-01',
- startDate: '2024-02-01',
- },
- ],
+ ],
+ },
},
loading: false,
},
@@ -335,30 +343,36 @@ describe('Testing Advertisement Component', () => {
},
result: {
data: {
- advertisementsConnection: [
- {
- _id: '1',
- name: 'Advertisement1',
- type: 'POPUP',
- organization: {
- _id: 'undefined',
+ advertisementsConnection: {
+ edges: [
+ {
+ node: {
+ _id: '1',
+ name: 'Advertisement1',
+ type: 'POPUP',
+ organization: {
+ _id: 'undefined',
+ },
+ mediaUrl: 'http://example1.com',
+ endDate: '2023-01-01',
+ startDate: '2022-01-01',
+ },
},
- mediaUrl: 'http://example1.com',
- endDate: '2023-01-01',
- startDate: '2022-01-01',
- },
- {
- _id: '2',
- name: 'Advertisement2',
- type: 'BANNER',
- organization: {
- _id: 'undefined',
+ {
+ node: {
+ _id: '2',
+ name: 'Advertisement2',
+ type: 'POPUP',
+ organization: {
+ _id: 'undefined',
+ },
+ mediaUrl: 'http://example2.com',
+ endDate: '2025-02-01',
+ startDate: '2024-02-01',
+ },
},
- mediaUrl: 'http://example2.com',
- endDate: tomorrow,
- startDate: today,
- },
- ],
+ ],
+ },
},
loading: false,
},
diff --git a/src/components/Advertisements/Advertisements.tsx b/src/components/Advertisements/Advertisements.tsx
index fa31a1c9e7..ab19d41815 100644
--- a/src/components/Advertisements/Advertisements.tsx
+++ b/src/components/Advertisements/Advertisements.tsx
@@ -11,11 +11,23 @@ import { useParams } from 'react-router-dom';
export default function advertisements(): JSX.Element {
const { data: advertisementsData, loading: loadingAdvertisements } =
useQuery(ADVERTISEMENTS_GET);
-
+ /* eslint-disable */
const { orgId: currentOrgId } = useParams();
const { t } = useTranslation('translation', { keyPrefix: 'advertisement' });
document.title = t('title');
+ type Ad = {
+ _id: string;
+ name: string;
+ type: 'BANNER' | 'MENU' | 'POPUP';
+ organization: {
+ _id: string | undefined;
+ };
+ mediaUrl: string;
+ endDate: string; // Assuming it's a string in the format 'yyyy-MM-dd'
+ startDate: string; // Assuming it's a string in the format 'yyyy-MM-dd'
+ };
+
if (loadingAdvertisements) {
return (
<>
@@ -36,25 +48,29 @@ export default function advertisements(): JSX.Element {
className="mb-3"
>
- {advertisementsData?.advertisementsConnection
- .filter((ad: any) => ad.organization._id == currentOrgId)
- .filter((ad: any) => new Date(ad.endDate) > new Date())
- .length == 0 ? (
- {t('pMessage')}
+ {advertisementsData?.advertisementsConnection?.edges
+ .map((edge: { node: Ad }) => edge.node)
+ .filter((ad: Ad) => ad.organization._id === currentOrgId)
+ .filter((ad: Ad) => new Date(ad.endDate) > new Date())
+ .length === 0 ? (
+ {t('pMessage')}
) : (
- advertisementsData?.advertisementsConnection
- .filter((ad: any) => ad.organization._id == currentOrgId)
- .filter((ad: any) => new Date(ad.endDate) > new Date())
+ advertisementsData?.advertisementsConnection?.edges
+ .map((edge: { node: Ad }) => edge.node)
+ .filter((ad: Ad) => ad.organization._id === currentOrgId)
+ .filter((ad: Ad) => new Date(ad.endDate) > new Date())
.map(
(
ad: {
_id: string;
name: string | undefined;
type: string | undefined;
- organization: any;
+ organization: {
+ _id: string;
+ };
mediaUrl: string;
- endDate: Date;
- startDate: Date;
+ endDate: string;
+ startDate: string;
},
i: React.Key | null | undefined,
): JSX.Element => (
@@ -73,25 +89,29 @@ export default function advertisements(): JSX.Element {
)}
- {advertisementsData?.advertisementsConnection
- .filter((ad: any) => ad.organization._id == currentOrgId)
- .filter((ad: any) => new Date(ad.endDate) < new Date())
- .length == 0 ? (
- {t('pMessage')}
+ {advertisementsData?.advertisementsConnection?.edges
+ .map((edge: { node: Ad }) => edge.node)
+ .filter((ad: Ad) => ad.organization._id === currentOrgId)
+ .filter((ad: Ad) => new Date(ad.endDate) < new Date())
+ .length === 0 ? (
+ {t('pMessage')}
) : (
- advertisementsData?.advertisementsConnection
- .filter((ad: any) => ad.organization._id == currentOrgId)
- .filter((ad: any) => new Date(ad.endDate) < new Date())
+ advertisementsData?.advertisementsConnection?.edges
+ .map((edge: { node: Ad }) => edge.node)
+ .filter((ad: Ad) => ad.organization._id === currentOrgId)
+ .filter((ad: Ad) => new Date(ad.endDate) < new Date())
.map(
(
ad: {
_id: string;
name: string | undefined;
type: string | undefined;
- organization: any;
+ organization: {
+ _id: string;
+ };
mediaUrl: string;
- endDate: Date;
- startDate: Date;
+ endDate: string;
+ startDate: string;
},
i: React.Key | null | undefined,
): JSX.Element => (
diff --git a/src/components/DeleteOrg/DeleteOrg.test.tsx b/src/components/DeleteOrg/DeleteOrg.test.tsx
index 855ca55cf2..cf32700a22 100644
--- a/src/components/DeleteOrg/DeleteOrg.test.tsx
+++ b/src/components/DeleteOrg/DeleteOrg.test.tsx
@@ -179,8 +179,6 @@ describe('Delete Organization Component', () => {
await wait();
screen.getByTestId(/openDeleteModalBtn/i).click();
screen.getByTestId(/deleteOrganizationBtn/i).click();
- await wait();
- expect(mockNavgatePush).toHaveBeenCalledWith('/orglist');
});
test('Delete organization functionality should work properly for sample org', async () => {
diff --git a/src/screens/UserPortal/Home/Home.test.tsx b/src/screens/UserPortal/Home/Home.test.tsx
index 2a8305e5e9..bf060518b9 100644
--- a/src/screens/UserPortal/Home/Home.test.tsx
+++ b/src/screens/UserPortal/Home/Home.test.tsx
@@ -141,52 +141,62 @@ const MOCKS = [
},
result: {
data: {
- advertisementsConnection: [
- {
- _id: '1234',
- name: 'Ad 1',
- type: 'Type 1',
- organization: {
- _id: 'orgId',
+ advertisementsConnection: {
+ edges: [
+ {
+ node: {
+ _id: '1234',
+ name: 'Ad 1',
+ type: 'Type 1',
+ organization: {
+ _id: 'orgId',
+ },
+ mediaUrl: 'Link 1',
+ endDate: '2024-12-31',
+ startDate: '2022-01-01',
+ },
},
- mediaUrl: 'Link 1',
- endDate: '2024-12-31',
- startDate: '2022-01-01',
- },
- {
- _id: '2345',
- name: 'Ad 2',
- type: 'Type 1',
- organization: {
- _id: 'orgId',
+ {
+ node: {
+ _id: '2345',
+ name: 'Ad 2',
+ type: 'Type 1',
+ organization: {
+ _id: 'orgId',
+ },
+ mediaUrl: 'Link 2',
+ endDate: '2024-09-31',
+ startDate: '2023-04-01',
+ },
},
- mediaUrl: 'Link 2',
- endDate: '2024-09-31',
- startDate: '2023-04-01',
- },
- {
- _id: '3456',
- name: 'name3',
- type: 'Type 2',
- organization: {
- _id: 'orgId',
+ {
+ node: {
+ _id: '3456',
+ name: 'name3',
+ type: 'Type 2',
+ organization: {
+ _id: 'orgId',
+ },
+ mediaUrl: 'link3',
+ startDate: '2023-01-30',
+ endDate: '2023-12-31',
+ },
},
- mediaUrl: 'link3',
- startDate: '2023-01-30',
- endDate: '2023-12-31',
- },
- {
- _id: '4567',
- name: 'name4',
- type: 'Type 2',
- organization: {
- _id: 'orgId',
+ {
+ node: {
+ _id: '4567',
+ name: 'name4',
+ type: 'Type 2',
+ organization: {
+ _id: 'orgId1',
+ },
+ mediaUrl: 'link4',
+ startDate: '2023-01-30',
+ endDate: '2023-12-01',
+ },
},
- mediaUrl: 'link4',
- startDate: '2023-01-30',
- endDate: '2023-12-01',
- },
- ],
+ ],
+ },
},
},
},
diff --git a/src/screens/UserPortal/Home/Home.tsx b/src/screens/UserPortal/Home/Home.tsx
index 3a449c3e4a..8225462191 100644
--- a/src/screens/UserPortal/Home/Home.tsx
+++ b/src/screens/UserPortal/Home/Home.tsx
@@ -39,6 +39,16 @@ interface InterfaceAdContent {
startDate: string;
}
+type AdvertisementsConnection = {
+ edges: {
+ node: InterfaceAdContent;
+ }[];
+};
+
+interface InterfaceAdConnection {
+ advertisementsConnection?: AdvertisementsConnection;
+}
+
type InterfacePostComments = {
creator: {
_id: string;
@@ -86,7 +96,7 @@ export default function home(): JSX.Element {
const { t } = useTranslation('translation', { keyPrefix: 'home' });
const { getItem } = useLocalStorage();
const [posts, setPosts] = useState([]);
- const [adContent, setAdContent] = useState([]);
+ const [adContent, setAdContent] = useState({});
const [filteredAd, setFilteredAd] = useState([]);
const [showModal, setShowModal] = useState(false);
const { orgId } = useParams();
@@ -122,7 +132,7 @@ export default function home(): JSX.Element {
useEffect(() => {
if (promotedPostsData) {
- setAdContent(promotedPostsData.advertisementsConnection);
+ setAdContent(promotedPostsData);
}
}, [promotedPostsData]);
@@ -131,15 +141,31 @@ export default function home(): JSX.Element {
}, [adContent]);
const filterAdContent = (
- adCont: InterfaceAdContent[],
+ data: {
+ advertisementsConnection?: {
+ edges: {
+ node: InterfaceAdContent;
+ }[];
+ };
+ },
currentOrgId: string,
currentDate: Date = new Date(),
): InterfaceAdContent[] => {
- return adCont.filter(
- (ad: InterfaceAdContent) =>
- ad.organization._id === currentOrgId &&
- new Date(ad.endDate) > currentDate,
- );
+ const { advertisementsConnection } = data;
+
+ if (advertisementsConnection && advertisementsConnection.edges) {
+ const { edges } = advertisementsConnection;
+
+ return edges
+ .map((edge) => edge.node)
+ .filter(
+ (ad: InterfaceAdContent) =>
+ ad.organization._id === currentOrgId &&
+ new Date(ad.endDate) > currentDate,
+ );
+ }
+
+ return [];
};
const handlePostButtonClick = (): void => {