This file contains hidden or 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
| async trackEvent({ category, action, label, value }) { | |
| await this.db('events').insert({ | |
| category, | |
| action, | |
| label, | |
| value | |
| }); | |
| return this.db.destroy(); | |
| } |
This file contains hidden or 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
| handleChange(e) { | |
| const form = e.currentTarget | |
| const { formValues } = this.state | |
| const valid = Array.from(form.elements).every(el => { | |
| if (el.name) { | |
| formValues[el.name] = el.value | |
| } | |
| return el.validity.valid | |
| }) |
This file contains hidden or 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; | |
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |