From 3a7f26f6200bd3796a5207f62c0bdd18858db0e1 Mon Sep 17 00:00:00 2001 From: fragosti Date: Fri, 1 Jun 2018 11:04:56 -0700 Subject: Have basic newsletter subscribe form working --- .../website/ts/components/forms/subscribe_form.tsx | 68 ++++++++++++++++++++++ packages/website/ts/components/token_balances.tsx | 2 +- 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 packages/website/ts/components/forms/subscribe_form.tsx (limited to 'packages/website/ts/components') diff --git a/packages/website/ts/components/forms/subscribe_form.tsx b/packages/website/ts/components/forms/subscribe_form.tsx new file mode 100644 index 000000000..8bb0f4fc7 --- /dev/null +++ b/packages/website/ts/components/forms/subscribe_form.tsx @@ -0,0 +1,68 @@ +import { colors } from '@0xproject/react-shared'; +import * as React from 'react'; + +import RaisedButton from 'material-ui/RaisedButton'; +import { backendClient } from 'ts/utils/backend_client'; + +export interface SubscribeFormProps {} + +export enum SubscribeFormStatus { + None, + Error, + Success, + Loading, +} + +export interface SubscribeFormState { + emailText: string; + status: SubscribeFormStatus; +} + +export class SubscribeForm extends React.Component { + public state = { + emailText: '', + status: SubscribeFormStatus.None, + }; + public render(): React.ReactNode { + return ( +
+ Subscribe to our newsletter for 0x relayer and dApp updates +
+ + +
+
+ ); + } + private _handleEmailInputChange(event: React.ChangeEvent): void { + this.setState({ emailText: event.target.value }); + } + private async _handleSubscribeClickAsync(): Promise { + this._setStatus(SubscribeFormStatus.Loading); + const success = await backendClient.subscribeToNewsletterAsync(this.state.emailText); + const status = success ? SubscribeFormStatus.Success : SubscribeFormStatus.Error; + this._setStatus(status); + } + private _setStatus(status: SubscribeFormStatus): void { + this.setState({ status }); + } +} diff --git a/packages/website/ts/components/token_balances.tsx b/packages/website/ts/components/token_balances.tsx index f5a51dabb..022968941 100644 --- a/packages/website/ts/components/token_balances.tsx +++ b/packages/website/ts/components/token_balances.tsx @@ -77,11 +77,11 @@ interface TokenBalancesProps { interface TokenBalancesState { errorType: BalanceErrs; + trackedTokenStateByAddress: TokenStateByAddress; isBalanceSpinnerVisible: boolean; isZRXSpinnerVisible: boolean; isTokenPickerOpen: boolean; isAddingToken: boolean; - trackedTokenStateByAddress: TokenStateByAddress; } export class TokenBalances extends React.Component { -- cgit v1.2.3