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 React, { Component } from 'react' | |
import { reduxForm } from 'redux-form' | |
const fields = ['email_marketing_opt_in'] | |
const submit = (values, dispatch) => { | |
dispatch() | |
} | |
class EmailMarketingForm extends Component { | |
render() { |
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
test('map a collection into a new array', assert => { | |
const expected = [ { a:1 }, { a: 1 } ] | |
const input = [ [ { a: 1 }, { b: 1 } ], [ { a: 1, c: 1 } ] ] | |
const actual = [].concat.apply([], input) | |
.filter(e => e.hasOwnProperty('a')) | |
.map(e => { | |
return { a: e.a } | |
}) | |
assert.deepEqual(actual, expected) | |
assert.end() |
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
export const LOAD_EMAIL_PREFERENCES = 'LOAD_EMAIL_PREFERENCES' | |
export const LOADED_EMAIL_PREFERENCES = 'LOADED_EMAIL_PREFERENCES' | |
export function loadEmailPreferences (personId) { | |
return async (dispatch, getState) => { | |
const account = getState().guests[personId].account | |
const centres = account.newsletter_centre_ids | |
if (centres.length) { | |
dispatch({ type: LOAD_EMAIL_PREFERENCES }) | |
const newslettersByCentre = await Promise.all(centres.map(getNewslettersByCentre)) | |
const subscriptions = account.newsletter_subscriptions |
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 React from 'react' | |
import { connect } from 'react-redux' | |
import { reduxForm } from 'redux-form' | |
import { loadInterests, saveInterests } from 'containers/UserDetail/Interests/actions' | |
import List from 'components/List' | |
import Panel from 'components/Panel' | |
function loadData (props) { | |
const { userId } = props.params | |
props.loadInterests(userId) |
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 activeCardSort(cards) { | |
const grouped = { | |
active: [], | |
expired: [], | |
deleted: [], | |
...groupBy(cards.map(getCardInfo), 'status') | |
} | |
const byCreatedAt = dateFrom('created_at') | |
const byDeletedAt = dateFrom('deleted_at') |
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 * as fs from 'fs' | |
import path from 'path' | |
import { sync as globSync } from 'glob' | |
import { sync as mkdirpSync } from 'mkdirp' | |
const MESSAGES_PATTERN = './dist/messages/**/*.json' | |
const LANG_DIR = './dist/lang/' | |
export default function() { | |
// Aggregates the default messages that were extracted from the example app's |
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
export function changeUser(user) { | |
const personId = user.person_id | |
return (dispatch, getState) => { | |
dispatch({ type: CHANGE_USER, payload: { personId } }) | |
const peopleEndpoint = PEOPLE_ENDPOINT(personId).clone() | |
return secureFetch(peopleEndpoint, { | |
method: 'PATCH', | |
body: JSON.stringify(user) | |
}).then( | |
res => dispatch(changedUser(user)), // I think i need to combine this user with getState().user |
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
let vehicles = groupBy(this.state.vehicles, 'license_plate') | |
vehicles = Object.keys(vehicles).map(license_plate => { | |
const activeVehicles = vehicles[license_plate] | |
.filter(notDeleted) | |
if (!activeVehicles.length) { | |
const byDeleted = dateFrom('deleted_at') | |
return vehicles[license_plate].sort(byDeleted)[0] | |
} |
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
// Print all of the news items on Hacker News | |
var jsdom = require('jsdom') | |
var fs = require('fs') | |
var app = fs.readFileSync('./dist/main.js', 'utf-8') | |
var html = '<div id="root"></div>' | |
jsdom.env(html, { | |
src: [app], | |
virtualConsole: jsdom.createVirtualConsole().sendTo(console), | |
done: function (err, window) { |
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
switch (action.type) { | |
case actionTypes.ME_SET: | |
return setMe(state, action); | |
default: | |
return state; | |
} |