Files
blitzkit/packages/website/src/components/Embeds/breakdown.tsx
T

42 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-10-05 23:20:04 -05:00
import { compositeStatsKeys, fetchTankDefinitions } from '@blitzkit/core';
2024-09-07 21:45:00 -05:00
import strings from '@blitzkit/core/lang/en-US.json';
2024-10-05 23:20:04 -05:00
import { breakdownConfig } from '../../constants/embeds';
import { useEmbedStateCurry } from '../../stores/embedState/utilities';
import { BreakdownEmbedCard, BreakdownEmbedWrapper } from '../TanksEmbed';
2024-08-08 14:18:22 -05:00
2024-09-08 21:52:12 -05:00
export const compositeStatsKeysOptions = compositeStatsKeys.map((value) => ({
2024-08-10 13:29:10 -05:00
label: strings.common.composite_stats[value],
value,
}));
2024-10-05 23:20:04 -05:00
const tanks = await fetchTankDefinitions().then((tanks) =>
Object.values(tanks.tanks),
);
2024-08-08 14:18:22 -05:00
export function BreakdownPreview() {
const { useState } = useEmbedStateCurry<typeof breakdownConfig>();
return (
<BreakdownEmbedWrapper>
{useState('showTotal') && <BreakdownEmbedCard tank={null} />}
{tanks.slice(0, useState('listMaxTanks')).map((tank) => (
<BreakdownEmbedCard key={tank.id} tank={tank} />
))}
</BreakdownEmbedWrapper>
);
}
2024-10-27 22:29:28 -05:00
export function BreakdownRenderer() {
const { useState } = useEmbedStateCurry<typeof breakdownConfig>();
2024-10-27 22:38:14 -05:00
return (
<BreakdownEmbedWrapper>
{useState('showTotal') && <BreakdownEmbedCard tank={null} />}
{tanks.slice(0, useState('listMaxTanks')).map((tank) => (
<BreakdownEmbedCard key={tank.id} tank={tank} />
))}
</BreakdownEmbedWrapper>
);
2024-10-27 22:29:28 -05:00
}