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 React from 'react'; | |
import { compose, withStateHandlers } from 'recompose'; | |
import Confirm from 'semantic-ui-react/dist/commonjs/addons/Confirm/Confirm'; | |
/** | |
* with confirm hoc | |
* wraps an underlying component with a modal action confirmation | |
*/ | |
export type ConfirmOptions = { |
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 { compose, lifecycle, withState } from 'recompose'; | |
import { History, UnregisterCallback } from 'history'; | |
type Props = { | |
pristine: boolean; | |
history: History; | |
}; | |
type State = { | |
historyBlock: UnregisterCallback; |
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 React from 'react'; | |
import { Modal, ModalProps } from './semantic'; | |
export function withModal<T extends {} = any>( | |
modalOptions: ModalProps | ((props: T) => ModalProps), | |
) { | |
return BaseComponent => props => { | |
const modalProps = | |
typeof modalOptions === 'function' ? modalOptions(props) : modalOptions; |
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 React from 'react'; | |
import { StoryDecorator } from 'storybook__react'; | |
import { ThemeProvider } from 'styled-components'; | |
/** | |
* Storybook styled-components theme provider | |
*/ | |
export function withTheme(theme): StoryDecorator { |
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 { Document, model, Model, Schema } from 'mongoose'; | |
import { withFindOrCreate, WithFindOrCreate } from '../utils/findOrCreate'; | |
import { NutrientUnitInstance, NutrientUnitModel } from '../NutrientUnit/NutrientUnit'; | |
import { ObjectID } from 'bson'; | |
/** | |
* Nutrient (e.g. calcium) | |
*/ | |
export interface Nutrient { |
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 { Document, Model, Schema } from 'mongoose'; | |
import { ObjectID } from 'bson'; | |
/** | |
* Find or create mongoose static function creator | |
*/ | |
export type WithFindOrCreate<T extends Document> = { | |
findOrCreate: (id?: string | ObjectID | null) => T; | |
}; |
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
// @ts-ignore | |
nutrientSchema.post('init', async function(this: NutrientInstance) { | |
// noinspection JSDeprecatedSymbols | |
if (!this.displayUnitCode && this.displayUnitId) { | |
const unit = await NutrientUnitModel.findById(this.displayUnitId); | |
if (unit) { | |
this.displayUnitCode = unit.code; | |
await this.save(); | |
} | |
} |
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
{ | |
"compilerOptions": { | |
"target": "es2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ | |
"lib": ["dom", "es2017", "esnext"], | |
"module": "commonjs", /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ | |
// "noEmit": true, /* Do not emit outputs. */ | |
"strict": true, | |
"strictFunctionTypes": false, | |
"noImplicitAny": false, | |
"experimentalDecorators": true, |
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 { graphql, QueryProps } from 'react-apollo'; | |
/** | |
* QUERY | |
*/ | |
const PAYMENT_QUERY = gql` | |
query payment($id: ID!) { | |
payment(id: $id) { | |
id |
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 React from 'react'; | |
import { Loading } from '@common/components/Loading/Loading'; | |
import { ErrorMessage } from '@common/components/ErrorMessage/ErrorMessage'; | |
import { IconSizeProp } from 'semantic-ui-react/src/elements/Icon/Icon'; | |
type Options<T = any> = { | |
loaderSize?: IconSizeProp, | |
errorExtraCheck?: (props: T) => string | null | undefined, | |
loadingExtraCheck?: (props: T) => boolean, |