Implement planet exclusion from totals calculations
This commit is contained in:
@@ -3,3 +3,4 @@ EVE_SSO_CLIENT_ID=Client ID
|
||||
EVE_SSO_SECRET=Secret Key
|
||||
EVE_SSO_CALLBACK_URL=Callback URL (This should be the domain you are hosting at or if run locally it should be http://localhost:3000)
|
||||
NEXT_PUBLIC_PRAISAL_URL=https://praisal.avanto.tk/appraisal/structured.json?persist=no
|
||||
SENTRY_AUTH_TOKEN=Sentry token for error reporting.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { SessionContext, ColorContext } from "@/app/context/Context";
|
||||
import { ColorContext, SessionContext } from "@/app/context/Context";
|
||||
import { PI_TYPES_MAP } from "@/const";
|
||||
import { AccessToken, PlanetWithInfo } from "@/types";
|
||||
import { planetCalculations } from "@/planets";
|
||||
import { AccessToken, PlanetWithInfo } from "@/types";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import { Button, Tooltip, Typography, useTheme } from "@mui/material";
|
||||
import AppBar from "@mui/material/AppBar";
|
||||
@@ -16,9 +16,9 @@ import { DateTime } from "luxon";
|
||||
import Image from "next/image";
|
||||
import React, { forwardRef, useContext, useState } from "react";
|
||||
import Countdown from "react-countdown";
|
||||
import PinsCanvas3D from "./PinsCanvas3D";
|
||||
import { timeColor, alertModeVisibility } from "./timeColors";
|
||||
import { PlanetConfigDialog } from "../PlanetConfig/PlanetConfigDialog";
|
||||
import PinsCanvas3D from "./PinsCanvas3D";
|
||||
import { alertModeVisibility, timeColor } from "./timeColors";
|
||||
|
||||
const Transition = forwardRef(function Transition(
|
||||
props: TransitionProps & {
|
||||
@@ -62,6 +62,7 @@ export const PlanetTableRow = ({
|
||||
const planetInfoUniverse = planet.infoUniverse;
|
||||
const { expired, extractors, localProduction, localImports, localExports } =
|
||||
planetCalculations(planet);
|
||||
const planetConfig = character.planetConfig.find(p => p.planetId === planet.planet_id)
|
||||
const { colors } = useContext(ColorContext);
|
||||
return (
|
||||
<TableRow
|
||||
@@ -159,6 +160,18 @@ export const PlanetTableRow = ({
|
||||
))}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div style={{ display: "flex", flexDirection: "column" }}>
|
||||
{localExports.map((exports) => (
|
||||
<Typography
|
||||
key={`export-excluded-${character.character.characterId}-${planet.planet_id}-${exports.typeId}`}
|
||||
fontSize={theme.custom.smallText}
|
||||
>
|
||||
{planetConfig?.excludeFromTotals ? 'ex' : ''}
|
||||
</Typography>
|
||||
))}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div style={{ display: "flex", flexDirection: "column" }}>
|
||||
{localExports.map((exports) => (
|
||||
|
@@ -77,6 +77,11 @@ const PlanetaryIteractionTable = ({
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
</TableCell>
|
||||
<TableCell width="2%">
|
||||
<Tooltip title="Is planet ecluded from totals">
|
||||
<Typography fontSize={theme.custom.smallText}>Excluded</Typography>
|
||||
</Tooltip>
|
||||
</TableCell>
|
||||
<TableCell width="2%">
|
||||
<Tooltip title="How many units per hour factories are producing">
|
||||
<Typography fontSize={theme.custom.smallText}>u/h</Typography>
|
||||
|
@@ -40,9 +40,10 @@ const displayValue = (valueInMillions: number): string =>
|
||||
: `${valueInMillions.toFixed(2)} M`;
|
||||
|
||||
export const Summary = ({ characters }: { characters: AccessToken[] }) => {
|
||||
const { piPrices, alertMode } = useContext(SessionContext);
|
||||
const { piPrices } = useContext(SessionContext);
|
||||
const exports = characters.flatMap((char) => {
|
||||
return char.planets.flatMap((planet) => {
|
||||
return char.planets.filter(p => !char.planetConfig.some(c => c.planetId == p.planet_id && c.excludeFromTotals))
|
||||
.flatMap((planet) => {
|
||||
const { localExports } = planetCalculations(planet);
|
||||
return localExports;
|
||||
});
|
||||
|
@@ -145,7 +145,18 @@ const Home = () => {
|
||||
};
|
||||
|
||||
const updatePlanetConfig = (config: PlanetConfig) => {
|
||||
console.log("poop");
|
||||
const charactersToSave = characters.map((c) => {
|
||||
if (c.character.characterId === config.characterId) {
|
||||
return {
|
||||
...c,
|
||||
planetConfig: [...c.planetConfig.filter(p => p.planetId !== config.planetId), config]
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
});
|
||||
setCharacters(charactersToSave);
|
||||
saveCharacters(charactersToSave);
|
||||
};
|
||||
|
||||
const readPlanetConfig = ({
|
||||
@@ -157,7 +168,7 @@ const Home = () => {
|
||||
}): PlanetConfig => {
|
||||
const defaultConfig = { planetId, characterId, excludeFromTotals: false };
|
||||
|
||||
return defaultConfig;
|
||||
return characters.find(c => c.character.characterId === characterId)?.planetConfig.find(p => p.planetId === planetId) ?? defaultConfig
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
@@ -34,7 +34,6 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
headers,
|
||||
}).then((res) => res.json());
|
||||
const character = extractCharacterFromToken(response);
|
||||
|
||||
const token: AccessToken = {
|
||||
access_token: response.access_token,
|
||||
token_type: response.token_type,
|
||||
@@ -49,6 +48,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
comment: accessToken.comment,
|
||||
system: accessToken.system,
|
||||
planets: [],
|
||||
planetConfig: accessToken.planetConfig ?? [],
|
||||
};
|
||||
|
||||
console.log("Refresh", character.name, character.characterId);
|
||||
|
@@ -50,6 +50,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
comment: "",
|
||||
system: "",
|
||||
planets: [],
|
||||
planetConfig: [],
|
||||
};
|
||||
res.json(token);
|
||||
} else {
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import { PlanetConfig } from "./app/components/PlanetConfig/PlanetConfigDialog";
|
||||
import { Api } from "./esi-api";
|
||||
|
||||
export interface AccessToken {
|
||||
@@ -11,6 +12,7 @@ export interface AccessToken {
|
||||
comment: string;
|
||||
system: string;
|
||||
planets: PlanetWithInfo[];
|
||||
planetConfig: PlanetConfig[];
|
||||
}
|
||||
|
||||
export interface Character {
|
||||
|
Reference in New Issue
Block a user