Skip to content

Commit 3e5857e

Browse files
authored
Merge pull request #3162 from glific/code-formatting
fixes for code formatting
2 parents 28d7132 + 115cdf5 commit 3e5857e

File tree

196 files changed

+1078
-2618
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+1078
-2618
lines changed

src/assets/images/icons/SideDrawer/KnowledgeBaseIcon.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
const SvgComponent = ({ color }: { color: string }) => (
2-
<svg
3-
xmlns="http://www.w3.org/2000/svg"
4-
x="0px"
5-
y="0px"
6-
width="18"
7-
height="18"
8-
viewBox="0,0,256,256"
9-
>
2+
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="18" height="18" viewBox="0,0,256,256">
103
<g fill={color}>
114
<g transform="scale(9.84615,9.84615)">
125
<path d="M7,0c-2.20312,0 -4,1.79688 -4,4v18c0,2.20313 1.79688,4 4,4h12c2.20313,0 4,-1.79687 4,-4v-14c0,-1.0625 -0.97266,-2.07031 -2.71875,-3.78125c-0.24219,-0.23828 -0.50391,-0.50391 -0.75,-0.75c-0.24609,-0.24609 -0.51172,-0.47656 -0.75,-0.71875c-1.71094,-1.74609 -2.71875,-2.75 -3.78125,-2.75zM7,2h7.28125c0.72266,0.18359 0.71875,1.05078 0.71875,1.9375v3.0625c0,0.55078 0.44922,1 1,1h3c0.99609,0 2,0.00391 2,1v13c0,1.10547 -0.89453,2 -2,2h-12c-1.10547,0 -2,-0.89453 -2,-2v-18c0,-1.10547 0.89453,-2 2,-2zM7.8125,10c-0.55078,0.05078 -0.95703,0.54297 -0.90625,1.09375c0.05078,0.55078 0.54297,0.95703 1.09375,0.90625h10c0.35938,0.00391 0.69531,-0.18359 0.87891,-0.49609c0.17969,-0.3125 0.17969,-0.69531 0,-1.00781c-0.18359,-0.3125 -0.51953,-0.5 -0.87891,-0.49609h-10c-0.03125,0 -0.0625,0 -0.09375,0c-0.03125,0 -0.0625,0 -0.09375,0zM7.8125,14c-0.55078,0.05078 -0.95703,0.54297 -0.90625,1.09375c0.05078,0.55078 0.54297,0.95703 1.09375,0.90625h8c0.35938,0.00391 0.69531,-0.18359 0.87891,-0.49609c0.17969,-0.3125 0.17969,-0.69531 0,-1.00781c-0.18359,-0.3125 -0.51953,-0.5 -0.87891,-0.49609h-8c-0.03125,0 -0.0625,0 -0.09375,0c-0.03125,0 -0.0625,0 -0.09375,0zM7.8125,18c-0.55078,0.05078 -0.95703,0.54297 -0.90625,1.09375c0.05078,0.55078 0.54297,0.95703 1.09375,0.90625h10c0.35938,0.00391 0.69531,-0.18359 0.87891,-0.49609c0.17969,-0.3125 0.17969,-0.69531 0,-1.00781c-0.18359,-0.3125 -0.51953,-0.5 -0.87891,-0.49609h-10c-0.03125,0 -0.0625,0 -0.09375,0c-0.03125,0 -0.0625,0 -0.09375,0z"></path>

src/assets/images/icons/SideDrawer/SettingsIcon.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
const SvgComponent = ({ color }: { color: string }) => (
22
<svg xmlns="http://www.w3.org/2000/svg" width={18} height={18} fill="none">
3-
<g
4-
stroke={color}
5-
strokeLinecap="round"
6-
strokeLinejoin="round"
7-
strokeWidth={2}
8-
clipPath="url(#a)"
9-
>
3+
<g stroke={color} strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} clipPath="url(#a)">
104
<path d="M9 11.25a2.25 2.25 0 1 0 0-4.5 2.25 2.25 0 0 0 0 4.5Z" />
115
<path d="M14.55 11.25a1.238 1.238 0 0 0 .247 1.365l.045.045a1.5 1.5 0 0 1-1.06 2.562 1.5 1.5 0 0 1-1.062-.44l-.045-.044a1.238 1.238 0 0 0-1.365-.248 1.238 1.238 0 0 0-.75 1.133v.127a1.5 1.5 0 1 1-3 0v-.068a1.238 1.238 0 0 0-.81-1.132 1.238 1.238 0 0 0-1.365.247l-.045.045a1.5 1.5 0 1 1-2.123-2.122l.046-.045a1.238 1.238 0 0 0 .247-1.365 1.238 1.238 0 0 0-1.132-.75H2.25a1.5 1.5 0 1 1 0-3h.067a1.237 1.237 0 0 0 1.133-.81 1.237 1.237 0 0 0-.248-1.365l-.044-.045A1.5 1.5 0 1 1 5.28 3.217l.045.046a1.237 1.237 0 0 0 1.365.247h.06a1.237 1.237 0 0 0 .75-1.132V2.25a1.5 1.5 0 0 1 3 0v.067a1.238 1.238 0 0 0 .75 1.133 1.237 1.237 0 0 0 1.365-.248l.045-.044a1.5 1.5 0 1 1 2.123 2.122l-.045.045a1.237 1.237 0 0 0-.248 1.365v.06a1.237 1.237 0 0 0 1.133.75h.127a1.5 1.5 0 0 1 0 3h-.068a1.238 1.238 0 0 0-1.132.75Z" />
126
</g>

src/assets/images/icons/SideDrawer/TagIcon.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ const SvgComponent = ({ color }: { color: string }) => (
66
d="M2.26 2.26c-.02.307-.038.647-.052 1.007-.058 1.477-.05 3.16.111 4.434l7.899 7.899 5.382-5.382L7.7 2.319c-1.272-.162-2.957-.17-4.434-.11-.36.014-.699.032-1.008.05ZM.284.284C.18.385-.248 5.25.201 8.255c.048.32.206.608.434.837l8.43 8.43a1.633 1.633 0 0 0 2.306 0l6.15-6.15a1.63 1.63 0 0 0 0-2.308L9.092.635A1.502 1.502 0 0 0 8.255.2C5.25-.247.385.18.285.285Z"
77
clipRule="evenodd"
88
/>
9-
<path
10-
fill={color}
11-
d="M6.86 5.414a1.087 1.087 0 1 1-1.538 1.538 1.087 1.087 0 0 1 1.539-1.538Z"
12-
/>
9+
<path fill={color} d="M6.86 5.414a1.087 1.087 0 1 1-1.538 1.538 1.087 1.087 0 0 1 1.539-1.538Z" />
1310
</svg>
1411
);
1512
export default SvgComponent;

src/common/RichEditor.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { UrlMatcher } from 'interweave-autolink';
55
import { $createParagraphNode, $createTextNode, $getRoot } from 'lexical';
66

77
// Indicates how to replace different parts of the text from WhatsApp to HTML.
8-
const regexForLink =
9-
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)/gi;
8+
const regexForLink = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)/gi;
109

1110
export const handleFormatterEvents = (event: KeyboardEvent) => {
1211
if ((event.ctrlKey || event.metaKey) && event.code === 'KeyB') {
@@ -130,9 +129,7 @@ export const WhatsAppTemplateButton = (text: string) => {
130129
const buttonsStr = text.substring(isTemplateButtonsPresent);
131130
const templateStr = buttonsStr.split('|');
132131

133-
const buttons = templateStr
134-
.map((val: string) => val && val.trim().slice(1, -1))
135-
.filter((a) => a);
132+
const buttons = templateStr.map((val: string) => val && val.trim().slice(1, -1)).filter((a) => a);
136133

137134
// Checking if template type is call to action or quick reply
138135

src/common/constants.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ export const SIMULATOR_CONTACT = '9876543210';
2323
export const FLOW_STATUS_PUBLISHED = 'published';
2424
export const SIMULATOR_NUMBER_START = '9876543210';
2525
export const GUPSHUP_ENTERPRISE_SHORTCODE = 'gupshup_enterprise';
26-
export const VALID_URL_REGEX =
27-
'https?://(www.)?[-a-zA-Z0-9@:%._+~#=]{2,256}.[a-z]{2,4}([-a-zA-Z0-9@:%_+.~#?&/=]*)';
26+
export const VALID_URL_REGEX = 'https?://(www.)?[-a-zA-Z0-9@:%._+~#=]{2,256}.[a-z]{2,4}([-a-zA-Z0-9@:%_+.~#?&/=]*)';
2827
// to find variables in message
2928
export const pattern = /[^{}]+(?=})/g;
3029

@@ -131,12 +130,7 @@ export const GROUP_COLLECTION_SEARCH_QUERY_VARIABLES = {
131130
},
132131
};
133132

134-
export const setVariables = (
135-
filter: any = {},
136-
limit: any = null,
137-
offset: number = 0,
138-
order: string = 'ASC'
139-
) => ({
133+
export const setVariables = (filter: any = {}, limit: any = null, offset: number = 0, order: string = 'ASC') => ({
140134
filter,
141135
opts: {
142136
limit,
@@ -248,12 +242,7 @@ export const yupPasswordValidation = (t: any) =>
248242
export const WA_GROUPS_COLLECTION = 'WA';
249243
export const CONTACTS_COLLECTION = 'WABA';
250244

251-
export const getVariables = (
252-
contactOptions: any,
253-
messageOptions: any,
254-
variables: any,
255-
groups?: boolean
256-
) => {
245+
export const getVariables = (contactOptions: any, messageOptions: any, variables: any, groups?: boolean) => {
257246
const contactVariable: string = groups ? 'waGroupOpts' : 'contactOpts';
258247
const messageVariable: string = groups ? 'waMessageOpts' : 'messageOpts';
259248
return {

src/common/responsive.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ export const showMessages = () => {
88
export const showChats = () => {
99
if (window.innerWidth < 768) {
1010
document.querySelector('.chatMessages')?.setAttribute('style', 'display: none ');
11-
document
12-
.querySelector('.ChatConversations')
13-
?.setAttribute('style', 'display: block !important');
11+
document.querySelector('.ChatConversations')?.setAttribute('style', 'display: block !important');
1412
}
1513
};

src/common/utils.ts

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import { CONTACT_FRAGMENT } from 'graphql/mutations/Chat';
1515
import { SIMULATOR_NUMBER_START, STANDARD_DATE_TIME_FORMAT } from './constants';
1616
import { setNotification } from './notification';
1717

18-
export const isSimulator = (phone: string) =>
19-
phone ? phone.startsWith(SIMULATOR_NUMBER_START) : false;
18+
export const isSimulator = (phone: string) => (phone ? phone.startsWith(SIMULATOR_NUMBER_START) : false);
2019

2120
export const getObject = (arr: any, data: any) => {
2221
const result: any = [];
@@ -43,11 +42,7 @@ export { parseText as parseTextMethod };
4342
const validateMediaMethod = (URL: string, attachmentType: string, allowStickers: boolean = true) =>
4443
new Promise((resolve) => {
4544
// check if stickers are allowed instead of image, if not then return early
46-
if (
47-
!allowStickers &&
48-
attachmentType === 'IMAGE' &&
49-
URL.slice(-5).toLocaleLowerCase() === '.webp'
50-
) {
45+
if (!allowStickers && attachmentType === 'IMAGE' && URL.slice(-5).toLocaleLowerCase() === '.webp') {
5146
resolve({
5247
data: {
5348
is_valid: false,
@@ -58,12 +53,9 @@ const validateMediaMethod = (URL: string, attachmentType: string, allowStickers:
5853

5954
const encodedUrl = encodeURIComponent(URL);
6055
axios
61-
.get(
62-
`${FLOW_EDITOR_API}validate-media?url=${encodedUrl}&type=${attachmentType.toLowerCase()}`,
63-
{
64-
headers: { authorization: getAuthSession('access_token') },
65-
}
66-
)
56+
.get(`${FLOW_EDITOR_API}validate-media?url=${encodedUrl}&type=${attachmentType.toLowerCase()}`, {
57+
headers: { authorization: getAuthSession('access_token') },
58+
})
6759
.then((response: any) => {
6860
resolve(response);
6961
})
@@ -95,8 +87,7 @@ const checkSessionValidityMethod = async () => {
9587
export { checkSessionValidityMethod as checkSessionValidity };
9688

9789
// function to get the random number with min and max
98-
export const randomIntFromInterval = (min: number, max: number) =>
99-
Math.floor(Math.random() * (max - min + 1) + min);
90+
export const randomIntFromInterval = (min: number, max: number) => Math.floor(Math.random() * (max - min + 1) + min);
10091

10192
export const copyToClipboardMethod = (text: string) => {
10293
if (text) {
@@ -222,12 +213,8 @@ export const getAddOrRemoveRoleIds = (roles: any, payload: any) => {
222213
const initialSelectedRoles = roles.map((role: any) => role.id);
223214
const payloadRoleIds = payload.roles.map((role: any) => role.id);
224215

225-
let addRoleIds = payloadRoleIds.filter(
226-
(selectedRoles: any) => !initialSelectedRoles.includes(selectedRoles)
227-
);
228-
const deleteRoleIds = initialSelectedRoles.filter(
229-
(roleId: any) => !payloadRoleIds.includes(roleId)
230-
);
216+
let addRoleIds = payloadRoleIds.filter((selectedRoles: any) => !initialSelectedRoles.includes(selectedRoles));
217+
const deleteRoleIds = initialSelectedRoles.filter((roleId: any) => !payloadRoleIds.includes(roleId));
231218

232219
if (checkDynamicRole()) {
233220
const userRoles = getUserSession('roles').map((role: any) => role.id);

src/components/UI/DialogBox/DialogBox.test.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ const dialogBox = (
1616

1717
it('should not display dialog box if open is false', () => {
1818
const { queryByTestId } = render(
19-
<DialogBox
20-
open={false}
21-
title={'Are you sure?'}
22-
handleOk={mockCallbackOK}
23-
handleCancel={mockCallbackCancel}
24-
/>
19+
<DialogBox open={false} title={'Are you sure?'} handleOk={mockCallbackOK} handleCancel={mockCallbackCancel} />
2520
);
2621

2722
expect(queryByTestId('dialogBox')).toBe(null);
@@ -46,12 +41,7 @@ it('should check if callback method is called when confirm button is clicked', (
4641

4742
it('Dialogbox with no ok and cancel buttons', () => {
4843
const { container } = render(
49-
<DialogBox
50-
skipOk
51-
skipCancel
52-
title="Dialog with no action buttons"
53-
handleCancel={mockCallbackCancel}
54-
/>
44+
<DialogBox skipOk skipCancel title="Dialog with no action buttons" handleCancel={mockCallbackCancel} />
5545
);
5646
expect(container).toBeInTheDocument();
5747
});

src/components/UI/DialogBox/DialogBox.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,7 @@ export const DialogBox = ({
5454
let cancelButtonDisplay = null;
5555
if (!skipCancel) {
5656
cancelButtonDisplay = (
57-
<Button
58-
variant="outlined"
59-
onClick={() => handleCancel()}
60-
color={colorCancel}
61-
data-testid="cancel-button"
62-
>
57+
<Button variant="outlined" onClick={() => handleCancel()} color={colorCancel} data-testid="cancel-button">
6358
{buttonCancel}
6459
</Button>
6560
);
@@ -83,12 +78,7 @@ export const DialogBox = ({
8378

8479
if (buttonMiddle) {
8580
middleButtonDisplay = (
86-
<Button
87-
onClick={() => handleMiddle()}
88-
color="primary"
89-
variant="outlined"
90-
data-testid="middle-button"
91-
>
81+
<Button onClick={() => handleMiddle()} color="primary" variant="outlined" data-testid="middle-button">
9282
{buttonMiddle}
9383
</Button>
9484
);

src/components/UI/EmojiPicker/EmojiPicker.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ Object.defineProperty(window, 'matchMedia', {
2828
},
2929
});
3030

31-
const dialogBox = (
32-
<EmojiPicker displayStyle={{ width: '100%' }} onEmojiSelect={onEmojiSelectMock} />
33-
);
31+
const dialogBox = <EmojiPicker displayStyle={{ width: '100%' }} onEmojiSelect={onEmojiSelectMock} />;
3432

3533
test('it should render emoji picker', () => {
3634
const { getByTestId } = render(dialogBox);

0 commit comments

Comments
 (0)