Skip to content

Commit

Permalink
updated query with the latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kanhaiya04 committed Mar 16, 2024
1 parent d7a8a9a commit 5f7309d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 34 deletions.
24 changes: 15 additions & 9 deletions src/components/Advertisements/Advertisements.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe('Testing Advertisement Component', () => {
},
result: {
data: {
getAdvertisements: [],
advertisementsConnection: [],
},
loading: false,
},
Expand Down Expand Up @@ -245,13 +245,15 @@ describe('Testing Advertisement Component', () => {
},
result: {
data: {
getAdvertisements: [
advertisementsConnection: [
{
_id: '1',
name: 'Advertisement1',
type: 'POPUP',
orgId: 'undefined',
link: 'http://example1.com',
organization: {
_id: 'undefined',
},
mediaUrl: 'http://example1.com',
endDate: '2023-01-01',
startDate: '2022-01-01',
},
Expand Down Expand Up @@ -310,22 +312,26 @@ describe('Testing Advertisement Component', () => {
},
result: {
data: {
getAdvertisements: [
advertisementsConnection: [
{
_id: '1',
name: 'Advertisement1',
type: 'POPUP',
orgId: 'undefined',
link: 'http://example1.com',
organization: {
_id: 'undefined',
},
mediaUrl: 'http://example1.com',
endDate: '2023-01-01',
startDate: '2022-01-01',
},
{
_id: '2',
name: 'Advertisement2',
type: 'BANNER',
orgId: 'undefined',
link: 'http://example2.com',
organization: {
_id: 'undefined',
},
mediaUrl: 'http://example2.com',
endDate: tomorrow,
startDate: today,
},
Expand Down
30 changes: 15 additions & 15 deletions src/components/Advertisements/Advertisements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,23 @@ export default function advertisements(): JSX.Element {
onSelect={updateSelectedTab}
>
<Tab eventKey="avaactiveAdsilable" title={t('activeAds')}>
{data2?.getAdvertisements
.filter((ad: any) => ad.orgId == currentOrgId)
{data2?.advertisementsConnection
.filter((ad: any) => ad.organization._id == currentOrgId)
.filter((ad: any) => new Date(ad.endDate) > new Date())
.length == 0 ? (
<h4>{t('pMessage')} </h4> // eslint-disable-line
) : (
data2?.getAdvertisements
.filter((ad: any) => ad.orgId == currentOrgId)
data2?.advertisementsConnection
.filter((ad: any) => ad.organization._id == currentOrgId)
.filter((ad: any) => new Date(ad.endDate) > new Date())
.map(
(
ad: {
_id: string;
name: string | undefined;
type: string | undefined;
orgId: string;
link: string;
organization: { _id: string };
mediaUrl: string;
endDate: Date;
startDate: Date;
},
Expand All @@ -138,34 +138,34 @@ export default function advertisements(): JSX.Element {
key={i}
name={ad.name}
type={ad.type}
orgId={ad.orgId}
orgId={ad.organization._id}
startDate={new Date(ad.startDate)}
endDate={new Date(ad.endDate)}
link={ad.link}
link={ad.mediaUrl}
// getInstalledPlugins={getInstalledPlugins}
/>
)
)
)}
</Tab>
<Tab eventKey="archievedAds" title={t('archievedAds')}>
{data2?.getAdvertisements
.filter((ad: any) => ad.orgId == currentOrgId)
{data2?.advertisementsConnection
.filter((ad: any) => ad.organization._id == currentOrgId)
.filter((ad: any) => new Date(ad.endDate) < new Date())
.length == 0 ? (
<h4>{t('pMessage')} </h4> // eslint-disable-line
) : (
data2?.getAdvertisements
.filter((ad: any) => ad.orgId == currentOrgId)
data2?.advertisementsConnection
.filter((ad: any) => ad.organization._id == currentOrgId)
.filter((ad: any) => new Date(ad.endDate) < new Date())
.map(
(
ad: {
_id: string;
name: string | undefined;
type: string | undefined;
orgId: string;
link: string;
organization: { _id: string };
mediaUrl: string;
endDate: Date;
startDate: Date;
},
Expand All @@ -176,7 +176,7 @@ export default function advertisements(): JSX.Element {
key={i}
name={ad.name}
type={ad.type}
orgId={ad.orgId}
orgId={ad.organization._id}
startDate={new Date(ad.startDate)}
endDate={new Date(ad.endDate)}
// getInstalledPlugins={getInstalledPlugins}
Expand Down
2 changes: 2 additions & 0 deletions src/components/UserUpdate/UserUpdate.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const MOCKS = [
__typename: 'UserData',
appUserProfile: {
__typename: 'AppUserProfile',
_id: '1',
adminFor: [
{ __typename: 'Organization', _id: '65e0df0906dd1228350cfd4a' },
{ __typename: 'Organization', _id: '65e0e2abb92c9f3e29503d4e' },
Expand All @@ -45,6 +46,7 @@ const MOCKS = [
},
user: {
__typename: 'User',
_id: '1',
firstName: 'Aditya',
lastName: 'Agarwal',
createdAt: '2024-02-26T10:36:33.098Z',
Expand Down
20 changes: 11 additions & 9 deletions src/screens/UserPortal/Organizations/Organizations.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,17 @@ const MOCKS = [
data: {
users: [
{
joinedOrganizations: [
{
__typename: 'Organization',
_id: '6401ff65ce8e8406b8f07af2',
name: 'joinedOrganization',
image: '',
description: 'New Desc',
},
],
user: {
joinedOrganizations: [
{
__typename: 'Organization',
_id: '6401ff65ce8e8406b8f07af2',
name: 'joinedOrganization',
image: '',
description: 'New Desc',
},
],
},
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion src/screens/UserPortal/Organizations/Organizations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default function organizations(): JSX.Element {
}
} else if (mode == 1) {
if (data2) {
setOrganizations(data2.users[0].joinedOrganizations);
setOrganizations(data2.users[0].user.joinedOrganizations);
}
} else if (mode == 2) {
if (data3) {
Expand Down

0 comments on commit 5f7309d

Please sign in to comment.