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
| // shared.ts | |
| export const graphqlRequest = async <T>( | |
| query: string, | |
| variables = {}, | |
| ): Promise<T> => { | |
| const headers = { | |
| ...buildContentTypeHeader('application/json'), | |
| }; |
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 React from 'react'; | |
| import { Field, FormSection } from 'redux-form'; | |
| import IntlLink from '../../core/intl/intlLink/intlLink.container'; | |
| import { LOCATION } from '../../core/location/location.types'; | |
| import { IntlText } from '../../core/intl/intlText/intlText.container'; | |
| import { Input, Radio, Button, Icon, Text } from '../../components'; | |
| import { Address } from '../address/address.fieldset'; | |
| import { Name } from '../name/name.fieldset'; | |
| import { |
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 { createSelector, createStructuredSelector } from 'reselect'; | |
| import { getFormValues } from 'redux-form'; | |
| import { AppStateT, LoginStateT, FORM_NAMES, LOCATION } from '../../core/types'; | |
| import { selectPreviousPageType, selectKind } from '../../core/location/location.selectors'; | |
| export const selectLogin = (state: AppStateT) => state.login; | |
| export const selectAuthenticated = createSelector( | |
| selectLogin, | |
| (loginState: LoginStateT) => loginState.authenticated |
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 { path, find, propEq } from 'ramda'; | |
| import { createSelector } from 'reselect'; | |
| import { | |
| AppStateT, | |
| UserProfileT, | |
| BusinessNameSearchesT, | |
| BusinessNameSearchesSearchesT, | |
| UserDetailsT, | |
| PaymentOrderT, | |
| BUSINESS_REGISTRATION_STATUS, |
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 { createStructuredSelector, createSelector } from 'reselect'; | |
| import { getFormValues } from 'redux-form'; | |
| import { FORM_NAMES } from '../../core/types'; | |
| export const selectBusinessNameRegistrationFormValues = createSelector( | |
| getFormValues(FORM_NAMES.BUSINESS_NAME_REGISTRATION), | |
| formValues => formValues | |
| ); | |
| export const businessNameRegistrationFormConnector = createStructuredSelector({ |
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 Link from '../Link.react'; | |
| import renderer from 'react-test-renderer'; | |
| it('renders correctly', () => { | |
| const tree = renderer.create( | |
| <Link page="http://www.facebook.com">Facebook</Link> | |
| ).toJSON(); | |
| expect(tree).toMatchSnapshot(); | |
| }); |
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
| describe('loginSuccessEpic', () => { | |
| it('dispatches actions to change location, authenticated, and stopSubmit', () => { | |
| const action = ActionsObservable.of({ | |
| type: LOGIN_TYPES.SUCCESS, | |
| payload: [{}, {}] | |
| }); | |
| loginSuccessEpic(action, {}) | |
| .toArray() | |
| .subscribe((outputActions) => { | |
| expect(outputActions).toEqual([ |
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 loginSuccessEpic = ( | |
| action$, | |
| store | |
| ) => action$ | |
| .ofType(LOGIN_TYPES.SUCCESS) | |
| .mergeMap(() => { | |
| return Observable.from([ | |
| location.createRouteChangeAction( | |
| LOCATION.USER_DASHBOARD | |
| ), |
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
| // selectors.js | |
| export const selectLogin = (state: AppStateT) => state.login; | |
| export const selectAuthenticated = createSelector( | |
| selectLogin, | |
| (loginState: LoginStateT) => loginState.authenticated | |
| ); | |
| // selectors.test.js | |
| import { type } from 'ramda'; |
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 { createSelector } from 'reselect' | |
| const shopItemsSelector = state => state.shop.items | |
| const subtotalSelector = createSelector( | |
| shopItemsSelector, | |
| items => items.reduce((acc, item) => acc + item.value, 0) | |
| ) | |
| let exampleState = { |