Skip to content

Commit

Permalink
Revert "feat: implemented support to upload media in advertisement re…
Browse files Browse the repository at this point in the history
…gister c…"

This reverts commit 81d11fc.
  • Loading branch information
palisadoes authored Feb 1, 2024
1 parent 81d11fc commit 8cd0ce6
Show file tree
Hide file tree
Showing 21 changed files with 354 additions and 522 deletions.
2 changes: 1 addition & 1 deletion public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@
"delete": "Delete",
"Rname": "Enter name of Advertisement",
"Rtype": "Select type of Advertisement",
"Rmedia": "Provide media content to be displayed",
"Rlink": "Provide a link for content to be displayed",
"RstartDate": "Select Start Date",
"RendDate": "Select End Date",
"RClose": "Close the window",
Expand Down
1 change: 0 additions & 1 deletion public/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,6 @@
"deleteAdvertisementMsg": "Voulez-vous supprimer cette annonce ?",
"no": "Non",
"yes": "Oui",
"Rmedia": "Fournir du contenu multimédia à afficher",
"view": "Voir",
"edit": "Éditer",
"editAdvertisement": "Éditer l'annonce",
Expand Down
1 change: 0 additions & 1 deletion public/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,6 @@
"deleteAdvertisementMsg": "क्या आप इस विज्ञापन को हटाना चाहते हैं?",
"no": "नहीं",
"yes": "हाँ",
"Rmedia": "प्रदर्शित करने के लिए मीडिया सामग्री प्रदान करें",
"view": "देखें",
"edit": "संपादित करें",
"editAdvertisement": "विज्ञापन संपादित करें",
Expand Down
1 change: 0 additions & 1 deletion public/locales/sp.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,6 @@
"deleteAdvertisementMsg": "¿Desea eliminar este anuncio?",
"no": "No",
"yes": "",
"Rmedia": "Proporcionar contenido multimedia para mostrar",
"view": "Ver",
"edit": "Editar",
"editAdvertisement": "Editar Anuncio",
Expand Down
1 change: 0 additions & 1 deletion public/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,6 @@
"deleteAdvertisementMsg": "您是否要删除此广告?",
"no": "",
"yes": "",
"Rmedia": "提供要显示的媒体内容",
"view": "查看",
"edit": "编辑",
"editAdvertisement": "编辑广告",
Expand Down
26 changes: 10 additions & 16 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ directive @role(requires: UserType) on FIELD_DEFINITION
type Advertisement {
_id: ID
endDate: Date!
mediaUrl: URL!
link: String!
name: String!
organizationId: ID!
orgId: ID
startDate: Date!
type: String!
}
Expand Down Expand Up @@ -402,19 +402,6 @@ type MinimumValueError implements FieldError {
path: [String!]!
}

input CreateAdvertisementInput {
endDate: Date!
name: String!
organizationId: ID!
startDate: Date!
type: String!
mediaFile: String!
}

type CreateAdvertisementPayload {
advertisement: Advertisement
}

type Mutation {
acceptAdmin(id: ID!): Boolean!
acceptMembershipRequest(membershipRequestId: ID!): MembershipRequest!
Expand All @@ -432,7 +419,14 @@ type Mutation {
cancelMembershipRequest(membershipRequestId: ID!): MembershipRequest!
checkIn(data: CheckInInput!): CheckIn!
createAdmin(data: UserAndOrganizationInput!): User!
createAdvertisement(input: CreateAdvertisementInput!): CreateAdvertisementPayload
createAdvertisement(
endDate: Date!
link: String!
name: String!
orgId: ID!
startDate: Date!
type: String!
): Advertisement!
createComment(data: CommentInput!, postId: ID!): Comment
createDirectChat(data: createChatInput!): DirectChat!
createDonation(
Expand Down
22 changes: 10 additions & 12 deletions src/GraphQl/Mutations/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,22 +444,20 @@ export const ADD_PLUGIN_MUTATION = gql`
`;
export const ADD_ADVERTISEMENT_MUTATION = gql`
mutation (
$organizationId: ID!
$orgId: ID!
$name: String!
$link: String!
$type: String!
$startDate: Date!
$endDate: Date!
$file: String!
) {
createAdvertisement(
input: {
organizationId: $organizationId
name: $name
type: $type
startDate: $startDate
endDate: $endDate
mediaFile: $file
}
orgId: $orgId
name: $name
link: $link
type: $type
startDate: $startDate
endDate: $endDate
) {
_id
}
Expand All @@ -469,7 +467,7 @@ export const UPDATE_ADVERTISEMENT_MUTATION = gql`
mutation UpdateAdvertisement(
$id: ID!
$name: String
$file: String
$link: String
$type: AdvertisementType
$startDate: Date
$endDate: Date
Expand All @@ -478,7 +476,7 @@ export const UPDATE_ADVERTISEMENT_MUTATION = gql`
input: {
_id: $id
name: $name
mediaFile: $file
link: $link
type: $type
startDate: $startDate
endDate: $endDate
Expand Down
6 changes: 2 additions & 4 deletions src/GraphQl/Queries/PlugInQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ export const ADVERTISEMENTS_GET = gql`
_id
name
type
organization {
_id
}
mediaUrl
orgId
link
endDate
startDate
}
Expand Down
42 changes: 14 additions & 28 deletions src/components/Advertisements/Advertisements.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import 'jest-location-mock';
import { act, fireEvent, render, screen } from '@testing-library/react';
import { act, render, screen } from '@testing-library/react';
import { MockedProvider } from '@apollo/client/testing';
import {
ApolloClient,
Expand Down Expand Up @@ -88,9 +88,9 @@ const ADD_ADVERTISEMENT_MUTATION_MOCK = {
request: {
query: ADD_ADVERTISEMENT_MUTATION,
variables: {
organizationId: 'undefined',
orgId: 'undefined',
name: 'Cookie Shop',
file: 'data:image/png;base64,bWVkaWEgY29udGVudA==',
link: 'http://yourwebsite.com/photo',
type: 'POPUP',
startDate: '2023-01-01',
endDate: '2023-02-02',
Expand Down Expand Up @@ -210,26 +210,18 @@ describe('Testing Advertisement Component', () => {
screen.getByLabelText('Enter name of Advertisement'),
'Cookie Shop'
);
const mediaFile = new File(['media content'], 'test.png', {
type: 'image/png',
});

const mediaInput = screen.getByTestId('advertisementMedia');
fireEvent.change(mediaInput, {
target: {
files: [mediaFile],
},
});
const mediaPreview = await screen.findByTestId('mediaPreview');
expect(mediaPreview).toBeInTheDocument();
userEvent.type(
screen.getByLabelText('Provide a link for content to be displayed'),
'http://yourwebsite.com/photo'
);
userEvent.selectOptions(
screen.getByLabelText('Select type of Advertisement'),
'POPUP'
);
userEvent.type(screen.getByLabelText('Select Start Date'), '2023-01-01');
userEvent.type(screen.getByLabelText('Select End Date'), '2023-02-02');

userEvent.click(screen.getByTestId('addonregister'));
await userEvent.click(screen.getByTestId('addonregister'));
expect(
await screen.findByText('Advertisement created successfully')
).toBeInTheDocument();
Expand All @@ -251,10 +243,8 @@ describe('Testing Advertisement Component', () => {
_id: '1',
name: 'Advertisement1',
type: 'POPUP',
organization: {
_id: 'undefined',
},
mediaUrl: 'http://example1.com',
orgId: 'undefined',
link: 'http://example1.com',
endDate: '2023-01-01',
startDate: '2022-01-01',
},
Expand Down Expand Up @@ -318,21 +308,17 @@ describe('Testing Advertisement Component', () => {
_id: '1',
name: 'Advertisement1',
type: 'POPUP',
organization: {
_id: 'undefined',
},
mediaUrl: 'http://example1.com',
orgId: 'undefined',
link: 'http://example1.com',
endDate: '2023-01-01',
startDate: '2022-01-01',
},
{
_id: '2',
name: 'Advertisement2',
type: 'BANNER',
organization: {
_id: 'undefined',
},
mediaUrl: 'http://example2.com',
orgId: 'undefined',
link: 'http://example2.com',
endDate: tomorrow,
startDate: today,
},
Expand Down
Loading

0 comments on commit 8cd0ce6

Please sign in to comment.