Skip to content

Commit 86f46c1

Browse files
committed
fix/Button for whatsapp form (#3661)
* Fix: add new button * fix: button * fix:Button image * Fix: css * fix: remove delete icon
1 parent d79e2c0 commit 86f46c1

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

src/containers/WhatsAppForms/WhatsAppFormList/WhatsAppFormList.module.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
min-height: 36px !important;
99
}
1010

11-
.SearchBar>fieldset {
11+
.SearchBar > fieldset {
1212
border: none !important;
1313
}
1414

@@ -127,6 +127,9 @@
127127
z-index: 20;
128128
min-width: 150px;
129129
}
130+
.IconSize {
131+
font-size: 1.2rem !important;
132+
}
130133

131134
.MoreListItem {
132135
padding: 5px 10px;

src/containers/WhatsAppForms/WhatsAppFormList/WhatsAppFormList.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ describe('<WhatsAppFormList />', () => {
150150
});
151151

152152
test('deactivate a form successfully when inactive button is clicked', async () => {
153-
const { getByText, getAllByRole, getByTestId } = render(wrapper([deactivateWhatsappForm]));
153+
const { getByText, getAllByRole, getByTestId, getAllByTestId } = render(wrapper([deactivateWhatsappForm]));
154154
const notificationSpy = vi.spyOn(Notification, 'setNotification');
155155

156156
const select = getAllByRole('combobox')[0];
@@ -164,8 +164,8 @@ describe('<WhatsAppFormList />', () => {
164164
expect(getByText('This is form name')).toBeInTheDocument();
165165
});
166166

167-
fireEvent.click(getByTestId('MoreIcon'));
168-
fireEvent.click(getByText('Deactivate'));
167+
const deactivateIcon = await waitFor(() => getAllByTestId('deactivate-icon')[0]);
168+
fireEvent.click(deactivateIcon);
169169

170170
await waitFor(() => {
171171
expect(getByTestId('dialogTitle')).toBeInTheDocument();
@@ -181,7 +181,7 @@ describe('<WhatsAppFormList />', () => {
181181
});
182182

183183
test('shows error message when deactivate API fails', async () => {
184-
const { getByText, getAllByRole, getByTestId } = render(wrapper([deactivateWhatsappFormError]));
184+
const { getByText, getAllByRole, getByTestId, getAllByTestId } = render(wrapper([deactivateWhatsappFormError]));
185185
const errorSpy = vi.spyOn(Notification, 'setErrorMessage');
186186

187187
const select = getAllByRole('combobox')[0];
@@ -195,8 +195,8 @@ describe('<WhatsAppFormList />', () => {
195195
expect(getByText('This is form name')).toBeInTheDocument();
196196
});
197197

198-
fireEvent.click(getByTestId('MoreIcon'));
199-
fireEvent.click(getByText('Deactivate'));
198+
const deactivateIcon = await waitFor(() => getAllByTestId('deactivate-icon')[0]);
199+
fireEvent.click(deactivateIcon);
200200

201201
await waitFor(() => {
202202
expect(getByTestId('dialogTitle')).toBeInTheDocument();

src/containers/WhatsAppForms/WhatsAppFormList/WhatsAppFormList.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import { GET_WHATSAPP_FORM, LIST_WHATSAPP_FORMS } from 'graphql/queries/WhatsApp
1010
import { useMemo, useState } from 'react';
1111
import { useNavigate } from 'react-router';
1212
import { formatError } from '../WhatsAppForms';
13+
import AddCircleOutlineIcon from '@mui/icons-material/AddCircleOutline';
14+
import HighlightOffIcon from '@mui/icons-material/HighlightOff';
15+
1316
import styles from './WhatsAppFormList.module.css';
1417

1518
const columnStyles = [styles.Name, styles.status, styles.Label, styles.Actions];
@@ -128,12 +131,12 @@ export const WhatsAppFormList = () => {
128131
const additionalAction = (item: any) => {
129132
const deactivateAction = {
130133
label: 'Deactivate',
134+
icon: <HighlightOffIcon className={styles.IconSize} data-testid="deactivate-icon" />,
131135
parameter: 'id',
132136
dialog: (id: string) => {
133137
setFormId(id);
134138
setDialogType('inactive');
135139
},
136-
insideMore: true,
137140
};
138141

139142
const publishAction = {
@@ -148,13 +151,12 @@ export const WhatsAppFormList = () => {
148151

149152
const activateAction = {
150153
label: 'Activate',
154+
icon: <AddCircleOutlineIcon className={styles.IconSize} data-testid="activate-icon" />,
151155
parameter: 'id',
152156
dialog: (id: string) => {
153157
setFormId(id);
154-
setDialogType('activate');
155158
activateForm({ variables: { activateWhatsappFormId: id } });
156159
},
157-
insideMore: true,
158160
};
159161

160162
let actions = [];

0 commit comments

Comments
 (0)