Skip to content

Commit ecc043c

Browse files
committed
Improved fishhook info rendering logic
1 parent 817893a commit ecc043c

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

src/components/FishInfoHooks/FishInfoHooks.tsx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,24 @@ export const FishInfoHooks = (props: FishInfoHooksProps) => {
1212
[styles.FishInfoHooksCompact]: compact,
1313
})}
1414
>
15-
{hookSizes.map(size => (
16-
<div
17-
className={clsx(styles.FishInfoHooksCell, {
18-
[styles.FishInfoHooksCellBronze]: data[size] === 'b',
19-
[styles.FishInfoHooksCellSilver]: data[size] === 's',
20-
[styles.FishInfoHooksCellGold]: data[size] === 'g',
21-
[styles.FishInfoHooksCellDiamond]: data[size] === 'd',
22-
[styles.FishInfoHooksCellLegendary]: data[size] === 'l',
23-
})}
24-
key={size}
25-
>
26-
{size}
27-
</div>
28-
))}
15+
{hookSizes.map(size => {
16+
const value = typeof data !== 'undefined' && size in data ? data[size] : null;
17+
18+
return (
19+
<div
20+
className={clsx(styles.FishInfoHooksCell, {
21+
[styles.FishInfoHooksCellBronze]: value === 'b',
22+
[styles.FishInfoHooksCellSilver]: value === 's',
23+
[styles.FishInfoHooksCellGold]: value === 'g',
24+
[styles.FishInfoHooksCellDiamond]: value === 'd',
25+
[styles.FishInfoHooksCellLegendary]: value === 'l',
26+
})}
27+
key={size}
28+
>
29+
{size}
30+
</div>
31+
);
32+
})}
2933
</div>
3034
);
3135
};

src/components/FishInfoHooks/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import type { HookData } from 'types/data';
22

33
export interface FishInfoHooksProps {
44
compact?: boolean;
5-
data: HookData;
5+
data?: HookData;
66
}

0 commit comments

Comments
 (0)