Remove console.logs
This commit is contained in:
parent
a1f2cc830a
commit
a5e2c4a8c8
@ -1,5 +1,5 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import useSWRImmutable from 'swr/immutable';
|
import useSWRImmutable from "swr/immutable";
|
||||||
|
|
||||||
import styles from "../styles/CellData.module.css";
|
import styles from "../styles/CellData.module.css";
|
||||||
import CellModList from "./CellModList";
|
import CellModList from "./CellModList";
|
||||||
@ -10,16 +10,16 @@ export interface Mod {
|
|||||||
nexus_mod_id: number;
|
nexus_mod_id: number;
|
||||||
author_name: string;
|
author_name: string;
|
||||||
author_id: number;
|
author_id: number;
|
||||||
category_name: string,
|
category_name: string;
|
||||||
category_id: number,
|
category_id: number;
|
||||||
description: string,
|
description: string;
|
||||||
thumbnail_link: string,
|
thumbnail_link: string;
|
||||||
game_id: number,
|
game_id: number;
|
||||||
updated_at: string,
|
updated_at: string;
|
||||||
created_at: string,
|
created_at: string;
|
||||||
last_update_at: string;
|
last_update_at: string;
|
||||||
first_upload_at: string;
|
first_upload_at: string;
|
||||||
last_updated_files_at: string,
|
last_updated_files_at: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Cell {
|
export interface Cell {
|
||||||
@ -40,38 +40,51 @@ const jsonFetcher = async (url: string): Promise<Cell | null> => {
|
|||||||
if (res.status === 404) {
|
if (res.status === 404) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const error = new Error('An error occurred while fetching the data.')
|
const error = new Error("An error occurred while fetching the data.");
|
||||||
throw error
|
throw error;
|
||||||
}
|
}
|
||||||
return res.json();
|
return res.json();
|
||||||
}
|
};
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
selectedCell: [number, number];
|
selectedCell: [number, number];
|
||||||
};
|
};
|
||||||
|
|
||||||
const CellData: React.FC<Props> = ({ selectedCell }) => {
|
const CellData: React.FC<Props> = ({ selectedCell }) => {
|
||||||
const { data, error } = useSWRImmutable(`https://cells.modmapper.com/${selectedCell[0]}/${selectedCell[1]}.json`, jsonFetcher);
|
const { data, error } = useSWRImmutable(
|
||||||
|
`https://cells.modmapper.com/${selectedCell[0]}/${selectedCell[1]}.json`,
|
||||||
|
jsonFetcher
|
||||||
|
);
|
||||||
|
|
||||||
if (error && error.status === 404) {
|
if (error && error.status === 404) {
|
||||||
return <div>Cell has no mod edits.</div>;
|
return <div>Cell has no mod edits.</div>;
|
||||||
} else if (error) {
|
} else if (error) {
|
||||||
console.log(error);
|
|
||||||
return <div>{`Error loading cell data: ${error.message}`}</div>;
|
return <div>{`Error loading cell data: ${error.message}`}</div>;
|
||||||
}
|
}
|
||||||
if (data === undefined) return <div>Loading...</div>;
|
if (data === undefined) return <div>Loading...</div>;
|
||||||
if (data === null) return <div>Cell has no edits.</div>;
|
if (data === null) return <div>Cell has no edits.</div>;
|
||||||
|
|
||||||
return selectedCell && (
|
return (
|
||||||
<>
|
selectedCell && (
|
||||||
|
<>
|
||||||
<ul className={styles["cell-data-list"]}>
|
<ul className={styles["cell-data-list"]}>
|
||||||
<li><strong>Form ID:</strong> <span>{data.form_id}</span></li>
|
<li>
|
||||||
<li><strong>Mods that edit:</strong> <span>{data.mods_count}</span></li>
|
<strong>Form ID:</strong> <span>{data.form_id}</span>
|
||||||
<li><strong>Files that edit:</strong> <span>{data.files_count}</span></li>
|
</li>
|
||||||
<li><strong>Plugins that edit:</strong> <span>{data.plugins_count}</span></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>
|
||||||
</ul>
|
</ul>
|
||||||
<CellModList mods={data.mods} />
|
<CellModList mods={data.mods} />
|
||||||
</>
|
</>
|
||||||
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,11 +32,9 @@ const CellModList: React.FC<Props> = ({ mods }) => {
|
|||||||
const counts = data
|
const counts = data
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.map((line) => line.split(",").map((count) => parseInt(count, 10)));
|
.map((line) => line.split(",").map((count) => parseInt(count, 10)));
|
||||||
console.log(counts);
|
|
||||||
|
|
||||||
const modsWithCounts: ModWithCounts[] = mods.map((mod) => {
|
const modsWithCounts: ModWithCounts[] = mods.map((mod) => {
|
||||||
const modCounts = counts.find((count) => count[0] === mod.nexus_mod_id);
|
const modCounts = counts.find((count) => count[0] === mod.nexus_mod_id);
|
||||||
console.log(mod.nexus_mod_id, modCounts);
|
|
||||||
return {
|
return {
|
||||||
...mod,
|
...mod,
|
||||||
total_downloads: modCounts ? modCounts[1] : 0,
|
total_downloads: modCounts ? modCounts[1] : 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user