Skip to content
This repository has been archived by the owner on Nov 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #72 from Kaleidoscope-Systems/depa
Browse files Browse the repository at this point in the history
Add date of birth, age, executor
  • Loading branch information
escarlson authored Nov 23, 2023
2 parents ffe0b36 + 2d70790 commit 3fb3e04
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
18 changes: 12 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "epitaph",
"version": "0.7.3",
"version": "0.7.4",
"private": true,
"scripts": {
"dev": "next dev",
Expand All @@ -18,6 +18,7 @@
"@fortawesome/pro-solid-svg-icons": "^6.4.2",
"@fortawesome/react-fontawesome": "^0.2.0",
"bootstrap": "^5.3.2",
"dayjs": "^1.11.10",
"eslint": "8.51.0",
"eslint-config-next": "^13.5.5",
"eslint-plugin-import": "^2.28.0",
Expand All @@ -34,7 +35,7 @@
"react-cookie-consent": "^9.0.0",
"react-dom": "^18.2.0",
"semver": "^7.5.4",
"snyk": "^1.1232.0"
"snyk": "^1.1238.0"
},
"devDependencies": {
"@prisma/client": "^5.5.2",
Expand Down
27 changes: 27 additions & 0 deletions pages/admin/people/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useRouter } from "next/router"
import { useState, useEffect } from "react"
import md5 from "md5"
import Image from "next/image"
import Link from "next/link"

let appModule = "people"

Expand All @@ -26,12 +27,23 @@ export default function People() {
const router = useRouter();
const personId = router.query.id;
const [person, setPerson] = useState(null);
const [executor, setExecutor] = useState(null);

useEffect(() => {
if (personId) {
fetchPeople(personId)
.then((data) => {
setExecutor(null);
setPerson(data);
if (data.executorId) {
fetchPeople(data.executorId)
.then((data) => {
setExecutor(data);
})
.catch((error) => {
console.error("Error fetching executor data:", error);
});
}
})
.catch((error) => {
console.error("Error fetching people data:", error);
Expand All @@ -54,6 +66,10 @@ export default function People() {
classStatusBadge = 'bg-secondary';
}

const dobFormatted = person?.dateOfBirth?.split('T')[0];
const dayjs = require('dayjs')
const age = dayjs().diff(dobFormatted, 'year')

if ('loading' === status) return (<Loading />)
if ('unauthenticated' === status) return (
<>
Expand Down Expand Up @@ -84,6 +100,7 @@ export default function People() {
<span className={`badge ${classStatusBadge} me-2`} id="btn-status">
{person?.status}
</span>
<span className="text-muted" id="age">{person?.dateOfBirth ? `· Age ${age}` : ""}</span>
</p>
</div>
</div>
Expand Down Expand Up @@ -120,8 +137,18 @@ export default function People() {
<p className="text-muted">{person.maritalStatus ? person.maritalStatus : '-'}</p>
</div>
<div className="col">
<h6 className="mb-0">Date of Birth</h6>
<p className="text-muted">{person.dateOfBirth ? dobFormatted : '-'}</p>
</div>
<div className="col">
<h6 className="mb-0">Birth Place</h6>
<p className="text-muted">{person.birthPlace ? person.birthPlace : '-'}</p>
</div>
<div className="col">
<h6 className="mb-0">Executor</h6>
<p className="text-muted">{executor ? <Link href={`/admin/people/${person.executorId}`}>
{executor && executor.displayName}
</Link> : '-'}</p>
</div>
</div>
</div>
Expand Down

0 comments on commit 3fb3e04

Please sign in to comment.