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

Feature/add contact to group #334

Merged
merged 16 commits into from
Aug 22, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
12 changes: 12 additions & 0 deletions src/assets/images/icons/Block.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/assets/images/icons/Configure/Configure.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/assets/images/icons/Contact/Light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 13 additions & 3 deletions src/components/UI/DialogBox/DialogBox.module.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
.DialogboxPaper {
border-radius: 24px !important;
margin: 0px !important;
margin-top: 66px !important;
width: 395px !important ;
}

.ScrollPaper {
align-items: unset !important;
}
.Dialogbox {
max-width: 459px;
min-width: 459px;
width: 459px;
margin: 0 auto;
height: unset !important;
}
Expand All @@ -21,6 +22,15 @@
.DialogTitle {
color: #073f24;
padding-top: 24px !important;
text-align: center;
padding-bottom: 8px !important;
}

.DialogTitleCenter {
composes: DialogTitle;
text-align: center;
}

.DialogTitleLeft {
composes: DialogTitle;
text-align: left;
}
9 changes: 8 additions & 1 deletion src/components/UI/DialogBox/DialogBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface DialogProps {
children?: ReactNode;
buttonOk?: string;
buttonCancel?: string;
titleAlign?: string;
colorOk?: 'inherit' | 'primary' | 'secondary' | 'default' | undefined;
colorCancel?: 'inherit' | 'primary' | 'secondary' | 'default' | undefined;
alignButtons?: string;
Expand All @@ -31,6 +32,7 @@ export const DialogBox: React.SFC<DialogProps> = ({
colorOk = 'primary',
colorCancel = 'default',
alignButtons,
titleAlign = 'center',
skipCancel = false,
}) => {
const handleCancelButton = () => {
Expand All @@ -55,6 +57,11 @@ export const DialogBox: React.SFC<DialogProps> = ({
);
}

let titleStyle = styles.DialogTitleCenter;
if (titleAlign === 'left') {
titleStyle = styles.DialogTitleLeft;
}

return (
<div>
<Dialog
Expand All @@ -69,7 +76,7 @@ export const DialogBox: React.SFC<DialogProps> = ({
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
>
<DialogTitle id="alert-dialog-title" className={styles.DialogTitle}>
<DialogTitle id="alert-dialog-title" className={titleStyle}>
{title}
</DialogTitle>
<DialogContent>{children}</DialogContent>
Expand Down
38 changes: 38 additions & 0 deletions src/components/UI/SearchDialogBox/SearchDialogBox.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.DialogBox {
width: 100%;
}

.Form {
padding-top: 5px;
padding-left: 4px;
max-height: 260px;
min-height: 100px;
overflow: auto;
}
.Label {
color: #073f24 !important;
font-size: 16px !important;
padding-left: 6px !important;
font-weight: 500;
line-height: 1.25 !important;
}

.Label input::placeholder {
color: #93a29b !important;
font-weight: 500 !important;
}

.Input {
padding: 8px !important;
font-size: 12px !important;
}

.SearchIcon {
width: 13px;
}

.Outline {
border-radius: 6px !important;
border-width: 1px !important;
border-color: #eaedec !important;
}
94 changes: 94 additions & 0 deletions src/components/UI/SearchDialogBox/SearchDialogBox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import React, { useState, useEffect } from 'react';
import { DialogBox } from '../DialogBox/DialogBox';
import {
FormControl,
InputLabel,
OutlinedInput,
InputAdornment,
Checkbox,
FormControlLabel,
} from '@material-ui/core';
import styles from './SearchDialogBox.module.css';
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 [search, setSearch] = useState('');
const [selectedOptions, setSelectedOptions] = useState<Array<string>>([]);

useEffect(() => {
setSelectedOptions(props.selectedOptions);
}, [props.selectedOptions]);

const handleCheckboxChange = (event: any) => {
const optionId = event.target.id;
const index = selectedOptions.indexOf(optionId.toString());
if (index > -1) {
setSelectedOptions(selectedOptions.filter((option) => option !== optionId));
} else {
setSelectedOptions([...selectedOptions, event.target.id]);
}
};

let optionsList = null;
optionsList = props.options.map((option: any) => {
if (option.label.toLowerCase().includes(search)) {
return (
<div>
<FormControlLabel
className={styles.Label}
control={
<Checkbox
checked={selectedOptions.includes(option.id)}
color="primary"
id={option.id}
onChange={handleCheckboxChange}
/>
}
label={option.label}
/>
</div>
);
}
});
return (
<DialogBox
title={props.title}
handleOk={() => props.handleOk(selectedOptions)}
handleCancel={props.handleCancel}
titleAlign="left"
buttonOk="Save"
>
<div className={styles.DialogBox}>
<FormControl fullWidth>
<OutlinedInput
classes={{
input: styles.Input,
notchedOutline: styles.Outline,
}}
data-testid="tagSearch"
className={styles.Label}
fullWidth
placeholder="Search"
onChange={(event) => setSearch(event.target.value)}
startAdornment={
<InputAdornment position="start">
<SearchIcon className={styles.SearchIcon} />
</InputAdornment>
}
/>
</FormControl>
<div>
<form className={styles.Form}>{optionsList}</form>
</div>
</div>
</DialogBox>
);
};
1 change: 1 addition & 0 deletions src/containers/Chat/ChatMessages/ChatMessages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ export const ChatMessages: React.SFC<ChatMessagesProps> = ({ contactId }) => {
? conversationInfo.contact.name
: conversationInfo.contact.phone
}
contactId={contactId.toString()}
/>
{messageListContainer}
<ChatInput handleHeightChange={handleHeightChange} onSendMessage={sendMessageHandler} />
Expand Down
55 changes: 55 additions & 0 deletions src/containers/Chat/ChatMessages/ContactBar/ContactBar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,58 @@
font-size: 20px !important;
color: #073f24;
}

.Configure {
cursor: pointer;
margin-left: auto;
}

.Configure > :first-child {
width: 21px !important;
height: 21px !important;
}

.Popper {
z-index: 1500;
}

.Popper button {
padding: 5px 30px 5px 10px !important;
text-transform: none !important;
}

.Popper > div:first-child {
padding-top: 10px !important;
}

.Popper > div:last-child {
padding-bottom: 10px !important;
}

.ListButton {
width: 100% !important;
font-weight: 400 !important;
font-size: 16px !important;
justify-content: flex-start !important;
}

.ListButton:hover {
background-color: #edf6f2 !important;
}

.Link {
text-decoration: none;
}

.Icon {
margin-right: 16px;
}

.ListButtonPrimary {
composes: ListButton;
color: #073f24 !important;
}

.Container {
margin-top: 6px;
}
12 changes: 9 additions & 3 deletions src/containers/Chat/ChatMessages/ContactBar/ContactBar.test.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import React from 'react';

import { shallow } from 'enzyme';
import { mount } from 'enzyme';
import { MockedProvider } from '@apollo/client/testing';
import ContactBar from './ContactBar';

describe('<ContactBar />', () => {
const defaultProps = {
contactName: 'Jane Doe',
contactId: '2',
};
const wrapper = shallow(<ContactBar {...defaultProps} />);
const wrapper = mount(
<MockedProvider>
<ContactBar {...defaultProps} />
</MockedProvider>
);

test('it should render the name correctly', () => {
expect(wrapper.find('[data-testid="beneficiaryName"]').text()).toEqual('Jane Doe');
expect(wrapper.find('h6[data-testid="beneficiaryName"]').text()).toEqual('Jane Doe');
});
});
Loading