import Head from "next/head"; import React from "react"; import useSWRImmutable from "swr/immutable"; import styles from "../styles/CellData.module.css"; import ModList from "./ModList"; import ParsedPluginsList from "./ParsedPluginsList"; import { jsonFetcher } from "../lib/api"; import FetchedPluginsList from "./FetchedPluginsList"; export interface Mod { id: number; name: string; nexus_mod_id: number; author_name: string; author_id: number; category_name: string; category_id: number; description: string; thumbnail_link: string; game_id: number; is_translation: boolean; updated_at: string; created_at: string; last_update_at: string; first_upload_at: string; last_updated_files_at: string; } 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 = { selectedCell: { x: number; y: number }; }; const CellData: React.FC = ({ selectedCell }) => { const { data, error } = useSWRImmutable( `https://cells.modmapper.com/${selectedCell.x}/${selectedCell.y}.json`, (_) => jsonFetcher(_) ); if (error && error.status === 404) { return
Cell has no mod edits.
; } else if (error) { return
{`Error loading cell data: ${error.message}`}
; } if (data === undefined) return
Loading...
; if (data === null) return
Cell has no edits.
; return ( selectedCell && ( <> {`Modmapper - Cell ${data.x}, ${data.y}`} ) ); }; export default CellData;