Skip to content
Open
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
37 changes: 35 additions & 2 deletions src/components/CallLog.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ import Paper from 'material-ui/Paper';
import { compose, getContext, withHandlers, withPropsOnChange, lifecycle } from 'recompose';
import { CALL_STATUS_IDLE } from 'react-sip';
import { connect } from 'react-redux';
import List, { ListItem, ListItemText, ListSubheader } from 'material-ui/List';
import List, {
ListItem,
ListItemText,
ListSubheader,
ListItemSecondaryAction,
} from 'material-ui/List';
import ThumbUpIcon from 'material-ui-icons/ThumbUp';
import ThumbDownIcon from 'material-ui-icons/ThumbDown';
import IconButton from 'material-ui/IconButton';

const timeago = require('timeago.js');

Expand Down Expand Up @@ -39,7 +47,7 @@ const Wrapper = styled(Paper).attrs({
display: flex;
`;

const DialLog = ({ entries, onListItemClick, allowListItemClicks }) => (
const DialLog = ({ entries, onListItemClick, allowListItemClicks, onFeedbackButtonClick }) => (
<Wrapper>
<List subheader={<ListSubheader>Your Call Log</ListSubheader>}>
{_.map(entries, (entry, i) => (
Expand All @@ -53,6 +61,24 @@ const DialLog = ({ entries, onListItemClick, allowListItemClicks }) => (
primary={entry.phoneNumber}
secondary={timeagoInstance.format(entry.startTimestamp, 'custom')}
/>
<ListItemSecondaryAction>
<IconButton
data-value={entry.feedback === 'positive' ? undefined : 'positive'}
data-itemindex={i}
color={entry.feedback === 'positive' ? 'primary' : undefined}
onClick={onFeedbackButtonClick}
>
<ThumbUpIcon />
</IconButton>
<IconButton
data-value={entry.feedback === 'negative' ? undefined : 'negative'}
data-itemindex={i}
color={entry.feedback === 'negative' ? 'accent' : undefined}
onClick={onFeedbackButtonClick}
>
<ThumbDownIcon />
</IconButton>
</ListItemSecondaryAction>
</ListItem>
))}
</List>
Expand Down Expand Up @@ -91,5 +117,12 @@ export default compose(
value: e.currentTarget.dataset['phonenumber'],
});
},
onFeedbackButtonClick: ({ dispatch }) => (e) => {
dispatch({
type: 'callLog/SET_FEEDBACK',
itemIndex: e.currentTarget.dataset['itemindex'] * 1,
value: e.currentTarget.dataset['value'],
});
},
}),
)(DialLog);
15 changes: 15 additions & 0 deletions src/redux/callLog/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ export default (state = initialState, action) => {
});
}

case 'callLog/SET_FEEDBACK': {
if (!action.value) {
return update(state, {
entries: {
[action.itemIndex]: { $unset: ['feedback'] },
},
});
}
return update(state, {
entries: {
[action.itemIndex]: { feedback: { $set: action.value } },
},
});
}

default:
return state;
}
Expand Down