Skip to content

Commit

Permalink
Decent progress on 2nd day of development. Got several classes and ca…
Browse files Browse the repository at this point in the history
…ncer model class with static methods to produce data. Next step is to switch focus to the actual interface
  • Loading branch information
davemanroth committed Jan 6, 2021
1 parent 96499cc commit e85592e
Show file tree
Hide file tree
Showing 19 changed files with 287 additions and 219 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
2 changes: 1 addition & 1 deletion firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

"emulators": {
"firestore": {
"port": 8080
"port": 5000
},

"ui": {
Expand Down
20 changes: 16 additions & 4 deletions firestore-debug.log
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
API endpoint: http://localhost:8080
API endpoint: http://localhost:5000
If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:

export FIRESTORE_EMULATOR_HOST=localhost:8080
export FIRESTORE_EMULATOR_HOST=localhost:5000

Dev App Server is now running.

Nov 30, 2020 1:39:47 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
Dec 02, 2020 3:38:38 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
Nov 30, 2020 1:39:47 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
Dec 02, 2020 3:38:38 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected HTTP/2 connection.
Dec 02, 2020 3:38:39 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
Dec 02, 2020 3:38:39 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
Dec 02, 2020 3:38:39 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
Dec 02, 2020 3:38:55 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
Dec 02, 2020 3:38:55 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
*** shutting down gRPC server since JVM is shutting down
*** server shut down
38 changes: 34 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
import PracticeInterface from './PracticeInterface/PracticeInterface';
import data from './cancers_template.json';

import React, { useState, useEffect } from 'react';
import { DBQueryer } from './DBQueryer/DBQueryer';
import { CancerModel } from './models';

const App = () => {
return <PracticeInterface data={ data } />
const [cancers, setCancers] = useState([]);

const output = (bundle) => {
if (!Array.isArray(bundle)) {
return;
}
return bundle.map( (items, i) => {
return (
<ul>
<li key={ i }>{ items.name }</li>
{ output(items.getContents()) }
</ul>
);
});
}

useEffect( () => {
if (cancers.length === 0) {
DBQueryer.getAll("cancers")
.then( (dbCancers) => {
CancerModel.load(dbCancers);
setCancers(CancerModel.getCancersFull());
});
}
});

return cancers.length > 0 && (
<>
{ output(cancers) }
</>
);
}

export default App;
23 changes: 0 additions & 23 deletions src/CancerSelector/CancerSelector.js

This file was deleted.

35 changes: 0 additions & 35 deletions src/CancerSelector/CancerSelector.test.js

This file was deleted.

28 changes: 28 additions & 0 deletions src/DBQueryer/DBQueryer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Revealing module design pattern

import { dbInstance } from '../helpers/dbinstance';

const DBQueryer = ( () => {
const db = dbInstance.getDB();
const collections = {};

const getAllFromDB = async (name) => {
const querySnapshot = await db.collection(name).get();
return querySnapshot.docs.map( (doc) => doc.data() );
}

const getAllInCollection = async (name) => {
if (!collections.hasOwnProperty(name)) {
const result = await getAllFromDB(name);
collections[name] = result;
}
return collections[name];
}

return {
getAll: getAllInCollection
}

})();

export { DBQueryer };
25 changes: 0 additions & 25 deletions src/ListModule/ListModule.js

This file was deleted.

26 changes: 0 additions & 26 deletions src/ListModule/ListModule.test.js

This file was deleted.

13 changes: 0 additions & 13 deletions src/Lists/List.js

This file was deleted.

21 changes: 0 additions & 21 deletions src/Lists/List.test.js

This file was deleted.

48 changes: 0 additions & 48 deletions src/PracticeInterface/PracticeInterface.js

This file was deleted.

15 changes: 0 additions & 15 deletions src/PracticeInterface/PracticeInterface.test.js

This file was deleted.

36 changes: 36 additions & 0 deletions src/__tests__/App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import { screen, render } from '@testing-library/react'
import { Regimen, RiskStrat, Cancer } from '../models';
import App from '../App';

beforeEach( () => {
render(<App />);
});

it('should show a list of cancers', async () => {
expect( await screen.findByRole('list')).toBeInTheDocument();
});

const getRegimens = () => {
return [
new Regimen('Regimen 1'),
new Regimen('Regimen 2'),
new Regimen('Regimen 3')
];
}

const getRiskStrats = () => {
return [
new RiskStrat('Risk strat 1'),
new RiskStrat('Risk strat 2'),
new RiskStrat('Risk strat 3')
];
}

const getCancers = () => {
return [
new Cancer('Cancer 1'),
new Cancer('Cancer 2'),
new Cancer('Cancer 3')
];
}
Loading

0 comments on commit e85592e

Please sign in to comment.