Sort storages
This commit is contained in:
@@ -418,50 +418,55 @@ export const PlanetTableRow = ({
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{planetDetails.storageInfo.map((storage: StorageInfo, idx: number) => {
|
{planetDetails.storageInfo
|
||||||
const isLaunchpad = LAUNCHPAD_IDS.includes(storage.type_id);
|
.map(storage => ({
|
||||||
const fillRate = storage.fillRate;
|
...storage,
|
||||||
const color = fillRate > 90 ? '#ff0000' : fillRate > 80 ? '#ffa500' : fillRate > 60 ? '#ffd700' : 'inherit';
|
isLaunchpad: LAUNCHPAD_IDS.includes(storage.type_id)
|
||||||
const contents = planet.info.pins.find(p => p.type_id === storage.type_id)?.contents || [];
|
}))
|
||||||
|
.sort((a, b) => (b.isLaunchpad ? 1 : 0) - (a.isLaunchpad ? 1 : 0))
|
||||||
|
.map((storage, idx) => {
|
||||||
|
const fillRate = storage.fillRate;
|
||||||
|
const color = fillRate > 90 ? '#ff0000' : fillRate > 80 ? '#ffa500' : fillRate > 60 ? '#ffd700' : 'inherit';
|
||||||
|
const contents = planet.info.pins.find(p => p.type_id === storage.type_id)?.contents || [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment key={`storage-${character.character.characterId}-${planet.planet_id}-${storage.type}-${idx}`}>
|
<React.Fragment key={`storage-${character.character.characterId}-${planet.planet_id}-${storage.type}-${idx}`}>
|
||||||
<TableRow>
|
|
||||||
<TableCell>{isLaunchpad ? 'Launchpad' : 'Storage'}</TableCell>
|
|
||||||
<TableCell align="right">{storage.capacity.toFixed(1)} m³</TableCell>
|
|
||||||
<TableCell align="right">{storage.used.toFixed(1)} m³</TableCell>
|
|
||||||
<TableCell align="right" sx={{ color }}>{fillRate.toFixed(1)}%</TableCell>
|
|
||||||
<TableCell align="right">
|
|
||||||
{storage.value > 0 ? (
|
|
||||||
storage.value >= 1000000000
|
|
||||||
? `${(storage.value / 1000000000).toFixed(2)} B`
|
|
||||||
: `${(storage.value / 1000000).toFixed(0)} M`
|
|
||||||
) : '-'} ISK
|
|
||||||
</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
{contents.length > 0 && (
|
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell colSpan={5} sx={{ pt: 0, pb: 0 }}>
|
<TableCell>{storage.isLaunchpad ? 'Launchpad' : 'Storage'}</TableCell>
|
||||||
<Table size="small">
|
<TableCell align="right">{storage.capacity.toFixed(1)} m³</TableCell>
|
||||||
<TableBody>
|
<TableCell align="right">{storage.used.toFixed(1)} m³</TableCell>
|
||||||
{contents.map((content, idy) => (
|
<TableCell align="right" sx={{ color }}>{fillRate.toFixed(1)}%</TableCell>
|
||||||
<TableRow key={`content-${character.character.characterId}-${planet.planet_id}-${storage.type}-${content.type_id}-${idx}-${idy}`}>
|
<TableCell align="right">
|
||||||
<TableCell sx={{ pl: 2 }}>
|
{storage.value > 0 ? (
|
||||||
{PI_TYPES_MAP[content.type_id]?.name}
|
storage.value >= 1000000000
|
||||||
</TableCell>
|
? `${(storage.value / 1000000000).toFixed(2)} B`
|
||||||
<TableCell align="right" colSpan={4}>
|
: `${(storage.value / 1000000).toFixed(0)} M`
|
||||||
{content.amount.toFixed(1)} units
|
) : '-'} ISK
|
||||||
</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
))}
|
|
||||||
</TableBody>
|
|
||||||
</Table>
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
)}
|
{contents.length > 0 && (
|
||||||
</React.Fragment>
|
<TableRow>
|
||||||
);
|
<TableCell colSpan={5} sx={{ pt: 0, pb: 0 }}>
|
||||||
})}
|
<Table size="small">
|
||||||
|
<TableBody>
|
||||||
|
{contents.map((content, idy) => (
|
||||||
|
<TableRow key={`content-${character.character.characterId}-${planet.planet_id}-${storage.type}-${content.type_id}-${idx}-${idy}`}>
|
||||||
|
<TableCell sx={{ pl: 2 }}>
|
||||||
|
{PI_TYPES_MAP[content.type_id]?.name}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell align="right" colSpan={4}>
|
||||||
|
{content.amount.toFixed(1)} units
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
)}
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -481,27 +486,32 @@ export const PlanetTableRow = ({
|
|||||||
>
|
>
|
||||||
<div style={{ display: "flex", flexDirection: "column" }}>
|
<div style={{ display: "flex", flexDirection: "column" }}>
|
||||||
{planetDetails.storageInfo.length === 0 &&<Typography fontSize={theme.custom.smallText}>No storage</Typography>}
|
{planetDetails.storageInfo.length === 0 &&<Typography fontSize={theme.custom.smallText}>No storage</Typography>}
|
||||||
{planetDetails.storageInfo.map((storage: StorageInfo, idx: number) => {
|
{planetDetails.storageInfo
|
||||||
const isLaunchpad = LAUNCHPAD_IDS.includes(storage.type_id);
|
.map(storage => ({
|
||||||
const fillRate = storage.fillRate;
|
...storage,
|
||||||
const color = fillRate > 90 ? '#ff0000' : fillRate > 80 ? '#ffa500' : fillRate > 60 ? '#ffd700' : 'inherit';
|
isLaunchpad: LAUNCHPAD_IDS.includes(storage.type_id)
|
||||||
|
}))
|
||||||
|
.sort((a, b) => (b.isLaunchpad ? 1 : 0) - (a.isLaunchpad ? 1 : 0))
|
||||||
|
.map((storage, idx) => {
|
||||||
|
const fillRate = storage.fillRate;
|
||||||
|
const color = fillRate > 90 ? '#ff0000' : fillRate > 80 ? '#ffa500' : fillRate > 60 ? '#ffd700' : 'inherit';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={`storage-${character.character.characterId}-${planet.planet_id}-${storage.type}-${idx}`} style={{ display: "flex", alignItems: "center" }}>
|
<div key={`storage-${character.character.characterId}-${planet.planet_id}-${storage.type}-${idx}`} style={{ display: "flex", alignItems: "center" }}>
|
||||||
<Typography fontSize={theme.custom.smallText} style={{ marginRight: "5px" }}>
|
<Typography fontSize={theme.custom.smallText} style={{ marginRight: "5px" }}>
|
||||||
{isLaunchpad ? 'L' : 'S'}
|
{storage.isLaunchpad ? 'L' : 'S'}
|
||||||
</Typography>
|
|
||||||
<Typography fontSize={theme.custom.smallText} style={{ color }}>
|
|
||||||
{fillRate.toFixed(1)}%
|
|
||||||
</Typography>
|
|
||||||
{storage.value > 0 && (
|
|
||||||
<Typography fontSize={theme.custom.smallText} style={{ marginLeft: "5px" }}>
|
|
||||||
({Math.round(storage.value / 1000000)}M)
|
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
<Typography fontSize={theme.custom.smallText} style={{ color }}>
|
||||||
</div>
|
{fillRate.toFixed(1)}%
|
||||||
);
|
</Typography>
|
||||||
})}
|
{storage.value > 0 && (
|
||||||
|
<Typography fontSize={theme.custom.smallText} style={{ marginLeft: "5px" }}>
|
||||||
|
({Math.round(storage.value / 1000000)}M)
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
Reference in New Issue
Block a user