Skip to content
8 changes: 8 additions & 0 deletions src/actions/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ export const addNetworkListToContact = (networkListId, contactId) => {
}
}
}

export const CURRENT_SORT_CONTACT = 'CURRENT_SORT_CONTACT'
export const currentSortContact = (currentContact) => {
return {
type: CURRENT_SORT_CONTACT,
payload: currentContact
}
}
20 changes: 9 additions & 11 deletions src/components/sortContact/SortContactContainer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { PureComponent, PropTypes } from 'react'
import { connect } from 'react-redux'
import { submit } from 'redux-form'
import { updateContact } from '../../actions/contacts'
import { updateContact, currentSortContact } from '../../actions/contacts'
import {formFieldsContactDetails as formFields} from '../../helpers/formData'
import Media from 'react-media'
import ZeroContacts from './ZeroContacts'
Expand Down Expand Up @@ -33,6 +33,10 @@ class SortContactContainer extends PureComponent {
contacts: PropTypes.array.isRequired,
addedContactIds: PropTypes.array.isRequired
}
componentWillMount() {
console.log('WILLMOUNT')
this.getOneContact()
}

componentDidMount () {
window.addEventListener('keydown', this.handleContainerKeyPress)
Expand Down Expand Up @@ -63,6 +67,7 @@ class SortContactContainer extends PureComponent {
return contacts.filter((contact, index) => {
return index === contactIndex
})

}

onSubmit (values, dispatch, props) {
Expand Down Expand Up @@ -124,16 +129,9 @@ class SortContactContainer extends PureComponent {
)
}

// NOTE i need to create renderHintText function that i will pass to HintFooter which will show different mila hints if a user clicks on next contact.

// renderHintText() {
// const hints = ['Tip #1: Use keyboard shortcuts to sort contacts faster!', 'Tip #2: Use left and right arrow keys to sort next contact']
//
// }

render () {
const { curContactNumb, totalContacts, completedProgress, snackOpen } = this.state
// if (this.props.contacts === []) return <ZeroContacts />

return (
<div className='sort-contact-wrapper'>
<div className='progress-indicator-wrapper'>
Expand Down Expand Up @@ -168,7 +166,6 @@ class SortContactContainer extends PureComponent {
hintText='hint-text'/>
)}/>


</div>
)
}
Expand All @@ -177,7 +174,8 @@ class SortContactContainer extends PureComponent {
const mapStateToProps = (state) => {
return {
contacts: state.contacts,
addedContactIds: state.sortContact.addedContactIds
addedContactIds: state.sortContact.addedContactIds,
currentContact: state.sortContact.theOneContact
}
}

Expand Down
1 change: 0 additions & 1 deletion src/reducers/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ export default function contacts(state = initialState, { type, payload } = {}) {
switch (type) {

case UPDATE_CONTACT :

return state.map((contact) => {
if (contact.id === payload.contactId) {
const updatedContactAttributes = payload.contactFields
Expand Down
1 change: 1 addition & 0 deletions src/reducers/networklists.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const networklists = (state = initialState, action) => {
// console.log(action.payload, 'networklists action.payload')
// const newNetworkList = Object.assign({}, action.payload)
// return [newNetworkList].concat(state)
// NOTE: maybe we can use {type, payload} = {} as params
return [
...state,
networklist(undefined, action)
Expand Down
9 changes: 8 additions & 1 deletion src/reducers/sortContactReducer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ADD_CONTACT_TO_NETWORKLIST } from '../actions/networklists'
import { CURRENT_SORT_CONTACT } from '../actions/contacts'

const initialState = {
addedContactIds: []
addedContactIds: [],
theOneContact: []
}

export default function sortContactReducer(state = initialState, { type, payload } = {}) {
Expand All @@ -12,6 +14,11 @@ export default function sortContactReducer(state = initialState, { type, payload
}
return { ...state, addedContactIds: [...state.addedContactIds, payload.contactId] }

case CURRENT_SORT_CONTACT:
// newCurrentContact = Object.assign({}, payload)
// return [newCurrentContact].concat(state)
return {...state, theOneContact: payload}

default:
return state

Expand Down