chore: Fix linter errors
This commit is contained in:
@@ -272,10 +272,10 @@ export default function CharacterSheet() {
|
|||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
const xp = parseInt(String(fields.xpCurrent)) || 0;
|
const xp = parseInt(String(fields.xpCurrent), 10) || 0;
|
||||||
const xpPct = Math.min((xp % 10) * 10, 100);
|
const xpPct = Math.min((xp % 10) * 10, 100);
|
||||||
const hpMax = parseInt(String(fields.hpMax)) || 0;
|
const hpMax = parseInt(String(fields.hpMax), 10) || 0;
|
||||||
const hpCur = parseInt(String(fields.hpCur)) || 0;
|
const hpCur = parseInt(String(fields.hpCur), 10) || 0;
|
||||||
const inCrisis = hpMax > 0 && hpCur <= Math.floor(hpMax / 2);
|
const inCrisis = hpMax > 0 && hpCur <= Math.floor(hpMax / 2);
|
||||||
const fpTotal = Math.max(10, fp);
|
const fpTotal = Math.max(10, fp);
|
||||||
|
|
||||||
@@ -463,7 +463,7 @@ export default function CharacterSheet() {
|
|||||||
const encoded = params.get("c");
|
const encoded = params.get("c");
|
||||||
if (shortId) {
|
if (shortId) {
|
||||||
// Short link: fetch the sheet JSON from the share service.
|
// Short link: fetch the sheet JSON from the share service.
|
||||||
fetch(apiURL("api/s/" + encodeURIComponent(shortId)))
|
fetch(apiURL(`api/s/${encodeURIComponent(shortId)}`))
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (!res.ok) throw new Error(String(res.status));
|
if (!res.ok) throw new Error(String(res.status));
|
||||||
return res.json();
|
return res.json();
|
||||||
@@ -489,9 +489,9 @@ export default function CharacterSheet() {
|
|||||||
if (raw)
|
if (raw)
|
||||||
try {
|
try {
|
||||||
applyData(JSON.parse(raw));
|
applyData(JSON.parse(raw));
|
||||||
} catch (e) {}
|
} catch (_e) {}
|
||||||
}
|
}
|
||||||
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
}, [applyData]);
|
||||||
|
|
||||||
// Auto-save every 30s
|
// Auto-save every 30s
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -565,10 +565,10 @@ export default function CharacterSheet() {
|
|||||||
});
|
});
|
||||||
if (!res.ok) throw new Error(String(res.status));
|
if (!res.ok) throw new Error(String(res.status));
|
||||||
const { id } = await res.json();
|
const { id } = await res.json();
|
||||||
shareURL = base + "?s=" + id;
|
shareURL = `${base}?s=${id}`;
|
||||||
} catch {
|
} catch {
|
||||||
// Backend unreachable: fall back to a self-contained inline ?c= link.
|
// Backend unreachable: fall back to a self-contained inline ?c= link.
|
||||||
shareURL = base + "?c=" + (await compressToBase64(json));
|
shareURL = `${base}?c=${await compressToBase64(json)}`;
|
||||||
}
|
}
|
||||||
await copyToClipboard(shareURL);
|
await copyToClipboard(shareURL);
|
||||||
setCopyStatus(true);
|
setCopyStatus(true);
|
||||||
@@ -576,13 +576,13 @@ export default function CharacterSheet() {
|
|||||||
}, [collectData]);
|
}, [collectData]);
|
||||||
|
|
||||||
const calcHP = useCallback(() => {
|
const calcHP = useCallback(() => {
|
||||||
const mig = parseInt(String(fields.migBase)) || 6;
|
const mig = parseInt(String(fields.migBase), 10) || 6;
|
||||||
const max = mig * 5 + level;
|
const max = mig * 5 + level;
|
||||||
setFields((prev) => ({ ...prev, hpMax: max, hpCur: prev.hpCur || max }));
|
setFields((prev) => ({ ...prev, hpMax: max, hpCur: prev.hpCur || max }));
|
||||||
}, [fields.migBase, level]);
|
}, [fields.migBase, level]);
|
||||||
|
|
||||||
const calcMP = useCallback(() => {
|
const calcMP = useCallback(() => {
|
||||||
const wlp = parseInt(String(fields.wlpBase)) || 6;
|
const wlp = parseInt(String(fields.wlpBase), 10) || 6;
|
||||||
const max = wlp * 5 + level;
|
const max = wlp * 5 + level;
|
||||||
setFields((prev) => ({ ...prev, mpMax: max, mpCur: prev.mpCur || max }));
|
setFields((prev) => ({ ...prev, mpMax: max, mpCur: prev.mpCur || max }));
|
||||||
}, [fields.wlpBase, level]);
|
}, [fields.wlpBase, level]);
|
||||||
@@ -663,8 +663,9 @@ export default function CharacterSheet() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="field-row">
|
<div className="field-row">
|
||||||
<div className="field" style={{ flex: 2 }}>
|
<div className="field" style={{ flex: 2 }}>
|
||||||
<label>Name</label>
|
<label htmlFor="character-name">Name</label>
|
||||||
<input
|
<input
|
||||||
|
id="character-name"
|
||||||
type="text"
|
type="text"
|
||||||
value={fields.charName}
|
value={fields.charName}
|
||||||
onChange={(e) => f("charName", e.target.value)}
|
onChange={(e) => f("charName", e.target.value)}
|
||||||
@@ -672,8 +673,9 @@ export default function CharacterSheet() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="field">
|
<div className="field">
|
||||||
<label>Pronouns</label>
|
<label htmlFor="character-pronouns">Pronouns</label>
|
||||||
<input
|
<input
|
||||||
|
id="character-pronouns"
|
||||||
type="text"
|
type="text"
|
||||||
value={fields.charPronouns}
|
value={fields.charPronouns}
|
||||||
onChange={(e) => f("charPronouns", e.target.value)}
|
onChange={(e) => f("charPronouns", e.target.value)}
|
||||||
@@ -682,8 +684,9 @@ export default function CharacterSheet() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="field">
|
<div className="field">
|
||||||
<label>Identity</label>
|
<label htmlFor="character-identity">Identity</label>
|
||||||
<input
|
<input
|
||||||
|
id="character-identity"
|
||||||
type="text"
|
type="text"
|
||||||
value={fields.charIdentity}
|
value={fields.charIdentity}
|
||||||
onChange={(e) => f("charIdentity", e.target.value)}
|
onChange={(e) => f("charIdentity", e.target.value)}
|
||||||
@@ -692,8 +695,9 @@ export default function CharacterSheet() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="field-row">
|
<div className="field-row">
|
||||||
<div className="field">
|
<div className="field">
|
||||||
<label>Theme</label>
|
<label htmlFor="character-theme">Theme</label>
|
||||||
<input
|
<input
|
||||||
|
id="character-theme"
|
||||||
type="text"
|
type="text"
|
||||||
value={fields.charTheme}
|
value={fields.charTheme}
|
||||||
onChange={(e) => f("charTheme", e.target.value)}
|
onChange={(e) => f("charTheme", e.target.value)}
|
||||||
@@ -701,8 +705,9 @@ export default function CharacterSheet() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="field">
|
<div className="field">
|
||||||
<label>Origin</label>
|
<label htmlFor="character-origin">Origin</label>
|
||||||
<input
|
<input
|
||||||
|
id="character-origin"
|
||||||
type="text"
|
type="text"
|
||||||
value={fields.charOrigin}
|
value={fields.charOrigin}
|
||||||
onChange={(e) => f("charOrigin", e.target.value)}
|
onChange={(e) => f("charOrigin", e.target.value)}
|
||||||
@@ -711,8 +716,9 @@ export default function CharacterSheet() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="field">
|
<div className="field">
|
||||||
<label>Traits (comma-separated)</label>
|
<label htmlFor="character-traits">Traits (comma-separated)</label>
|
||||||
<textarea
|
<textarea
|
||||||
|
id="character-traits"
|
||||||
value={fields.charTraits}
|
value={fields.charTraits}
|
||||||
onChange={(e) => f("charTraits", e.target.value)}
|
onChange={(e) => f("charTraits", e.target.value)}
|
||||||
placeholder="Brave, Reckless, Loyal to a fault…"
|
placeholder="Brave, Reckless, Loyal to a fault…"
|
||||||
@@ -757,8 +763,9 @@ export default function CharacterSheet() {
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div className="field">
|
<div className="field">
|
||||||
<label>Experience Points (XP)</label>
|
<label htmlFor="character-xp-current">Experience Points (XP)</label>
|
||||||
<input
|
<input
|
||||||
|
id="character-xp-current"
|
||||||
type="number"
|
type="number"
|
||||||
value={fields.xpCurrent}
|
value={fields.xpCurrent}
|
||||||
onChange={(e) => f("xpCurrent", e.target.value)}
|
onChange={(e) => f("xpCurrent", e.target.value)}
|
||||||
@@ -773,8 +780,9 @@ export default function CharacterSheet() {
|
|||||||
<span>10 XP = Level</span>
|
<span>10 XP = Level</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="field" style={{ marginTop: 12 }}>
|
<div className="field" style={{ marginTop: 12 }}>
|
||||||
<label>Zenit (currency)</label>
|
<label htmlFor="character-zenit">Zenit (currency)</label>
|
||||||
<input
|
<input
|
||||||
|
id="character-zenit"
|
||||||
type="number"
|
type="number"
|
||||||
value={fields.zenit}
|
value={fields.zenit}
|
||||||
onChange={(e) => f("zenit", e.target.value)}
|
onChange={(e) => f("zenit", e.target.value)}
|
||||||
@@ -791,24 +799,27 @@ export default function CharacterSheet() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="def-row">
|
<div className="def-row">
|
||||||
<div className="def-block">
|
<div className="def-block">
|
||||||
<label>Initiative Mod</label>
|
<label htmlFor="character-initiative">Initiative Mod</label>
|
||||||
<input
|
<input
|
||||||
|
id="character-initiative"
|
||||||
type="number"
|
type="number"
|
||||||
value={fields.initMod}
|
value={fields.initMod}
|
||||||
onChange={(e) => f("initMod", e.target.value)}
|
onChange={(e) => f("initMod", e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="def-block">
|
<div className="def-block">
|
||||||
<label>Defense</label>
|
<label htmlFor="character-defense">Defense</label>
|
||||||
<input
|
<input
|
||||||
|
id="character-defense"
|
||||||
type="number"
|
type="number"
|
||||||
value={fields.defense}
|
value={fields.defense}
|
||||||
onChange={(e) => f("defense", e.target.value)}
|
onChange={(e) => f("defense", e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="def-block">
|
<div className="def-block">
|
||||||
<label>Magic Defense</label>
|
<label htmlFor="character-magic-defense">Magic Defense</label>
|
||||||
<input
|
<input
|
||||||
|
id="character-magic-defense"
|
||||||
type="number"
|
type="number"
|
||||||
value={fields.magDef}
|
value={fields.magDef}
|
||||||
onChange={(e) => f("magDef", e.target.value)}
|
onChange={(e) => f("magDef", e.target.value)}
|
||||||
|
|||||||
Reference in New Issue
Block a user