From e11e2093b056a4c04c66de3c0c8b0bb3e24ad576 Mon Sep 17 00:00:00 2001 From: neru Date: Fri, 19 Jun 2026 04:05:38 -0300 Subject: [PATCH] style: move randInRange to utils --- app/items/ItemGrid.tsx | 2 +- app/items/OfferingGrid.tsx | 2 +- app/items/types.ts | 7 ------- lib/utils.ts | 29 +++++++++++++++++------------ 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/app/items/ItemGrid.tsx b/app/items/ItemGrid.tsx index 455e772..c783f97 100644 --- a/app/items/ItemGrid.tsx +++ b/app/items/ItemGrid.tsx @@ -4,7 +4,7 @@ import { useState, useMemo } from 'react'; import shared from '../../styles/shared.module.css'; import styles from '../../styles/Items.module.css'; import QuantityCard from '../../components/QuantityCard'; -import { Item, ItemType, ITEM_TYPE_LABELS, getItemType, getItemIconUrl, randInRange } from './types'; +import { Item, ItemType, ITEM_TYPE_LABELS, getItemType, getItemIconUrl } from './types'; type Props = { items: Item[]; diff --git a/app/items/OfferingGrid.tsx b/app/items/OfferingGrid.tsx index cef6ef6..514004a 100644 --- a/app/items/OfferingGrid.tsx +++ b/app/items/OfferingGrid.tsx @@ -4,7 +4,7 @@ import { useState, useMemo } from 'react'; import shared from '../../styles/shared.module.css'; import styles from '../../styles/Items.module.css'; import QuantityCard from '../../components/QuantityCard'; -import { Offering, OfferingRole, getOfferingIconUrl, randInRange } from './types'; +import { Offering, OfferingRole, getOfferingIconUrl } from './types'; type Props = { offerings: Offering[]; diff --git a/app/items/types.ts b/app/items/types.ts index 9416b1a..8902fcd 100644 --- a/app/items/types.ts +++ b/app/items/types.ts @@ -30,7 +30,6 @@ export const getItemType = (id: string): ItemType => { return 'other'; }; - export const getItemIconUrl = (iconFilePath: string) => { const file = (iconFilePath.split('/').pop() ?? '').split('.')[0]; return `${DB_BASE_URL}/icons/item-icons/${file}.png`; @@ -40,9 +39,3 @@ export const getOfferingIconUrl = (iconFilePath: string) => { const file = (iconFilePath.split('/').pop() ?? '').split('.')[0]; return `${DB_BASE_URL}/icons/offering-icons/${file}.png`; }; - -export const randInRange = (min: number, max: number) => { - const lo = Math.min(min, max); - const hi = Math.max(min, max); - return Math.floor(Math.random() * (hi - lo + 1)) + lo; -}; \ No newline at end of file diff --git a/lib/utils.ts b/lib/utils.ts index 33ca239..5985b81 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -1,22 +1,27 @@ export type DLC = { - id: string; - name: string | null; - dlcIds: { - steam: string; - epic: string; - grdk: string; - }; + id: string; + name: string | null; + dlcIds: { + steam: string; + epic: string; + grdk: string; + }; }; export const getFileName = (iconFilePath: string): string => { - const base = iconFilePath.split('/').pop() ?? ''; - return base.split('.')[0]; + const base = iconFilePath.split('/').pop() ?? ''; + return base.split('.')[0]; }; export const cleanFolderName = (name: string): string => - name.replace(/[\\/:*?"<>|]/g, '_'); + name.replace(/[\\/:*?"<>|]/g, '_'); export const isKiller = (idx: number): boolean => idx >= 268435456; -export const isNamedDLC = (dlc: DLC): dlc is DLC & { name: string } => - !!dlc.name && !dlc.name.startsWith('@'); \ No newline at end of file +export const isNamedDLC = (dlc: DLC): dlc is DLC & { name: string } => !!dlc.name && !dlc.name.startsWith('@'); + +export const randInRange = (min: number, max: number) => { + const lo = Math.min(min, max); + const hi = Math.max(min, max); + return Math.floor(Math.random() * (hi - lo + 1)) + lo; +}; \ No newline at end of file