From 0e6f5e580b7e64ecc2002534e1a14ccee36cd28e Mon Sep 17 00:00:00 2001
From: Jenny Yu <jennyyu212@outlook.com>
Date: Wed, 8 Jun 2022 22:55:16 -0700
Subject: feat: basic dashboard view

---
 src/client/views/DashboardView.tsx | 50 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 src/client/views/DashboardView.tsx

(limited to 'src/client/views/DashboardView.tsx')

diff --git a/src/client/views/DashboardView.tsx b/src/client/views/DashboardView.tsx
new file mode 100644
index 000000000..5fd9b550d
--- /dev/null
+++ b/src/client/views/DashboardView.tsx
@@ -0,0 +1,50 @@
+import { observable } from "mobx";
+import { observer } from "mobx-react";
+import * as React from 'react';
+import { Doc, DocListCast } from "../../fields/Doc";
+import { Id } from "../../fields/FieldSymbols";
+import { Cast, ImageCast, StrCast } from "../../fields/Types";
+import { CurrentUserUtils } from "../util/CurrentUserUtils";
+import { UndoManager } from "../util/UndoManager";
+import "./DashboardView.scss"
+
+@observer
+export class DashboardView extends React.Component {
+
+      //TODO: delete dashboard, share dashboard, etc.
+
+      newDashboard = async () => {
+            const batch = UndoManager.StartBatch("new dash");
+            await CurrentUserUtils.createNewDashboard(Doc.UserDoc());
+            batch.end();
+      }
+
+      clickDashboard = async (e: React.MouseEvent, dashboard: Doc) => {
+            if (e.detail === 2) {
+                  Doc.UserDoc().activeDashboard = dashboard
+            }
+      }
+
+      render() {
+            const myDashboards = DocListCast(CurrentUserUtils.MyDashboards.data);
+            return <div className="dashboard-view">
+                  <div className="left-menu">
+                        <div onClick={this.newDashboard}>New</div>
+                        <div>All Dashboards</div>
+                  </div>
+                  <div className="all-dashboards">
+                        {myDashboards.map((dashboard) =>
+                              <div className="dashboard-container" key={dashboard[Id]} onClick={(e) => { this.clickDashboard(e, dashboard) }}>
+                                    <img src="https://media.istockphoto.com/photos/hot-air-balloons-flying-over-the-botan-canyon-in-turkey-picture-id1297349747?b=1&k=20&m=1297349747&s=170667a&w=0&h=oH31fJty_4xWl_JQ4OIQWZKP8C6ji9Mz7L4XmEnbqRU="></img>
+                                    <div className="title"> {StrCast(dashboard.title)} </div>
+                              </div>
+
+                        )}
+                        {myDashboards.map((dashboard) => {
+                              console.log(dashboard.thumb)
+                        })}
+
+                  </div>
+            </div>
+      }
+}
-- 
cgit v1.2.3-70-g09d2

