diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index 6ac8141..439cb58 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -8,6 +8,7 @@ import {
withRouter,
} from "react-router";
import { AuthScreen } from "~Auth/AuthScreen";
+import { SharedView } from "~Documents/SharedView";
import { Home } from "~Home/Home";
import { Landing } from "~Landing/Landing";
import { IAppState } from "~redux/reducers";
@@ -23,12 +24,14 @@ export function AppComponent(props: IAppComponentProps) {
,
,
,
+ ,
,
) : (
+ ,
} />
diff --git a/frontend/src/Documents/Shared.scss b/frontend/src/Documents/Shared.scss
new file mode 100644
index 0000000..027f364
--- /dev/null
+++ b/frontend/src/Documents/Shared.scss
@@ -0,0 +1,13 @@
+.viewComponent {
+ position: absolute;
+ max-width: 100%;
+ width: 50rem;
+ left: 0;
+ right: 0;
+ top: -$pt-navbar-height;
+ bottom: 0;
+ margin-left: auto;
+ margin-right: auto;
+ padding-top: 2 * $pt-navbar-height + 20px;
+ max-height: 100%;
+}
\ No newline at end of file
diff --git a/frontend/src/Documents/SharedView.tsx b/frontend/src/Documents/SharedView.tsx
new file mode 100644
index 0000000..2ce70af
--- /dev/null
+++ b/frontend/src/Documents/SharedView.tsx
@@ -0,0 +1,95 @@
+import "./Docs.scss";
+
+import { Button, H1 } from "@blueprintjs/core";
+import * as React from "react";
+import Markdown from "react-markdown";
+import { connect } from "react-redux";
+import { RouteComponentProps, withRouter } from "react-router";
+import { Dispatch } from "redux";
+import { IDocumentJSON } from "~../../src/entity/Document";
+import { LoadingStub } from "~LoadingStub";
+import { NotFound } from "~NotFound";
+import { fetchSharedDoc } from "~redux/api/docs";
+import { fetchDocsStart } from "~redux/docs/actions";
+import { IAppState } from "~redux/reducers";
+import { CodeBlock } from "./CodeBlock";
+
+export interface ISharedViewComponentProps extends RouteComponentProps {
+ loggedIn: boolean;
+ username: string | undefined;
+}
+
+export interface ISharedViewComponentState {
+ loaded: boolean;
+ doc: IDocumentJSON | null;
+ error: string | null;
+}
+
+const defaultState: ISharedViewComponentState = {
+ loaded: false,
+ doc: null,
+ error: null,
+};
+
+export class SharedViewComponent extends React.PureComponent<
+ ISharedViewComponentProps,
+ ISharedViewComponentState
+> {
+ constructor(props: ISharedViewComponentProps) {
+ super(props);
+ this.state = defaultState;
+
+ return;
+ }
+
+ public render() {
+ if (this.state.loaded) {
+ if (this.state.error) {
+ return (
+
+ );
+ }
+ const { doc } = this.state;
+ return (
+
+ );
+ } else {
+ return ;
+ }
+ }
+
+ public async componentDidMount() {
+ const { username, id } = this.props.match.params as any;
+ const res = await fetchSharedDoc(username, id);
+ if (!res.error) {
+ this.setState({ loaded: true, doc: res.data });
+ } else {
+ this.setState({ loaded: true, error: res.error });
+ }
+ }
+}
+
+function mapStateToProps(state: IAppState) {
+ return {
+ loggedIn: state.user.user !== null,
+ username: state.user.user.username,
+ };
+}
+
+export const SharedView = SharedViewComponent;
diff --git a/frontend/src/redux/api/docs/index.ts b/frontend/src/redux/api/docs/index.ts
index a299f02..7560370 100644
--- a/frontend/src/redux/api/docs/index.ts
+++ b/frontend/src/redux/api/docs/index.ts
@@ -1,7 +1,7 @@
import { IDocumentJSON } from "~../../src/entity/Document";
import { IAPIResponse } from "~../../src/types";
-import { fetchJSONAuth } from "../utils";
+import { fetchJSONAuth, fetchJSON } from "../utils";
export async function fetchRecentDocs(): Promise<
IAPIResponse
@@ -19,6 +19,13 @@ export async function fetchDoc(
return fetchJSONAuth(`/docs/byID/${id}`, "GET");
}
+export async function fetchSharedDoc(
+ username: string,
+ id: number,
+): Promise> {
+ return fetchJSON(`/docs/shared/${username}/${id}`, "GET");
+}
+
export async function patchDoc(
id: number,
name?: string,