From 723dd2bcde0a3c8277be7a000657f4acde0dfa4e Mon Sep 17 00:00:00 2001 From: Fred Carlsen Date: Wed, 12 Dec 2018 19:45:11 +0100 Subject: WIP configurator --- packages/website/ts/@next/pages/instant.tsx | 10 +- .../ts/@next/pages/instant/config_generator.tsx | 314 +++++++++++++++++++++ .../ts/@next/pages/instant/configurator.tsx | 109 +++++++ 3 files changed, 428 insertions(+), 5 deletions(-) create mode 100644 packages/website/ts/@next/pages/instant/config_generator.tsx create mode 100644 packages/website/ts/@next/pages/instant/configurator.tsx diff --git a/packages/website/ts/@next/pages/instant.tsx b/packages/website/ts/@next/pages/instant.tsx index 442aa0c8b..34dd83f1e 100644 --- a/packages/website/ts/@next/pages/instant.tsx +++ b/packages/website/ts/@next/pages/instant.tsx @@ -11,8 +11,8 @@ import {Button} from 'ts/@next/components/button'; import {Definition} from 'ts/@next/components/definition'; import {Section} from 'ts/@next/components/newLayout'; import {SiteWrap} from 'ts/@next/components/siteWrap'; -import {Paragraph} from 'ts/@next/components/text'; -// import { Configurator } from 'ts/pages/instant/configurator'; +import {Heading, Paragraph} from 'ts/@next/components/text'; +import { Configurator } from 'ts/@next/pages/instant/configurator'; const CONFIGURATOR_HASH = 'configure'; @@ -91,9 +91,9 @@ export const Next0xInstant = () => ( ))} -
- Configurator goes here - {/* */} +
+ 0x Instant Configurator +
void; +} + +export interface ConfigGeneratorState { + isLoadingAvailableTokens: boolean; + // Address to token info + availableTokens?: ObjectMap; +} + +const SRA_ENDPOINTS = ['https://api.radarrelay.com/0x/v2/', 'https://sra.bamboorelay.com/0x/v2/']; + +export class ConfigGenerator extends React.Component { + public state: ConfigGeneratorState = { + isLoadingAvailableTokens: true, + }; + public componentDidMount(): void { + // tslint:disable-next-line:no-floating-promises + this._setAvailableAssetsFromOrderProvider(); + } + public componentDidUpdate(prevProps: ConfigGeneratorProps): void { + if (prevProps.value.orderSource !== this.props.value.orderSource) { + // tslint:disable-next-line:no-floating-promises + this._setAvailableAssetsFromOrderProvider(); + const newConfig: ZeroExInstantBaseConfig = { + ...this.props.value, + availableAssetDatas: undefined, + }; + this.props.onConfigChange(newConfig); + } + } + public render(): React.ReactNode { + const { value } = this.props; + if (!_.isString(value.orderSource)) { + throw new Error('ConfigGenerator component only supports string values as an orderSource.'); + } + return ( + + +