mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 02:09:41 +00:00
Co-authored-by: ShadowLarkens <shadowlarkens@gmail.com> Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
90 lines
2.3 KiB
TypeScript
90 lines
2.3 KiB
TypeScript
import { useBackend } from 'tgui/backend';
|
|
import { Window } from 'tgui/layouts';
|
|
import {
|
|
Button,
|
|
Collapsible,
|
|
LabeledList,
|
|
Section,
|
|
Stack,
|
|
} from 'tgui-core/components';
|
|
import { toTitleCase } from 'tgui-core/string';
|
|
|
|
type Data = {
|
|
scanner: string[];
|
|
seeds: seed[];
|
|
};
|
|
|
|
type seed = {
|
|
name: string;
|
|
uid: string;
|
|
amount: number;
|
|
id: number;
|
|
traits: {
|
|
Endurance: string;
|
|
Yield: string;
|
|
Production: string;
|
|
Potency: string;
|
|
'Repeat Harvest': string;
|
|
'Ideal Heat': string;
|
|
'Ideal Light': string;
|
|
'Nutrient Consumption': string;
|
|
'Water Consumption': string;
|
|
notes: string;
|
|
};
|
|
};
|
|
|
|
export const SeedStorage = (props) => {
|
|
const { act, data } = useBackend<Data>();
|
|
|
|
const { seeds } = data;
|
|
|
|
seeds.sort((a, b) =>
|
|
a.name.toLowerCase().localeCompare(b.name.toLowerCase()),
|
|
);
|
|
|
|
return (
|
|
<Window width={600} height={760}>
|
|
<Window.Content scrollable>
|
|
<Section title="Seeds">
|
|
{seeds.map((seed) => (
|
|
<Stack mt={-1} key={seed.name + seed.uid}>
|
|
<Stack.Item basis="60%">
|
|
<Collapsible title={toTitleCase(seed.name) + ' #' + seed.uid}>
|
|
<Section width="165%" title="Traits">
|
|
<LabeledList>
|
|
{Object.keys(seed.traits).map((key) => (
|
|
<LabeledList.Item label={toTitleCase(key)} key={key}>
|
|
{seed.traits[key]}
|
|
</LabeledList.Item>
|
|
))}
|
|
</LabeledList>
|
|
</Section>
|
|
</Collapsible>
|
|
</Stack.Item>
|
|
<Stack.Item mt={0.4}>{seed.amount} Remaining</Stack.Item>
|
|
<Stack.Item grow>
|
|
<Button
|
|
fluid
|
|
icon="download"
|
|
onClick={() => act('vend', { id: seed.id })}
|
|
>
|
|
Vend
|
|
</Button>
|
|
</Stack.Item>
|
|
<Stack.Item grow>
|
|
<Button
|
|
fluid
|
|
icon="trash"
|
|
onClick={() => act('purge', { id: seed.id })}
|
|
>
|
|
Purge
|
|
</Button>
|
|
</Stack.Item>
|
|
</Stack>
|
|
))}
|
|
</Section>
|
|
</Window.Content>
|
|
</Window>
|
|
);
|
|
};
|