Skip to content

Commit

Permalink
[userTypeFix] Fixed front-end GraphQL schema in the admin portal, Adv…
Browse files Browse the repository at this point in the history
…ertisement functionality, and the introspection test. (PalisadoesFoundation#1808)

* made changes to pluginqueries

* Made more changes to the queries

* Made more changes to the queries

* Made more changes to the queries

* Made more changes to the queries

* Made more changes to the queries

* Made more changes to the queries

* Made more changes to the queries

* Made more changes to the Mutations

* Fixed error in home.tsx

* Fixed tests in advertisement

* Fixed lint errors, and removed all any types

* Fixed lint errors, and removed all any types

* Made some more changes

* Made changes

* Fixed errors in home.tsx

* Fixed coverage issue
  • Loading branch information
Anubhav-2003 authored Mar 28, 2024
1 parent 0fb76c1 commit 68db1fb
Show file tree
Hide file tree
Showing 8 changed files with 295 additions and 196 deletions.
18 changes: 8 additions & 10 deletions src/GraphQl/Mutations/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export const UPDATE_USER_MUTATION = gql`
$empStatus: EmploymentStatus
$maritalStatus: MaritalStatus
$address: String
$city: String
$state: String
$country: String
$image: String
Expand All @@ -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
) {
Expand All @@ -139,7 +133,9 @@ export const UPDATE_USER_PASSWORD_MUTATION = gql`
confirmNewPassword: $confirmNewPassword
}
) {
_id
user {
_id
}
}
}
`;
Expand Down Expand Up @@ -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
}
}
}
`;
Expand All @@ -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(
Expand Down
20 changes: 12 additions & 8 deletions src/GraphQl/Queries/PlugInQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
`;
Expand Down
143 changes: 86 additions & 57 deletions src/GraphQl/Queries/Queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ export const USER_LIST_REQUEST = gql`
$lastName_contains: String
$first: Int
$skip: Int
$userType: String
$adminApproved: Boolean
) {
users(
Expand All @@ -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
}
}
}
}
`;
Expand Down Expand Up @@ -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
}
}
}
Expand Down
106 changes: 60 additions & 46 deletions src/components/Advertisements/Advertisements.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
Expand Down Expand Up @@ -193,7 +193,9 @@ describe('Testing Advertisement Component', () => {
},
result: {
data: {
advertisementsConnection: [],
advertisementsConnection: {
edges: [],
},
},
loading: false,
},
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down
Loading

0 comments on commit 68db1fb

Please sign in to comment.