Skip to content

Commit 60f78e7

Browse files
committed
feat: pass allStats to LoadoutCard and Loadouts components for enhanced stats handling
1 parent 674c1ca commit 60f78e7

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

‎src/lib/components/stats/LoadoutCard.svelte‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import EmptyItemSlot from "$lib/components/item/EmptyItemSlot.svelte";
44
import GearSlotColumn from "$lib/components/item/GearSlotColumn.svelte";
55
import Item from "$lib/components/item/Item.svelte";
6-
import type { ModelsResolvedLoadout } from "$lib/shared/api/orval-generated";
6+
import type { ModelsResolvedLoadout, ModelsStatData } from "$lib/shared/api/orval-generated";
77
import { titleCase } from "$lib/shared/helper";
88
import { cn } from "$lib/shared/utils";
9-
import { getAllStats } from "$src/lib/shared/api/skycrypt-api.remote";
109
import { Separator } from "$ui/separator";
1110
1211
type Props = {
1312
loadout: ModelsResolvedLoadout;
1413
index: number;
14+
allStats: ModelsStatData[];
1515
class?: string;
1616
};
1717
@@ -22,16 +22,14 @@
2222
walk_speed: "speed"
2323
} as const;
2424
25-
let { loadout, index, class: className }: Props = $props();
25+
let { loadout, index, allStats, class: className }: Props = $props();
2626
2727
const name = $derived(loadout.name?.trim() || `Loadout ${index + 1}`);
2828
const armor = $derived(loadout.armor ?? []);
2929
const equipment = $derived(loadout.equipment ?? []);
3030
const pet = $derived(loadout.pet);
3131
const tuningPoints = $derived(Object.entries(loadout.accessories?.tuningPoints ?? {}));
3232
const powerStone = $derived(loadout.accessories?.powerStone ? titleCase(loadout.accessories.powerStone) : "None");
33-
const allStats = await getAllStats();
34-
3533
function selectedSlot(value: number | undefined): string {
3634
return value ? value.toString() : "None";
3735
}

‎src/lib/components/stats/Loadouts.svelte‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<script lang="ts">
2-
import type { ModelsResolvedLoadout } from "$lib/shared/api/orval-generated";
2+
import type { ModelsResolvedLoadout, ModelsStatData } from "$lib/shared/api/orval-generated";
33
import { ScrollArea } from "$ui/scroll-area";
44
import LoadoutCard from "./LoadoutCard.svelte";
55
66
type Props = {
77
loadouts: ModelsResolvedLoadout[];
8+
allStats?: ModelsStatData[];
89
};
910
10-
let { loadouts }: Props = $props();
11+
let { loadouts, allStats = [] }: Props = $props();
1112
1213
function loadoutKey(loadout: ModelsResolvedLoadout | undefined, index: number): string {
1314
return `${loadout?.id ?? "loadout"}-${index}`;
@@ -21,7 +22,7 @@
2122
viewportClasses="rounded-xl pr-4 scroll-fade-track-y">
2223
<div class="grid grid-cols-1 gap-4 lg:grid-cols-2">
2324
{#each loadouts as loadout, index (loadoutKey(loadout, index))}
24-
<LoadoutCard {loadout} {index} />
25+
<LoadoutCard {loadout} {index} {allStats} />
2526
{/each}
2627
</div>
2728
<div

‎src/lib/sections/stats/Gear.svelte‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import { cn } from "$lib/shared/utils";
1111
import ScrollAreaItems from "$src/lib/components/ScrollAreaItems.svelte";
1212
import SectionSubtitle from "$src/lib/components/sections/SectionSubtitle.svelte";
13+
import { getAllStats } from "$src/lib/shared/api/skycrypt-api.remote";
1314
import ShieldIcon from "@lucide/svelte/icons/shield";
1415
import ShirtIcon from "@lucide/svelte/icons/shirt";
1516
import SwordIcon from "@lucide/svelte/icons/sword";
@@ -23,6 +24,7 @@
2324
const equipmentWardrobe = $derived(gear?.equipmentWardrobe);
2425
const weapons = $derived(gear?.weapons);
2526
const loadouts = $derived(getCombinedContext().current?.loadouts ?? []);
27+
const allStats = await getAllStats();
2628
const armorSlots = ["helmet", "chestplate", "leggings", "boots"] as const;
2729
const firstWardrobeItems = $derived.by(() => {
2830
if (wardrobe?.length === 0) return [];
@@ -94,7 +96,7 @@
9496
{#if loadouts.length > 0}
9597
<div class="space-y-4 rounded-xl border p-4">
9698
<SectionSubtitle>Loadouts</SectionSubtitle>
97-
<Loadouts {loadouts} />
99+
<Loadouts {loadouts} {allStats} />
98100
</div>
99101
{/if}
100102

0 commit comments

Comments
 (0)