2022-02-14 05:38:21 +00:00
|
|
|
import Head from "next/head";
|
2022-01-19 06:06:19 +00:00
|
|
|
import React from "react";
|
2022-01-19 06:07:32 +00:00
|
|
|
import useSWRImmutable from "swr/immutable";
|
2022-01-19 06:06:19 +00:00
|
|
|
|
|
|
|
import styles from "../styles/CellData.module.css";
|
2022-03-17 05:11:59 +00:00
|
|
|
import ModList from "./ModList";
|
2022-08-18 03:19:55 +00:00
|
|
|
import PluginList from "./ParsedPluginsList";
|
2022-03-18 05:06:20 +00:00
|
|
|
import { jsonFetcher } from "../lib/api";
|
2022-01-19 06:06:19 +00:00
|
|
|
|
|
|
|
export interface Mod {
|
|
|
|
id: number;
|
|
|
|
name: string;
|
|
|
|
nexus_mod_id: number;
|
|
|
|
author_name: string;
|
|
|
|
author_id: number;
|
2022-01-19 06:07:32 +00:00
|
|
|
category_name: string;
|
|
|
|
category_id: number;
|
|
|
|
description: string;
|
|
|
|
thumbnail_link: string;
|
|
|
|
game_id: number;
|
2022-03-16 04:37:08 +00:00
|
|
|
is_translation: boolean;
|
2022-01-19 06:07:32 +00:00
|
|
|
updated_at: string;
|
|
|
|
created_at: string;
|
2022-01-19 06:06:19 +00:00
|
|
|
last_update_at: string;
|
|
|
|
first_upload_at: string;
|
2022-01-19 06:07:32 +00:00
|
|
|
last_updated_files_at: string;
|
2022-01-19 06:06:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface Cell {
|
|
|
|
form_id: number;
|
|
|
|
x: number;
|
|
|
|
y: number;
|
|
|
|
is_persistent: boolean;
|
|
|
|
mods_count: number;
|
|
|
|
files_count: number;
|
|
|
|
plugins_count: number;
|
|
|
|
mods: Mod[];
|
|
|
|
}
|
|
|
|
|
|
|
|
type Props = {
|
2022-01-24 05:59:36 +00:00
|
|
|
selectedCell: { x: number; y: number };
|
2022-01-30 21:55:50 +00:00
|
|
|
counts: Record<number, [number, number, number]> | null;
|
2022-01-19 06:06:19 +00:00
|
|
|
};
|
|
|
|
|
2022-01-25 05:31:25 +00:00
|
|
|
const CellData: React.FC<Props> = ({ selectedCell, counts }) => {
|
2022-01-19 06:07:32 +00:00
|
|
|
const { data, error } = useSWRImmutable(
|
2022-01-24 05:59:36 +00:00
|
|
|
`https://cells.modmapper.com/${selectedCell.x}/${selectedCell.y}.json`,
|
2022-03-18 05:06:20 +00:00
|
|
|
(_) => jsonFetcher<Cell>(_)
|
2022-01-19 06:07:32 +00:00
|
|
|
);
|
2022-01-19 06:06:19 +00:00
|
|
|
|
|
|
|
if (error && error.status === 404) {
|
|
|
|
return <div>Cell has no mod edits.</div>;
|
|
|
|
} else if (error) {
|
|
|
|
return <div>{`Error loading cell data: ${error.message}`}</div>;
|
|
|
|
}
|
|
|
|
if (data === undefined) return <div>Loading...</div>;
|
|
|
|
if (data === null) return <div>Cell has no edits.</div>;
|
|
|
|
|
2022-01-19 06:07:32 +00:00
|
|
|
return (
|
|
|
|
selectedCell && (
|
|
|
|
<>
|
2022-02-14 05:38:21 +00:00
|
|
|
<Head>
|
|
|
|
<title key="title">{`Modmapper - Cell ${data.x}, ${data.y}`}</title>
|
|
|
|
<meta
|
|
|
|
key="description"
|
|
|
|
name="description"
|
|
|
|
content={`Map of Skyrim showing ${data.mods_count} mods that edit cell ${data.x}, ${data.y}`}
|
|
|
|
/>
|
|
|
|
<meta
|
|
|
|
key="og:title"
|
|
|
|
property="og:title"
|
|
|
|
content={`Modmapper - Cell ${data.x}, ${data.y}`}
|
|
|
|
/>
|
|
|
|
<meta
|
|
|
|
key="og:description"
|
|
|
|
property="og:description"
|
|
|
|
content={`Map of Skyrim showing ${data.mods_count} mods that edit cell ${data.x}, ${data.y}`}
|
|
|
|
/>
|
|
|
|
<meta
|
|
|
|
key="twitter:title"
|
|
|
|
name="twitter:title"
|
|
|
|
content={`Modmapper - Cell ${data.x}, ${data.y}`}
|
|
|
|
/>
|
|
|
|
<meta
|
|
|
|
key="twitter:description"
|
|
|
|
name="twitter:description"
|
|
|
|
content={`Map of Skyrim showing ${data.mods_count} mods that edit cell ${data.x}, ${data.y}`}
|
|
|
|
/>
|
|
|
|
<meta
|
|
|
|
key="og:url"
|
|
|
|
property="og:url"
|
|
|
|
content={`https://modmapper.com/?cell=${encodeURIComponent(
|
|
|
|
`${data.x},${data.y}`
|
|
|
|
)}`}
|
|
|
|
/>
|
|
|
|
</Head>
|
2022-01-19 06:06:19 +00:00
|
|
|
<ul className={styles["cell-data-list"]}>
|
2022-01-19 06:07:32 +00:00
|
|
|
<li>
|
2022-02-07 03:09:24 +00:00
|
|
|
<strong>Form ID:</strong>{" "}
|
|
|
|
<span>{data.form_id.toString(16).padStart(8, "0")}</span>
|
2022-01-19 06:07:32 +00:00
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<strong>Mods that edit:</strong> <span>{data.mods_count}</span>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<strong>Files that edit:</strong> <span>{data.files_count}</span>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<strong>Plugins that edit:</strong>{" "}
|
|
|
|
<span>{data.plugins_count}</span>
|
|
|
|
</li>
|
2022-01-19 06:06:19 +00:00
|
|
|
</ul>
|
2022-03-10 05:59:13 +00:00
|
|
|
<PluginList selectedCell={selectedCell} />
|
2022-03-17 05:11:59 +00:00
|
|
|
<ModList mods={data.mods} counts={counts} />
|
2022-01-19 06:07:32 +00:00
|
|
|
</>
|
|
|
|
)
|
2022-01-19 06:06:19 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-01-19 06:07:32 +00:00
|
|
|
export default CellData;
|