2018-11-30 07:37:36 +00:00
|
|
|
const initialState = {
|
|
|
|
documentTitle: '',
|
|
|
|
search: '',
|
|
|
|
colorPicker: '',
|
2019-08-10 15:28:32 +00:00
|
|
|
noteMediaSelection: [],
|
2019-08-03 02:24:24 +00:00
|
|
|
uploadFile: undefined,
|
|
|
|
s3Path: undefined
|
2018-11-30 07:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const inputs = (state=initialState, action) => {
|
|
|
|
switch(action.type) {
|
|
|
|
// Document Title
|
|
|
|
case 'GET_DOCUMENT_TEXT':
|
2019-08-03 02:24:24 +00:00
|
|
|
if (action.status === 'success' && action.state === 'currentDocument' && ['tags', 'media'].indexOf(action.docType) <= 0 ) {
|
2018-11-30 07:37:36 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
documentTitle: action.data.title
|
|
|
|
}
|
2019-08-03 02:24:24 +00:00
|
|
|
} else if (action.status === 'success' && action.docType === 'tags') {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
documentTitle: action.data.title,
|
|
|
|
colorPicker: action.data.color
|
|
|
|
}
|
|
|
|
} else if (action.status === 'success' && action.state === 'currentDocument' && action.docType === 'media') {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
documentTitle: action.data.title,
|
|
|
|
s3Path: action.data.s3Path
|
|
|
|
}
|
2018-11-30 07:37:36 +00:00
|
|
|
} else { return state }
|
|
|
|
case 'CREATE_DOCUMENT':
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
documentTitle: ''
|
|
|
|
}
|
|
|
|
case 'UPDATE_DOCUMENT_TITLE':
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
documentTitle: action.data
|
|
|
|
}
|
|
|
|
// Search
|
|
|
|
case 'UPDATE_SEARCH_INPUT':
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
search: action.data
|
|
|
|
}
|
|
|
|
// Color Picker
|
2019-07-28 20:16:59 +00:00
|
|
|
case 'SAVE_DOCUMENT':
|
|
|
|
if (action.status === 'success' && action.docType === 'tags') {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
colorPicker: ''
|
|
|
|
}
|
|
|
|
} else { return state }
|
2018-11-30 07:37:36 +00:00
|
|
|
case 'CREATE_DOCUMENT':
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
colorPicker: ''
|
|
|
|
}
|
|
|
|
case 'SELECT_COLOR_SWATCH':
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
colorPicker: action.data
|
|
|
|
}
|
|
|
|
case 'UPDATE_COLOR_PICKER':
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
colorPicker: action.data.toUpperCase()
|
|
|
|
}
|
2019-07-30 04:42:50 +00:00
|
|
|
// Media Upload
|
|
|
|
case 'UPDATE_MEDIA_INPUT':
|
|
|
|
return {
|
|
|
|
...state,
|
2019-08-03 02:24:24 +00:00
|
|
|
uploadFile: action.data
|
2019-07-30 04:42:50 +00:00
|
|
|
}
|
2019-08-03 02:24:24 +00:00
|
|
|
// S3 File
|
|
|
|
case 'UPLOAD_TO_S3_RESPONSE':
|
|
|
|
if (action.status === 'success') {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
s3Path: action.url
|
|
|
|
}
|
|
|
|
} else { return state }
|
2019-08-10 15:28:32 +00:00
|
|
|
case 'CLEAR_LOADED_MEDIA':
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
s3Path: undefined
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return state
|
2018-11-30 07:37:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default inputs
|