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

Enabling editing an advertisement #1428

Merged
merged 23 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8cc7735
add: modifying create advertisement modal to allow editing
Vaishali054 Dec 9, 2023
b038719
adding edit button to advertisement card
Vaishali054 Dec 9, 2023
bcb2b99
fix: adding link as prop
Vaishali054 Dec 9, 2023
6d68cd7
adding css for the changes
Vaishali054 Dec 9, 2023
89d3071
changing title of edit modal
Vaishali054 Dec 9, 2023
4fc71d3
update: changing card layout to default layout
Vaishali054 Dec 9, 2023
09d1370
fix: view button styling
Vaishali054 Dec 9, 2023
0c32c0a
fix: edit modal header styling
Vaishali054 Dec 9, 2023
70386da
Merge remote-tracking branch 'upstream/develop' into develop
Vaishali054 Dec 9, 2023
7ee1bf2
adding test for increasing code coverage
Vaishali054 Dec 9, 2023
4537cc9
add: test case for delete add button
Vaishali054 Dec 9, 2023
7c7f4e9
fix:tests
Vaishali054 Dec 9, 2023
10a5436
eslint fix
Vaishali054 Dec 9, 2023
4d937ac
merge conflicts
Vaishali054 Dec 23, 2023
3772320
fix: resolved warning
Vaishali054 Dec 23, 2023
bab7122
add : translations
Vaishali054 Dec 23, 2023
487b495
Merge remote-tracking branch 'upstream/develop' into develop
Vaishali054 Dec 26, 2023
4d34aca
fix: mutation and add: refetch after updating
Vaishali054 Dec 27, 2023
a89d247
fix: tests & mutation
Vaishali054 Jan 14, 2024
6b041ca
Merge branch 'PalisadoesFoundation:develop' into develop
Vaishali054 Jan 14, 2024
ca132e0
Merge remote-tracking branch 'origin/develop' into develop
Vaishali054 Jan 14, 2024
6f03dbf
remove the card link && fix tests
Vaishali054 Jan 14, 2024
9be5d34
changes: add line, fix comment
Vaishali054 Jan 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,11 @@
"deleteAdvertisement": "Delete Advertisement",
"deleteAdvertisementMsg": "Do you want to remove this advertisement?",
"no": "No",
"yes": "Yes"
"yes": "Yes",
"view": "View",
"edit": "Edit",
"editAdvertisement": "Edit Advertisement",
"saveChanges": "Save Changes"
},
"userChat": {
"chat": "Chat",
Expand Down
6 changes: 5 additions & 1 deletion public/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,11 @@
"deleteAdvertisement": "Supprimer l'annonce",
"deleteAdvertisementMsg": "Voulez-vous supprimer cette annonce ?",
"no": "Non",
"yes": "Oui"
"yes": "Oui",
"view": "Voir",
"edit": "Éditer",
"editAdvertisement": "Éditer l'annonce",
"saveChanges": "Enregistrer les modifications"
},
"userChat": {
"chat": "Chat",
Expand Down
6 changes: 5 additions & 1 deletion public/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,11 @@
"deleteAdvertisement": "विज्ञापन हटाएं",
"deleteAdvertisementMsg": "क्या आप इस विज्ञापन को हटाना चाहते हैं?",
"no": "नहीं",
"yes": "हाँ"
"yes": "हाँ",
"view": "देखें",
"edit": "संपादित करें",
"editAdvertisement": "विज्ञापन संपादित करें",
"saveChanges": "परिवर्तन सहेजें"
},
"userChat": {
"chat": "बात",
Expand Down
6 changes: 5 additions & 1 deletion public/locales/sp.json
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,11 @@
"deleteAdvertisement": "Eliminar anuncio",
"deleteAdvertisementMsg": "¿Desea eliminar este anuncio?",
"no": "No",
"yes": "Sí"
"yes": "Sí",
"view": "Ver",
"edit": "Editar",
"editAdvertisement": "Editar Anuncio",
"saveChanges": "Guardar Cambios"
},
"userChat": {
"chat": "Charlar",
Expand Down
6 changes: 5 additions & 1 deletion public/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,11 @@
"deleteAdvertisement": "删除广告",
"deleteAdvertisementMsg": "您是否要删除此广告?",
"no": "不",
"yes": "是"
"yes": "是",
"view": "查看",
"edit": "编辑",
"editAdvertisement": "编辑广告",
"saveChanges": "保存更改"
},
"userChat": {
"chat": "聊天",
Expand Down
25 changes: 25 additions & 0 deletions src/GraphQl/Mutations/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,31 @@ export const ADD_ADVERTISEMENT_MUTATION = gql`
}
}
`;
export const UPDATE_ADVERTISEMENT_MUTATION = gql`
mutation UpdateAdvertisement(
$id: ID!
$name: String
$link: String
$type: AdvertisementType
$startDate: Date
$endDate: Date
) {
updateAdvertisement(
input: {
_id: $id
name: $name
link: $link
type: $type
startDate: $startDate
endDate: $endDate
}
) {
advertisement {
_id
}
}
}
`;
export const DELETE_ADVERTISEMENT_BY_ID = gql`
mutation ($id: ID!) {
deleteAdvertisementById(id: $id) {
Expand Down
51 changes: 0 additions & 51 deletions src/components/Advertisements/Advertisements.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,57 +163,6 @@ const ORGANIZATIONS_LIST_MOCK = {
};

describe('Testing Advertisement Component', () => {
test('Testing if the deletion works', async () => {
Vaishali054 marked this conversation as resolved.
Show resolved Hide resolved
const mocks = [
{
request: {
query: ADVERTISEMENTS_GET,
},
result: {
data: {
getAdvertisements: [
{
_id: '1',
name: 'Advertisement1',
type: 'POPUP',
orgId: 'undefined',
link: 'http://example1.com',
endDate: '2023-01-01',
startDate: '2022-01-01',
},
],
},
loading: false,
},
},
ORGANIZATIONS_LIST_MOCK,
PLUGIN_GET_MOCK,
ADD_ADVERTISEMENT_MUTATION_MOCK,
];

render(
<MockedProvider addTypename={false} mocks={mocks}>
<BrowserRouter>
<Provider store={store}>
<I18nextProvider i18n={i18nForTest}>
<ToastContainer />
<Advertisement />
</I18nextProvider>
</Provider>
</BrowserRouter>
</MockedProvider>
);

await wait();

await act(async () => {
await userEvent.click(screen.getByText('Delete'));
});
await act(async () => {
await userEvent.click(screen.getByText('Yes'));
});
});

test('for creating new Advertisements', async () => {
const mocks = [
ORGANIZATIONS_LIST_MOCK,
Expand Down
1 change: 1 addition & 0 deletions src/components/Advertisements/Advertisements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default function advertisements(): JSX.Element {
orgId={ad.orgId}
startDate={new Date(ad.startDate)}
endDate={new Date(ad.endDate)}
link={ad.link}
// getInstalledPlugins={getInstalledPlugins}
/>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,67 @@
}

.entryaction {
margin-left: auto;
display: flex !important;
align-items: center;
}

.entryaction i {
margin-right: 8px;
margin-top: 4px;
}

.entryaction .spinner-grow {
height: 1rem;
width: 1rem;
margin-right: 8px;
}

.buttons {
display: flex;
justify-content: flex-end;
}

.dropdownButton {
background-color: transparent;
color: #000;
border: none;
cursor: pointer;
display: flex;
width: 100%;
justify-content: flex-end;
padding: 8px 10px;
}

.dropdownContainer {
position: relative;
display: inline-block;
}

.dropdownmenu {
display: none;
position: absolute;
z-index: 1;
background-color: white;
width: 120px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
padding: 5px 0;
margin: 0;
list-style-type: none;
right: 0;
top: 100%;
}

.dropdownmenu li {
cursor: pointer;
padding: 8px 16px;
text-decoration: none;
display: block;
color: #333;
}

.dropdownmenu li:hover {
background-color: #f1f1f1;
}

.dropdownContainer:hover .dropdownmenu {
display: block;
}
Loading
Loading