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

Added update & create collection button #368

Merged
merged 17 commits into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions src/components/UI/Form/Calendar/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ export const Calendar: React.SFC<CalendarProps> = ({
const dateValue = field.value ? moment(field.value, moment.defaultFormat).toDate() : null;
// const defaultDateValue = field.value ? field.value : setFieldValue(field.name, '');

const handleDateChange = (date: Date | null) => {
const handleDateChange = (date: Date | null | string) => {
if (date) {
setFieldValue(field.name, date);
if (date !== 'Invalid Date') setFieldValue(field.name, date);
} else {
setFieldValue(field.name, null);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/UI/SearchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const SearchBar: React.SFC<SearchBarProps> = (props) => {
<IconButton
aria-label="toggle password visibility"
onClick={(e: any) => {
props.handleClick(e, 'search');
props.handleClick(e, 'search', 'update');
}}
>
<AdvancedSearch />
Expand Down
8 changes: 7 additions & 1 deletion src/components/UI/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ interface TooltipProps {
title: String;
placement: TooltipElement.TooltipProps['placement'];
children: ReactNode;
tooltipClass?: string;
}

export const Tooltip: React.SFC<TooltipProps> = (props: TooltipProps) => {
return (
<TooltipElement.default title={props.title} placement={props.placement} arrow>
<TooltipElement.default
title={props.title}
placement={props.placement}
arrow
classes={{ tooltip: props.tooltipClass }}
>
<div>{props.children}</div>
</TooltipElement.default>
);
Expand Down
25 changes: 12 additions & 13 deletions src/containers/Chat/ChatConversations/ChatConversations.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,13 @@
}

.SaveCollection {
margin: 6%;
margin: 0% 6%;
position: absolute;
width: 100%;
bottom: 3%;
background-color: #fff;
border: 1px solid rgba(17, 150, 86, 0.5);
border-radius: 25px;
width: fit-content;
width: 85%;
height: 10% !important;
bottom: 15px;
width: -moz-fit-content;
height: 48px;
text-align: center !important;
}

.button {
border: unset !important;
padding: 0px !important;
}

.cancelButton {
Expand All @@ -57,4 +49,11 @@

.container {
padding: 10px !important;
display: flex;
justify-content: center;
}

.tooltipClass {
background-color: #073f24 !important;
width: 150px !important;
}
161 changes: 50 additions & 111 deletions src/containers/Chat/ChatConversations/ChatConversations.test.helper.ts
Original file line number Diff line number Diff line change
@@ -1,137 +1,76 @@
import { mocks as SAVED_SEARCH_MOCK } from '../../SavedSearch/SavedSearchToolbar/SavedSearchToolbar.test';
import { SEARCH_QUERY } from '../../../graphql/queries/Search';
import { conversationQuery } from '../Chat.test.helper';

const searchQuery = (messageLimit: number, contactLimit: number, filter: any) => {
return {
request: {
query: SEARCH_QUERY,
variables: {
filter: filter,
messageOpts: { limit: messageLimit },
contactOpts: { limit: contactLimit },
},
},
result: {
data: {
search: [
const withResult = {
data: {
search: [
{
__typename: 'Conversation',
contact: {
id: '6',
name: 'Red Sparrow',
phone: '919520285543',
lastMessageAt: '2020-08-03T07:01:36Z',
},
messages: [
{
contact: {
id: '34',
body: 'Hi',
insertedAt: '2020-08-03T07:01:36Z',
receiver: {
id: '2',
},
sender: {
id: '6',
name: 'Red Sparrow',
phone: '919520285543',
lastMessageAt: '2020-08-03T07:01:36Z',
},
messages: [
tags: [
{
body: 'Hi',
id: '34',
insertedAt: '2020-08-03T07:01:36Z',
receiver: {
id: '2',
},
sender: {
id: '6',
},
tags: [
{
id: '8',
label: 'Not working',
colorCode: '#00d084',
parent: null,
},
],
id: '8',
label: 'Not working',
colorCode: '#00d084',
parent: null,
},
],
},
],
},
},
};
],
},
};
export const chatConversationsMocks = [
{

const noResult = { data: { search: [] } };

const searchQuery = (
messageLimit: number,
contactLimit: number,
filter: any,
showResult: boolean = true
) => {
return {
request: {
query: SEARCH_QUERY,
variables: { contactOpts: { limit: 25 }, filter: { id: '2' }, messageOpts: { limit: 25 } },
},
result: {
data: {
conversation: {
contact: {
id: '2',
name: 'Jane Doe',
phone: '919520285543',
lastMessageAt: '2020-08-03T07:01:36Z',
},
messages: [
{
id: '1',
body: 'Hey there whats up?',
insertedAt: '2020-06-25T13:36:43Z',
receiver: {
id: '1',
},
sender: {
id: '2',
},
tags: [
{
id: '1',
label: 'important',
colorCode: null,
parent: null,
},
],
},
],
},
variables: {
filter: filter,
messageOpts: { limit: messageLimit },
contactOpts: { limit: contactLimit },
},
},
},
result: showResult ? withResult : noResult,
};
};

export const chatConversationsMocks = [
searchQuery(50, 50, {}),
searchQuery(50, 50, { term: 'a' }),
searchQuery(50, 50, { term: 'a' }, false),
searchQuery(50, 50, { term: '' }),
searchQuery(5, 10, { includeTags: ['12'] }),
searchQuery(5, 10, { term: '', includeTags: ['12'] }),
];

export const searchQueryMock = searchQuery(50, 50, { term: '' });
export const searchQueryEmptyMock = searchQuery(50, 50, {});

export const conversations = [
{
contact: {
id: '6',
name: 'Red Eye',
phone: '919520225543',
lastMessageAt: '2020-08-03T07:01:36Z',
},
messages: [
{
id: '34',
body: 'Hi',
insertedAt: '2020-08-03T07:01:36Z',
receiver: {
id: '1',
},
sender: {
id: '6',
},
tags: [
{
id: '8',
label: 'Not replied',
},
],
},
],
},
searchQuery(5, 10, { includeTags: ['12'] }, false),
];

export const ChatConversationMocks = [
...chatConversationsMocks,
...chatConversationsMocks,
...SAVED_SEARCH_MOCK,
conversationQuery,
];

export const searchQueryMock = searchQuery(50, 50, { term: '' });
export const searchQueryEmptyMock = searchQuery(50, 50, {});
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import { render, wait, fireEvent } from '@testing-library/react';
import { render, wait, fireEvent, cleanup } from '@testing-library/react';
import ChatConversations from './ChatConversations';
import { MockedProvider } from '@apollo/client/testing';
import { ChatConversationMocks, conversations } from './ChatConversations.test.helper';
import { ChatConversationMocks } from './ChatConversations.test.helper';

const mocks = ChatConversationMocks;

afterEach(cleanup);
const chatConversation = (
<MockedProvider mocks={mocks} addTypename={false}>
<MockedProvider mocks={mocks}>
<Router>
<ChatConversations contactId={2} />
<ChatConversations contactId={6} />
</Router>
</MockedProvider>
);
Expand Down
Loading