diff --git a/package-lock.json b/package-lock.json
index 7e3a97d..3641185 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,5 +1,5 @@
{
- "name": "myApp",
+ "name": "Turtle",
"version": "0.0.1",
"lockfileVersion": 1,
"requires": true,
diff --git a/src/App.tsx b/src/App.tsx
index 9c7a3b4..db5f7cc 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,8 +1,9 @@
import React from 'react';
-import { Redirect, Route } from 'react-router-dom';
+import { Route } from 'react-router-dom';
import { IonApp, IonRouterOutlet } from '@ionic/react';
import { IonReactRouter } from '@ionic/react-router';
import Home from './pages/Home';
+import Room from './pages/Room';
/* Core CSS required for Ionic components to work properly */
import '@ionic/react/css/core.css';
@@ -28,6 +29,7 @@ const App: React.FC = () => (
+
diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx
index 83a634b..7136932 100644
--- a/src/pages/Home.tsx
+++ b/src/pages/Home.tsx
@@ -1,9 +1,30 @@
-import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar, IonButton, IonGrid, IonRow } from '@ionic/react';
-import React from 'react';
+import { IonButton, IonContent, IonGrid, IonHeader, IonPage, IonRow, IonTitle, IonToolbar } from '@ionic/react';
+import React, { useEffect, useState } from 'react';
+import { useHistory } from 'react-router';
+import { db, timestamp } from '../services/firebase';
import './Home.css';
const Home: React.FC = () => {
- async function handleSubmit() {}
+ const [loading, setLoading] = useState(true);
+ const [userId, setUserId] = useState('');
+
+ let history = useHistory();
+
+ const handleClick = async () => {
+ const roomId = await db.collection('rooms').add({
+ createdAt: timestamp,
+ ownerId: userId,
+ });
+
+ const path = '/room/' + roomId.id;
+ return history.push(path);
+ };
+
+ useEffect(() => {
+ console.log('Hook fired');
+ setUserId('placeholder');
+ setLoading(false);
+ }, []);
return (
@@ -15,7 +36,11 @@ const Home: React.FC = () => {
- Create Room
+ {loading ? (
+ Loading...
+ ) : (
+ Create Room
+ )}
diff --git a/src/pages/Room.tsx b/src/pages/Room.tsx
new file mode 100644
index 0000000..4d548d4
--- /dev/null
+++ b/src/pages/Room.tsx
@@ -0,0 +1,43 @@
+import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/react';
+import React, { useEffect, useState } from 'react';
+import { RouteComponentProps, useHistory } from 'react-router';
+import { db } from '../services/firebase';
+
+const Room: React.FC> = ({ match }) => {
+ const history = useHistory();
+ const roomId = match.params.roomId;
+
+ const [loading, setLoading] = useState(true);
+
+ // Verify that the roomId exists in db
+ useEffect(() => {
+ const fetchRoom = async () => {
+ const room = await db.collection('rooms').doc(roomId).get();
+ if (!room.exists) {
+ history.push('/');
+ } else {
+ setLoading(false);
+ }
+ };
+
+ console.log('Hook fired');
+ fetchRoom();
+ }, [history, roomId]);
+
+ return (
+
+
+
+ Turtle
+
+
+ {!loading ? (
+ Video and chat
+ ) : (
+ Loading...
+ )}
+
+ );
+};
+
+export default Room;