Save comment draft + test

This commit is contained in:
Chi Vinh Le
2018-09-03 12:16:01 +02:00
parent ccf91480da
commit aa2b70fd8c
24 changed files with 354 additions and 304 deletions
@@ -1,6 +1,7 @@
import { FormState } from "final-form";
import { Localized } from "fluent-react/compat";
import React, { StatelessComponent } from "react";
import { Field, Form } from "react-final-form";
import { Field, Form, FormSpy } from "react-final-form";
import { OnSubmit } from "talk-framework/lib/form";
import { required } from "talk-framework/lib/validation";
@@ -22,10 +23,12 @@ interface FormProps {
export interface PostCommentFormProps {
onSubmit: OnSubmit<FormProps>;
onChange?: (state: FormState) => void;
initialValues?: FormProps;
}
const PostCommentForm: StatelessComponent<PostCommentFormProps> = props => (
<Form onSubmit={props.onSubmit}>
<Form onSubmit={props.onSubmit} initialValues={props.initialValues}>
{({ handleSubmit, submitting }) => (
<form
autoComplete="off"
@@ -33,6 +36,7 @@ const PostCommentForm: StatelessComponent<PostCommentFormProps> = props => (
className={styles.root}
id="comments-postCommentForm-form"
>
<FormSpy onChange={props.onChange} />
<HorizontalGutter>
<Field name="body" validate={required}>
{({ input, meta }) => (
@@ -213,7 +213,7 @@ exports[`when use is logged in renders correctly 1`] = `
<withContext(createMutationContainer(withContext(createMutationContainer(withContext(createMutationContainer(withContext(withLocalStateContainer(Relay(UserBoxContainer)))))))))
user={Object {}}
/>
<withContext(createMutationContainer(PostCommentFormContainer))
<withContext(withContext(createMutationContainer(PostCommentFormContainer)))
assetID="asset-id"
/>
</withPropsOnChange(HorizontalGutter)>