-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d38ce83
commit 74f09e0
Showing
10 changed files
with
98 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { promises as fs } from "fs"; | ||
|
||
|
||
export async function readJsonFile(filePath: string) { | ||
try { | ||
const file = await fs.readFile(process.cwd() + filePath, 'utf8'); | ||
const data = JSON.parse(file); | ||
return data; | ||
} catch (e) { | ||
console.error("Error reading JSON file:", e); | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,43 @@ | ||
import Image from "next/image"; | ||
import { readJsonFile } from "@/app/libs/utils"; | ||
import { | ||
peopleJsonData, | ||
sectionData, | ||
personData | ||
} from "./types"; | ||
|
||
|
||
import { promises as fs } from "fs"; | ||
|
||
|
||
type personData = { | ||
imagePath: string, | ||
name: string, | ||
affiliation: string, | ||
orcid: string | ||
} | ||
|
||
type sectionData = { | ||
title: string, | ||
persons: personData[] | ||
} | ||
|
||
export default async function AboutPeople() { | ||
const [imgW, imgH] = [150, 150]; | ||
|
||
async function readJsonFile(filePath: string) { | ||
try { | ||
const file = await fs.readFile(process.cwd() + '/app/ui/about/people.json', 'utf8'); | ||
const data = JSON.parse(file); | ||
return data; | ||
} catch (e) { | ||
console.error("Error reading YAML file:", e); | ||
return null; | ||
} | ||
} | ||
|
||
const peopleJson = await readJsonFile('') as sectionData[]; | ||
console.log(peopleJson) | ||
|
||
const peopleJson = await readJsonFile('/app/ui/about/people.json') as peopleJsonData; | ||
|
||
return ( | ||
<> | ||
<p className="header-2"><b>Principal Investigators</b></p> | ||
<div className="grid grid-rows-1"> | ||
<div className="grid md:grid-cols-3 sm:grid-rows-1"> | ||
{ | ||
//@ts-ignore | ||
peopleJson['sections'][0]['persons'].map((person: personData) => { | ||
return ( | ||
<div className="card"> | ||
<Image src={person.imagePath} width={imgW} height={imgH} alt={person.name} className="mx-auto"></Image> | ||
<div className="pt-2"> | ||
<p className="text-lg"><b>{person.name}</b></p> | ||
<p className="mb-2">{person.affiliation}</p> | ||
<a href={person.orcid} className="orcid-id-btn" target="_blank">ID</a> | ||
</div> | ||
</div> | ||
); | ||
}) | ||
} | ||
</div> | ||
</div> | ||
<p className="header-2"><b>Project Team Members</b></p> | ||
<div className="grid grid-rows-1"> | ||
<div className="grid grid-cols-3"> | ||
{ | ||
//@ts-ignore | ||
peopleJson['sections'][1]['persons'].map((person: personData) => { | ||
return ( | ||
<div className="card"> | ||
<Image src={person.imagePath} width={imgW} height={imgH} alt={person.name} className="mx-auto"></Image> | ||
<div className="pt-2"> | ||
<p className="text-lg"><b>{person.name}</b></p> | ||
<p className="mb-2">{person.affiliation}</p> | ||
<a href={person.orcid} className="orcid-id-btn" target="_blank">ID</a> | ||
</div> | ||
</div> | ||
); | ||
}) | ||
} | ||
|
||
</div> | ||
</div> | ||
<p className="header-2"><b>Former Project Team Members</b></p> | ||
<div className="grid grid-rows-1"> | ||
<div className="grid grid-cols-3"> | ||
{ | ||
//@ts-ignore | ||
peopleJson['sections'][2]['persons'].map((person: personData) => { | ||
return ( | ||
<div className="card"> | ||
<Image src={person.imagePath} width={imgW} height={imgH} alt={person.name} className="mx-auto"></Image> | ||
<div className="pt-2"> | ||
<p className="text-lg"><b>{person.name}</b></p> | ||
<p className="mb-2">{person.affiliation}</p> | ||
<a href={person.orcid} className="orcid-id-btn" target="_blank">ID</a> | ||
</div> | ||
</div> | ||
); | ||
}) | ||
} | ||
</div> | ||
</div> | ||
{ | ||
peopleJson['sections'].map((section: sectionData) => { | ||
return ( | ||
<> | ||
<p className="header-2"><b>{section.title}</b></p> | ||
<div className="grid md:grid-cols-3 sm:grid-rows-1 gap-4"> | ||
{ | ||
section.persons.map((person: personData) => { | ||
return ( | ||
<div className="card"> | ||
<Image src={person.imagePath} width={imgW} height={imgH} alt={person.name} className="mx-auto"></Image> | ||
<div className="pt-2"> | ||
<p className="text-lg"><b>{person.name}</b></p> | ||
<p className="mb-2">{person.affiliation}</p> | ||
<a href={person.orcid} className="orcid-id-btn" target="_blank">ID</a> | ||
</div> | ||
</div> | ||
); | ||
}) | ||
} | ||
</div> | ||
</> | ||
) | ||
}) | ||
} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export type personData = { | ||
imagePath: string, | ||
name: string, | ||
affiliation: string, | ||
orcid: string | ||
} | ||
|
||
export type sectionData = { | ||
title: string, | ||
persons: personData[] | ||
} | ||
|
||
export type peopleJsonData = { | ||
sections: sectionData[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters