Back to the stream if comment not found

This commit is contained in:
Belén Curcio
2018-07-26 11:27:22 -03:00
parent 1c60e2fdea
commit 325f453476
2 changed files with 26 additions and 5 deletions
@@ -4,6 +4,7 @@
margin: 20px auto;
}
.comment {
.comment,
.commentNotFound {
margin: 20px auto;
}
@@ -3,7 +3,7 @@ import * as React from "react";
import { StatelessComponent } from "react";
import Logo from "talk-stream/components/Logo";
import { Button, Flex } from "talk-ui/components";
import { Button, Flex, Typography } from "talk-ui/components";
import CommentContainer from "../../containers/CommentContainer";
import * as styles from "./PermalinkView.css";
@@ -12,20 +12,22 @@ export interface InnerProps {
}
const PermalinkView: StatelessComponent<InnerProps> = props => {
let assetURL: string = "";
const query = qs.parse(location.search);
if (!query.assetID && !query.commentID) {
return <div>Bad url: `assetID` and `commentID` params are needed</div>;
}
if (props.comment) {
if (query.assetID) {
// TODO (bc) temporary needed to pass the assetID to go back to the correct asset until the backend
// returns the correct asset url
let assetURL: string = "";
if (query.assetID) {
assetURL = `${location.origin}/?assetID=${query.assetID}`;
}
}
if (props.comment) {
return (
<div className={styles.root}>
<Logo />
@@ -47,7 +49,25 @@ const PermalinkView: StatelessComponent<InnerProps> = props => {
);
}
return <div>Comment not found</div>;
return (
<div className={styles.root}>
<Logo />
<Typography className={styles.commentNotFound}>
Comment not found
</Typography>
{assetURL && (
<Button
variant="filled"
color="primary"
onClick={() => {
window.location.href = assetURL;
}}
>
Back to the Stream
</Button>
)}
</div>
);
};
export default PermalinkView;