This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import _ from 'lodash' | |
import { gql } from '@apollo/client' | |
const THROTTLE_CAP = 750 | |
const signFileUploadMutation = gql` | |
mutation SignFileUpload ( | |
$fileName: String! | |
$type: FileUploadType! | |
) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const removeImage = publicId => new Promise((resolve, reject) => { | |
cloudinary.v2.uploader.destroy(publicId, error => { | |
if (error) { | |
return reject(error) | |
} | |
resolve() | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createReducer(initialState, handlers) { | |
return function reducer(state = initialState, action) { | |
if (handlers.hasOwnProperty(action.type)) { | |
return handlers[action.type](state, action) | |
} | |
return state | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { injectReducer } from 'common/reducers' | |
import * as Routes from 'constants/Routes' | |
import { toggleLoader } from 'common/actions/loader' | |
export default (store) => ({ | |
path: Routes.LOGIN, | |
getComponent: async function (nextState, cb) { | |
store.dispatch(toggleLoader(true)) | |
const [module, reducer] = await Promise.all([ | |
import('./containers/LoginContainer'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Old | |
export const appRoutes = ( | |
<div> | |
<Route path="companies/:companyId" component={CompanyNavigation} > | |
<IndexRoute component={CompanyProjectsContainer} /> // TODO: Dashboard? | |
<Route path="projects" component={CompanyProjectsContainer} /> | |
<Route path="users" component={CompanyUsersContainer} /> | |
<Route path="divisions" component={CompanyDivisionsContainer} /> | |
<Route path="activities" component={CompanyActivitiesContainer} /> | |
</Route> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// [email protected] | |
// | |
// For this solution, when a project has lodash, I would suggest to use `flattenDeep` @ https://lodash.com/docs/4.17.4#flattenDeep | |
// But ofcourse, a manual util function is easily written: | |
const nestedArray = [1, [2, 3], [4, 5, [6, 7]], 8] | |
function flattenArray (nestedArray) { | |
let flatArray = [] |