Files
cpr-character-sheet/app/skills/education.tsx
T

76 lines
3.1 KiB
TypeScript

import { useState, useEffect } from 'react'
const baseUrl = typeof window !== 'undefined'
? window.location.origin
: process.env.VITE_VERCEL_URL || 'http://localhost:5173' // Fallback for your server env
const st = await fetch(`${baseUrl}/characters/collateral/stats.json`)
.then(r => r.json());
const sk = await
fetch(`${baseUrl}/characters/collateral/skills.json`)
.then(r => r.json());
function BaseVal({ skillRank, stat }) {
if (skillRank === "---") {
return <td>---</td>
} else {
return (<td>{skillRank + stat}</td>)
}
}
function SkillRow({ skillName, skillRank, stat }) {
return (
<tr>
<td>{skillName}</td>
<td>{skillRank}</td>
<td>{stat}</td>
<BaseVal skillRank={skillRank} stat={stat} />
</tr>
);
}
export function Education() {
const [stats] = useState(st)
const [skills] = useState(sk)
return (
<main>
<table className="cyber-table">
<thead>
<tr>
<th style={{ width: "70%" }}>EDUCATION SKILLS</th>
<th style={{ width: "10%" }}>RANKS</th>
<th style={{ width: "10%" }}>STAT</th>
<th style={{ width: "10%" }}>BASE</th>
</tr>
</thead>
<tbody>
<SkillRow skillName="ACCOUNTING" skillRank={skills.accounting} stat={stats.int} />
<SkillRow skillName="ANIMAL HANDLING" skillRank={skills.animalhandling} stat={stats.int} />
<SkillRow skillName="BUREAUCRAY" skillRank={skills.bureaucracy} stat={stats.int} />
<SkillRow skillName="BUSINESS" skillRank={skills.business} stat={stats.int} />
<SkillRow skillName="COMPOSITION" skillRank={skills.composition} stat={stats.int} />
<SkillRow skillName="CRIMINOLOGY" skillRank={skills.criminology} stat={stats.int} />
<SkillRow skillName="CRYPTOGRAPHY" skillRank={skills.cryptography} stat={stats.int} />
<SkillRow skillName="DEDUCTION" skillRank={skills.deduction} stat={stats.int} />
<SkillRow skillName="EDUCATION" skillRank={skills.education} stat={stats.int} />
<SkillRow skillName="GAMBLE" skillRank={skills.gamble} stat={stats.int} />
<SkillRow skillName="LANGUAGE:" skillRank="---" stat="---" />
<SkillRow skillName="-- STREETSLANG" skillRank={skills.lang_streetslang} stat={stats.int} />
<SkillRow skillName="-- ENGLISH" skillRank={skills.lang_english} stat={stats.int} />
<SkillRow skillName="-- SPANISH" skillRank={skills.lang_spanish} stat={stats.int} />
<SkillRow skillName="LIBRARY SEARCH" skillRank={skills.librarysearch} stat={stats.int} />
<SkillRow skillName="LOCAL EXPERT:" skillRank="---" stat="---" />
<SkillRow skillName="-- OLD COMBAT ZONE" skillRank={skills.localex_ocz} stat={stats.int} />
<SkillRow skillName="-- HOT ZONE" skillRank={skills.localex_hotzone} stat={stats.int} />
<SkillRow skillName="TACTICS" skillRank={skills.tactics} stat={stats.int} />
<SkillRow skillName="WILDERNESS SURVIVAL" skillRank={skills.wildernesssurvival} stat={stats.int} />
</tbody>
</table>
</main>
)
}