import { useState, useEffect } from "react";
import type { Route } from "./+types/home";
export function meta({}: Route.MetaArgs) {
return [
{ title: "Collateral - Gear" },
{ name: "description", content: "Gear" },
];
}
const baseUrl =
typeof window !== "undefined"
? window.location.origin
: process.env.VITE_VERCEL_URL || "http://localhost:5173"; // Fallback for your server env
const g = await fetch(`${baseUrl}/characters/collateral/gear.json`).then((r) =>
r.json(),
);
type AmmunitionData = {
caliber: string;
type: string;
count: number;
};
type GearData = {
name: string;
description: string;
count: number;
contents: GearData[];
};
function AmmunitionRow({ ammo }: { ammo: AmunitionData }) {
return (
| {ammo.caliber} |
{ammo.type} |
{ammo.count}x |
);
}
function AmmunitionHeader() {
return (
| Caliber |
Type |
Count |
);
}
function Ammunition({ ammo }: { ammo: AmmunitionData[] }) {
const ammoRows: ReactElement[] = ammo.map((entry, index) => (
));
return (
);
}
function InventoryHeader(): ReactElement {
return (
| Name |
Description |
Count |
);
}
function InventoryWithDepth(name: string, depth: number): string {
if (depth === 0) {
return name;
}
return "|" + "-".repeat(depth - 1) + "> " + name;
}
function InventoryRow({
gear,
depth,
}: {
gear: GearData;
depth: number;
}): ReactElement {
const contents = gear.contents
? gear.contents.map((entry, index) => (
))
: [];
return (
<>
| {InventoryWithDepth(gear.name, depth)} |
{InventoryWithDepth(gear.description, depth)} |
{gear.count}x |
{contents}
>
);
}
function Inventory({ gear }: { gear: GearData[] }) {
const inventoryRows = gear.map((entry, index) => (
));
return (
);
}
export default function Gear() {
const [gear] = useState(g);
return (
);
}