Skip to content

Commit

Permalink
Merge branch 'master' into template-flows-keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
kurund authored Oct 1, 2024
2 parents 926ecb8 + 7c5cbea commit 855c6ef
Show file tree
Hide file tree
Showing 5 changed files with 822 additions and 1,408 deletions.
59 changes: 28 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "glific-frontend",
"version": "6.1.7",
"version": "6.1.8",
"private": true,
"type": "module",
"dependencies": {
"@apollo/client": "^3.11.5",
"@apollo/client": "^3.11.8",
"@apollo/link-context": "^2.0.0-beta.3",
"@apollo/link-error": "^2.0.0-beta.3",
"@appsignal/javascript": "^1.3.30",
"@appsignal/javascript": "^1.3.31",
"@appsignal/plugin-breadcrumbs-network": "^1.1.22",
"@appsignal/plugin-path-decorator": "^1.0.16",
"@appsignal/plugin-window-events": "^1.0.22",
Expand All @@ -19,50 +19,49 @@
"@emotion/styled": "^11.13.0",
"@glific/flow-editor": "^1.26.3-12",
"@lexical/react": "^0.17.1",
"@mui/icons-material": "^6.0.0",
"@mui/material": "^6.0.0",
"@mui/x-date-pickers": "^7.14.0",
"@nyaruka/temba-components": "^0.104.1",
"@mui/icons-material": "^6.1.1",
"@mui/material": "^6.1.1",
"@mui/x-date-pickers": "^7.18.0",
"@nyaruka/temba-components": "^0.108.1",
"@stripe/react-stripe-js": "^2.8.0",
"@stripe/stripe-js": "^4.4.0",
"@types/jest": "^29.5.12",
"@stripe/stripe-js": "^4.5.0",
"@vitejs/plugin-react": "^4.3.1",
"apollo-absinthe-upload-link": "^1.7.0",
"apollo-link-token-refresh": "^0.7.0",
"axios": "^1.7.5",
"axios": "^1.7.7",
"buffer": "^6.0.3",
"dayjs": "^1.11.13",
"emoji-mart": "^5.6.0",
"formik": "^2.4.6",
"graphql": "^16.9.0",
"graphql-ws": "^5.16.0",
"i18next": "^23.14.0",
"i18next": "^23.15.1",
"i18next-browser-languagedetector": "^8.0.0",
"interweave": "^13.1.0",
"interweave-autolink": "^5.1.1",
"lexical": "^0.17.1",
"lexical-beautiful-mentions": "^0.1.40",
"pino": "^9.3.2",
"lexical-beautiful-mentions": "^0.1.41",
"pino": "^9.4.0",
"pino-logflare": "^0.4.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-draggable": "^4.4.6",
"react-google-recaptcha-v3": "^1.10.1",
"react-i18next": "^15.0.1",
"react-i18next": "^15.0.2",
"react-image": "^4.1.0",
"react-media-recorder": "^1.7.0",
"react-media-recorder": "^1.7.1",
"react-phone-input-2": "^2.15.1",
"react-player": "^2.16.0",
"react-resize-detector": "^11.0.1",
"react-router-dom": "^6.26.1",
"react-router-dom": "^6.26.2",
"react-tiny-link": "^3.6.1",
"react-viewer": "^3.2.2",
"rollup-plugin-polyfill-node": "^0.13.0",
"stream-browserify": "^3.0.0",
"util": "^0.12.5",
"uuid": "^10.0.0",
"vite": "^5.4.2",
"vite-plugin-checker": "^0.7.2",
"vite": "^5.4.8",
"vite-plugin-checker": "^0.8.0",
"vite-plugin-svgr": "^4.2.0",
"vite-tsconfig-paths": "^5.0.1",
"yup": "^1.4.0"
Expand Down Expand Up @@ -101,34 +100,32 @@
"devDependencies": {
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.0",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/draft-js": "^0.11.18",
"@types/emoji-mart": "^3.0.14",
"@types/node": "^22.5.1",
"@types/react": "^18.3.4",
"@types/node": "^22.7.2",
"@types/react": "^18.3.9",
"@types/react-dom": "^18.3.0",
"@types/react-google-recaptcha": "^2.1.9",
"@types/react-router": "^5.1.20",
"@types/react-router-dom": "^5.3.3",
"@types/react-test-renderer": "^18.3.0",
"@types/uuid": "^10.0.0",
"@vitest/coverage-istanbul": "^2.0.5",
"@vitest/ui": "^2.0.5",
"@vitest/coverage-istanbul": "^2.1.1",
"@vitest/ui": "^2.1.1",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.9.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-jsx-a11y": "^6.10.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react": "^7.36.1",
"eslint-plugin-react-hooks": "^4.6.2",
"i18next-parser": "^9.0.2",
"jsdom": "^25.0.0",
"jsdom": "^25.0.1",
"prettier": "^3.3.3",
"react-test-renderer": "^18.3.1",
"typescript": "^5.5.4",
"vite-plugin-eslint": "^1.8.1",
"vitest": "^2.0.5",
"typescript": "^5.6.2",
"vitest": "^2.1.1",
"yarn-upgrade-all": "^0.7.4"
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import { useEffect, useState } from 'react';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';

import {
CONTACT_SEARCH_QUERY,
GET_CONTACTS_LIST,
GET_CONTACT_COUNT,
} from 'graphql/queries/Contact';
import { CONTACT_SEARCH_QUERY, GET_CONTACT_COUNT } from 'graphql/queries/Contact';
import { UPDATE_COLLECTION_CONTACTS } from 'graphql/mutations/Collection';
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
import DeleteIcon from 'assets/images/icons/Delete/Red.svg?react';
import CollectionIcon from 'assets/images/icons/Collection/Dark.svg?react';
import { List } from 'containers/List/List';
import styles from './CollectionContactList.module.css';
import { useLazyQuery, useMutation } from '@apollo/client';
import { setVariables } from 'common/constants';
import { SearchDialogBox } from 'components/UI/SearchDialogBox/SearchDialogBox';
import { useMutation } from '@apollo/client';
import { Button } from 'components/UI/Form/Button/Button';
import { getContactStatus, getDisplayName } from 'common/utils';
import { DialogBox } from 'components/UI/DialogBox/DialogBox';
import { setNotification } from 'common/notification';
import AddToCollection from 'containers/Chat/ChatMessages/AddToCollection/AddToCollection';

export interface CollectionContactListProps {
title: string;
Expand Down Expand Up @@ -72,43 +67,18 @@ export const CollectionContactList = ({
}: CollectionContactListProps) => {
const [addContactsDialogShow, setAddContactsDialogShow] = useState(false);
const [removeContactsDialogShow, setRemoveContactsDialogShow] = useState(false);
const [contactSearchTerm, setContactSearchTerm] = useState('');
const [selectedContacts, setSelectedContact] = useState<any>([]);
const [contactsToRemove, setContactsToRemove] = useState<any>([]);
const [contactOptions, setContactOptions] = useState<any>([]);
const [updateCollection, setUpdateCollection] = useState(false);

const { t } = useTranslation();
const params = useParams();

const collectionId = params.id;
let dialog;

const [getContacts, { data: contactsData }] = useLazyQuery(GET_CONTACTS_LIST, {
fetchPolicy: 'cache-and-network',
});

const [updateCollectionContacts] = useMutation(UPDATE_COLLECTION_CONTACTS);

const handleCollectionAdd = (selectedContacts: any) => {
if (selectedContacts.length === 0) {
setAddContactsDialogShow(false);
} else {
updateCollectionContacts({
variables: {
input: {
addContactIds: selectedContacts,
groupId: collectionId,
deleteContactIds: [],
},
},
onCompleted: () => {
setNotification(t('Contact has been added successfully to the collection.'), 'success');
},
});
}
setAddContactsDialogShow(false);
};

const handleCollectionRemove = () => {
const idsToRemove = selectedContacts.map((collection: any) => collection.id);
updateCollectionContacts({
Expand All @@ -121,6 +91,7 @@ export const CollectionContactList = ({
},
onCompleted: () => {
setNotification(t('Contact has been removed successfully from the collection.'), 'success');
setUpdateCollection(!updateCollection);
},
});
setRemoveContactsDialogShow(false);
Expand All @@ -132,36 +103,14 @@ export const CollectionContactList = ({
setSelectedContact(selectedContacts);
};

useEffect(() => {
if (contactsData) {
setContactOptions(contactsData.contacts);
}
}, [contactsData]);

if (addContactsDialogShow) {
dialog = (
<SearchDialogBox
title={t('Add contacts to collection')}
handleOk={handleCollectionAdd}
handleCancel={() => setAddContactsDialogShow(false)}
options={contactOptions}
optionLabel="name"
additionalOptionLabel="phone"
asyncSearch
colorOk="primary"
buttonOk="Add"
disableClearable
searchLabel="Search contacts"
textFieldPlaceholder="Type here"
onChange={(value: any) => {
if (typeof value === 'string') {
setContactSearchTerm(value);
}
<AddToCollection
collectionId={collectionId}
setDialog={setAddContactsDialogShow}
afterAdd={() => {
setUpdateCollection(!updateCollection);
}}
selectedOptions={[]}
fullWidth={true}
showTags={false}
placeholder="Select contacts"
/>
);
}
Expand Down Expand Up @@ -193,9 +142,6 @@ export const CollectionContactList = ({
color="primary"
data-testid="addBtn"
onClick={() => {
getContacts({
variables: setVariables({ name: contactSearchTerm, excludeGroups: collectionId }, 50),
});
setAddContactsDialogShow(true);
}}
>
Expand Down Expand Up @@ -245,6 +191,7 @@ export const CollectionContactList = ({
}}
{...queries}
{...columnAttributes}
refreshList={updateCollection}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const mocks = [
countGroups,
getGroupsCollectionList(getCollectionsVariables),
getGroupsCollectionList(getCollectionsVariables),
getGroupsSearchQuery(setVariables({ excludeGroups: '1' }, 50)),
getGroupsSearchQuery(setVariables({ excludeGroups: '1', term: '' }, 50)),
getGroupsSearchQuery(setVariables({ excludeGroups: '1' }, 50)),
updateCollectionWaGroupQuery({
input: { addWaGroupIds: ['1'], groupId: '1', deleteWaGroupIds: [] },
Expand Down
Loading

0 comments on commit 855c6ef

Please sign in to comment.