mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
fix: add tanks to compare on load
This commit is contained in:
1 parent
fa9ed570ce
commit
2fd9205662
1 file changed
+24
-1
@@ -4,15 +4,17 @@ import {
|
|||||||
fetchModelDefinitions,
|
fetchModelDefinitions,
|
||||||
fetchProvisionDefinitions,
|
fetchProvisionDefinitions,
|
||||||
fetchSkillDefinitions,
|
fetchSkillDefinitions,
|
||||||
|
fetchTankDefinitions,
|
||||||
} from '@blitzkit/core';
|
} from '@blitzkit/core';
|
||||||
import { PlusIcon } from '@radix-ui/react-icons';
|
import { PlusIcon } from '@radix-ui/react-icons';
|
||||||
import { Box, Flex, Heading, IconButton, Text } from '@radix-ui/themes';
|
import { Box, Flex, Heading, IconButton, Text } from '@radix-ui/themes';
|
||||||
import { useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
import { CompareTable } from '../../../components/Compare/CompareTable';
|
import { CompareTable } from '../../../components/Compare/CompareTable';
|
||||||
import { Controls } from '../../../components/Compare/Controls';
|
import { Controls } from '../../../components/Compare/Controls';
|
||||||
import { DamageWarning } from '../../../components/DamageWarning';
|
import { DamageWarning } from '../../../components/DamageWarning';
|
||||||
import { PageWrapper } from '../../../components/PageWrapper';
|
import { PageWrapper } from '../../../components/PageWrapper';
|
||||||
import { tankCharacteristics } from '../../../core/blitzkit/tankCharacteristics';
|
import { tankCharacteristics } from '../../../core/blitzkit/tankCharacteristics';
|
||||||
|
import { tankToCompareMember } from '../../../core/blitzkit/tankToCompareMember';
|
||||||
import { App } from '../../../stores/app';
|
import { App } from '../../../stores/app';
|
||||||
import { CompareEphemeral } from '../../../stores/compareEphemeral';
|
import { CompareEphemeral } from '../../../stores/compareEphemeral';
|
||||||
import { ComparePersistent } from '../../../stores/comparePersistent';
|
import { ComparePersistent } from '../../../stores/comparePersistent';
|
||||||
@@ -21,6 +23,7 @@ const modelDefinitions = await fetchModelDefinitions();
|
|||||||
const equipmentDefinitions = await fetchEquipmentDefinitions();
|
const equipmentDefinitions = await fetchEquipmentDefinitions();
|
||||||
const provisionDefinitions = await fetchProvisionDefinitions();
|
const provisionDefinitions = await fetchProvisionDefinitions();
|
||||||
const skillDefinitions = await fetchSkillDefinitions();
|
const skillDefinitions = await fetchSkillDefinitions();
|
||||||
|
const tankDefinitions = await fetchTankDefinitions();
|
||||||
|
|
||||||
export function Page() {
|
export function Page() {
|
||||||
return (
|
return (
|
||||||
@@ -74,6 +77,26 @@ function Content() {
|
|||||||
),
|
),
|
||||||
[members, crewSkills],
|
[members, crewSkills],
|
||||||
);
|
);
|
||||||
|
const mutateCompareEphemeral = CompareEphemeral.useMutation();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const search = new URLSearchParams(window.location.search);
|
||||||
|
const tanksQuery = search.get('tanks');
|
||||||
|
|
||||||
|
if (tanksQuery === null) return;
|
||||||
|
|
||||||
|
const tanks = tanksQuery.split(',').map(Number);
|
||||||
|
|
||||||
|
mutateCompareEphemeral((draft) => {
|
||||||
|
tanks.forEach((id) => {
|
||||||
|
const tank = tankDefinitions.tanks[id];
|
||||||
|
|
||||||
|
if (tank === undefined) return;
|
||||||
|
|
||||||
|
draft.members.push(tankToCompareMember(tank, provisionDefinitions));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageWrapper color="crimson" size="100%">
|
<PageWrapper color="crimson" size="100%">
|
||||||
|
|||||||
Reference in new issue
Block a user