Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
feat(patients): add very simple way of displaying all patients
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmeyer committed Nov 20, 2019
1 parent bb94ef0 commit 927b5bc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/clients/db/patients-db.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { patients } from '../../config/pouchdb';

export async function getAll() {
return patients.allDocs();
return patients.allDocs({ include_docs: true});
}

export async function deleteDocument(document: any) {
Expand Down
42 changes: 39 additions & 3 deletions src/components/Patients.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,55 @@
import React, { Component } from 'react';
import * as patientsDb from '../clients/db/patients-db';
import { Link } from 'react-router-dom';

class Patients extends Component {
interface Props {

}

interface State {
patients: any[],
}


class Patients extends Component<Props, State> {

constructor(props: Props) {
super(props);
this.state = {
patients: [],
}
}

async componentDidMount() {
const patients = await patientsDb.getAll();
console.log(patients);
this.setState({
patients: patients.rows,
})
}

render() {
const list = (
<ul>
{this.state.patients.map((patient) =>
<Link to={`/patients/${patient.id}`}>
<li key={patient.id}>
{patient.doc.firstName} {patient.doc.lastName}
</li>
</Link>
)}
</ul>
);

return (
<div>
<h1>Patients</h1>
</div>
<div className="container">
<ul>
{list}
</ul>
</div>

</div>
);
}
}
Expand Down

0 comments on commit 927b5bc

Please sign in to comment.