|
|
|
|
@@ -1,5 +1,5 @@
|
|
|
|
|
import { ColorContext, SessionContext } from "@/app/context/Context";
|
|
|
|
|
import { PI_TYPES_MAP, STORAGE_IDS, STORAGE_CAPACITIES, PI_PRODUCT_VOLUMES, EVE_IMAGE_URL, PI_SCHEMATICS } from "@/const";
|
|
|
|
|
import { PI_TYPES_MAP, STORAGE_IDS, STORAGE_CAPACITIES, PI_PRODUCT_VOLUMES, EVE_IMAGE_URL, PI_SCHEMATICS, LAUNCHPAD_IDS } from "@/const";
|
|
|
|
|
import { planetCalculations } from "@/planets";
|
|
|
|
|
import { AccessToken, PlanetWithInfo } from "@/types";
|
|
|
|
|
import CloseIcon from "@mui/icons-material/Close";
|
|
|
|
|
@@ -351,8 +351,12 @@ export const PlanetTableRow = ({
|
|
|
|
|
const cycleTime = schematic?.cycle_time ?? 3600;
|
|
|
|
|
const consumptionPerHour = i.quantity * i.factoryCount * (3600 / cycleTime);
|
|
|
|
|
|
|
|
|
|
// Calculate time until depletion in hours
|
|
|
|
|
const hoursUntilDepletion = consumptionPerHour > 0 ? totalAmount / consumptionPerHour : 0;
|
|
|
|
|
// Calculate time until depletion in hours, starting from last_update
|
|
|
|
|
const lastUpdate = DateTime.fromISO(planet.last_update);
|
|
|
|
|
const now = DateTime.now();
|
|
|
|
|
const hoursSinceUpdate = now.diff(lastUpdate, 'hours').hours;
|
|
|
|
|
const remainingAmount = Math.max(0, totalAmount - (consumptionPerHour * hoursSinceUpdate));
|
|
|
|
|
const hoursUntilDepletion = consumptionPerHour > 0 ? remainingAmount / consumptionPerHour : 0;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
@@ -363,7 +367,9 @@ export const PlanetTableRow = ({
|
|
|
|
|
{totalAmount > 0 && (
|
|
|
|
|
<Tooltip title={
|
|
|
|
|
<>
|
|
|
|
|
<div>Total: {totalAmount.toFixed(1)} units</div>
|
|
|
|
|
<div>Total in storage: {totalAmount.toFixed(1)} units</div>
|
|
|
|
|
<div>Consumption rate: {consumptionPerHour.toFixed(1)} units/hour</div>
|
|
|
|
|
<div>Last update: {lastUpdate.toFormat('yyyy-MM-dd HH:mm:ss')}</div>
|
|
|
|
|
<div>Will be depleted in {hoursUntilDepletion.toFixed(1)} hours</div>
|
|
|
|
|
</>
|
|
|
|
|
}>
|
|
|
|
|
@@ -460,25 +466,18 @@ export const PlanetTableRow = ({
|
|
|
|
|
{storageFacilities.length === 0 &&<Typography fontSize={theme.custom.smallText}>No storage</Typography>}
|
|
|
|
|
{storageFacilities
|
|
|
|
|
.sort((a, b) => {
|
|
|
|
|
const isALaunchpad = a.type_id === 2256 || a.type_id === 2542 || a.type_id === 2543 || a.type_id === 2544 || a.type_id === 2552 || a.type_id === 2555 || a.type_id === 2556 || a.type_id === 2557;
|
|
|
|
|
const isBLaunchpad = b.type_id === 2256 || b.type_id === 2542 || b.type_id === 2543 || b.type_id === 2544 || b.type_id === 2552 || b.type_id === 2555 || b.type_id === 2556 || b.type_id === 2557;
|
|
|
|
|
const isALaunchpad = LAUNCHPAD_IDS.includes(a.type_id);
|
|
|
|
|
const isBLaunchpad = LAUNCHPAD_IDS.includes(b.type_id);
|
|
|
|
|
return isALaunchpad === isBLaunchpad ? 0 : isALaunchpad ? -1 : 1;
|
|
|
|
|
})
|
|
|
|
|
.map((storage) => {
|
|
|
|
|
const storageInfo = getStorageInfo(storage);
|
|
|
|
|
if (!storageInfo) return null;
|
|
|
|
|
|
|
|
|
|
const isLaunchpad = storage.type_id === 2256 ||
|
|
|
|
|
storage.type_id === 2542 ||
|
|
|
|
|
storage.type_id === 2543 ||
|
|
|
|
|
storage.type_id === 2544 ||
|
|
|
|
|
storage.type_id === 2552 ||
|
|
|
|
|
storage.type_id === 2555 ||
|
|
|
|
|
storage.type_id === 2556 ||
|
|
|
|
|
storage.type_id === 2557;
|
|
|
|
|
const isLaunchpad = LAUNCHPAD_IDS.includes(storage.type_id);
|
|
|
|
|
|
|
|
|
|
const fillRate = storageInfo.fillRate;
|
|
|
|
|
const color = fillRate > 95 ? '#ff0000' : fillRate > 80 ? '#ffd700' : 'inherit';
|
|
|
|
|
const color = fillRate > 90 ? '#ff0000' : fillRate > 80 ? '#ffa500' : fillRate > 60 ? '#ffd700' : 'inherit';
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div key={`storage-${character.character.characterId}-${planet.planet_id}-${storage.pin_id}`} style={{ display: "flex", alignItems: "center" }}>
|
|
|
|
|
|