-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #334 from glific/feature/add-contact-to-group
Feature/add contact to group
- Loading branch information
Showing
14 changed files
with
414 additions
and
57 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/components/UI/SearchDialogBox/SearchDialogBox.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
.DialogBox { | ||
width: 100%; | ||
} | ||
|
||
.Form { | ||
padding-top: 5px; | ||
padding-left: 4px; | ||
max-height: 260px; | ||
min-height: 100px; | ||
overflow: auto; | ||
} | ||
|
||
.Input { | ||
padding: 8px !important; | ||
font-size: 12px !important; | ||
} | ||
|
||
.SearchIcon { | ||
width: 13px; | ||
} | ||
|
||
.Outline { | ||
border-radius: 6px !important; | ||
border-width: 1px !important; | ||
border-color: #eaedec !important; | ||
} | ||
|
||
.DeleteIcon { | ||
width: 8px !important; | ||
margin-right: 13px !important; | ||
} | ||
|
||
.Paper > ul > li:hover { | ||
background-color: #edf6f2 !important; | ||
} | ||
|
||
.Autocomplete { | ||
margin-bottom: 10px !important; | ||
} | ||
|
||
.Paper > ul > li { | ||
color: #073f24; | ||
} |
26 changes: 26 additions & 0 deletions
26
src/components/UI/SearchDialogBox/SearchDialogBox.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
|
||
import { mount } from 'enzyme'; | ||
import { MockedProvider } from '@apollo/client/testing'; | ||
import { SearchDialogBox } from './SearchDialogBox'; | ||
|
||
const defaultProps = { | ||
title: 'Search Box', | ||
handleOk: jest.fn(), | ||
handleCancel: jest.fn(), | ||
options: [{ id: 1, label: 'something' }], | ||
selectedOptions: ['1'], | ||
}; | ||
const wrapper = mount( | ||
<MockedProvider> | ||
<SearchDialogBox {...defaultProps} /> | ||
</MockedProvider> | ||
); | ||
|
||
test('it should render the title correctly', () => { | ||
expect(wrapper.find('div[data-testid="dialogTitle"]').text()).toEqual('Search Box'); | ||
}); | ||
|
||
test('it should contain the selected option', () => { | ||
expect(wrapper.find('div[data-testid="searchChip"] span').text()).toEqual('something'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { DialogBox } from '../DialogBox/DialogBox'; | ||
import { FormControl, Paper, Chip, TextField } from '@material-ui/core'; | ||
import styles from './SearchDialogBox.module.css'; | ||
import { ReactComponent as DeleteIcon } from '../../../assets/images/icons/Close.svg'; | ||
import AutoComplete from '@material-ui/lab/Autocomplete'; | ||
import { ReactComponent as SearchIcon } from '../../../assets/images/icons/Search/Desktop.svg'; | ||
|
||
export interface SearchDialogBoxProps { | ||
title: string; | ||
handleOk: Function; | ||
handleCancel: Function; | ||
options: any; | ||
selectedOptions: any; | ||
} | ||
|
||
export const SearchDialogBox = (props: any) => { | ||
const [selectedOptions, setSelectedOptions] = useState<Array<string>>([]); | ||
|
||
useEffect(() => { | ||
setSelectedOptions(props.selectedOptions); | ||
}, [props.selectedOptions]); | ||
|
||
return ( | ||
<DialogBox | ||
title={props.title} | ||
handleOk={() => props.handleOk(selectedOptions)} | ||
handleCancel={props.handleCancel} | ||
titleAlign="left" | ||
buttonOk="Save" | ||
> | ||
<div className={styles.DialogBox}> | ||
<FormControl fullWidth> | ||
<AutoComplete | ||
className={styles.Autocomplete} | ||
PaperComponent={({ className, ...props }) => ( | ||
<Paper | ||
className={`${styles.Paper} ${className}`} | ||
{...props} | ||
data-testid="dialogInput" | ||
></Paper> | ||
)} | ||
value={props.options.filter((option: any) => | ||
selectedOptions.includes(option.id.toString()) | ||
)} | ||
renderTags={(value: any, getTagProps) => | ||
value.map((option: any, index: number) => ( | ||
<Chip | ||
data-testid="searchChip" | ||
style={{ backgroundColor: '#e2f1ea', color: '#073F24', fontSize: '16px' }} | ||
label={option.label} | ||
{...getTagProps({ index })} | ||
deleteIcon={<DeleteIcon className={styles.DeleteIcon} data-testid="deleteIcon" />} | ||
/> | ||
)) | ||
} | ||
multiple | ||
freeSolo | ||
onChange={(event, value: any) => { | ||
setSelectedOptions(value.map((option: any) => option.id)); | ||
}} | ||
options={props.options ? props.options : []} | ||
getOptionLabel={(option: any) => option.label} | ||
renderInput={(params) => ( | ||
<TextField {...params} variant="outlined" data-testid="dialogInput" label="Search" /> | ||
)} | ||
></AutoComplete> | ||
</FormControl> | ||
</div> | ||
</DialogBox> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.