Working single comment view

This commit is contained in:
Belén Curcio
2018-07-25 17:24:14 -03:00
parent e519503129
commit 906940f152
13 changed files with 125 additions and 147 deletions
@@ -1,57 +0,0 @@
import * as React from "react";
import { StatelessComponent } from "react";
import { ReadyState } from "react-relay";
import { graphql, QueryRenderer } from "talk-framework/lib/relay";
import {
PermalinkViewQueryResponse,
PermalinkViewQueryVariables,
} from "talk-stream/__generated__/PermalinkViewQuery.graphql";
import { PermalinkViewContainer } from "talk-stream/containers/PermalinkViewContainer";
export interface CommentData {
id: string;
author: {
username: string;
} | null;
body: string | null;
createdAt: string;
}
export const render = ({
error,
props,
}: ReadyState<{
comment: CommentData;
}>) => {
if (error) {
return <div>{error.message}</div>;
}
if (props) {
return <PermalinkViewContainer data={props} />;
}
return <div>Loading</div>;
};
interface InnerProps {
commentID: string;
}
const PermalinkViewQuery: StatelessComponent<InnerProps> = props => {
return (
<QueryRenderer<PermalinkViewQueryVariables, PermalinkViewQueryResponse>
query={graphql`
query PermalinkViewQuery($commentID: ID!) {
...PermalinkViewContainer @arguments(commentID: $commentID)
}
`}
variables={{
commentID: props.commentID,
}}
render={render}
/>
);
};
export default PermalinkViewQuery;