From 402d054b30287857c97a11d2c99134c344258c4a Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Mon, 18 May 2026 17:08:12 -0500 Subject: [PATCH] stuff icon --- packages/website-ue/src/api/abstract.ts | 1 + packages/website-ue/src/api/client.ts | 5 +++ packages/website-ue/src/api/server.ts | 9 ++++- .../website-ue/src/components/Price/index.tsx | 39 ++++++++++++++----- .../src/pages/[api]/currencies/[id].webp.ts | 2 +- .../src/pages/[api]/stuff/[id].webp.ts | 14 +++++++ 6 files changed, 59 insertions(+), 11 deletions(-) create mode 100644 packages/website-ue/src/pages/[api]/stuff/[id].webp.ts diff --git a/packages/website-ue/src/api/abstract.ts b/packages/website-ue/src/api/abstract.ts index e9805ccf9..8fda066bc 100644 --- a/packages/website-ue/src/api/abstract.ts +++ b/packages/website-ue/src/api/abstract.ts @@ -46,6 +46,7 @@ export abstract class AbstractAPI { abstract backgrounds(): Promise; abstract currencyIcon(id: string): Promise; + abstract stuffIcon(id: string): Promise; private assertLocale(locale: string) { const supported = locales.supported.find( diff --git a/packages/website-ue/src/api/client.ts b/packages/website-ue/src/api/client.ts index 68353dda8..002d82bc9 100644 --- a/packages/website-ue/src/api/client.ts +++ b/packages/website-ue/src/api/client.ts @@ -116,6 +116,11 @@ export class ClientAPI extends AbstractAPI { currencyIcon() { return rejected(); } + + @UnimplementedOnClient + stuffIcon() { + return rejected(); + } } function UnimplementedOnClient( diff --git a/packages/website-ue/src/api/server.ts b/packages/website-ue/src/api/server.ts index 6367a5f05..24328da8f 100644 --- a/packages/website-ue/src/api/server.ts +++ b/packages/website-ue/src/api/server.ts @@ -388,9 +388,16 @@ export class ServerAPI extends AbstractAPI { @Cache() async currencyIcon(id: string) { - const item = this.metadata.item(`CurrencyEntity.${id}`); + const item = this.metadata.item(id); const stuffUI = item.StuffUI("UIComponent"); + return this.mediaPrefix(stuffUI.icon!.value); + } + @Cache() + async stuffIcon(id: string) { + const item = this.metadata.item(id); + console.log(id); + const stuffUI = item.StuffUI("UIComponent"); return this.mediaPrefix(stuffUI.icon!.value); } } diff --git a/packages/website-ue/src/components/Price/index.tsx b/packages/website-ue/src/components/Price/index.tsx index f3ddec2ad..3c2051f39 100644 --- a/packages/website-ue/src/components/Price/index.tsx +++ b/packages/website-ue/src/components/Price/index.tsx @@ -26,23 +26,44 @@ interface PriceEntryProps { } function PriceEntry({ entry }: PriceEntryProps) { - const locale = useLocale(); + if (entry.premium_time_price !== undefined) { + console.log(entry); - if ( - entry.premium_time_price !== undefined || - entry.stuff_price !== undefined || - entry.currency_price === undefined - ) { throw new Error("Unsupported price type"); } - const [, iconName] = entry.currency_price.currency_catalog_id.split("."); + return ( + <> + {entry.currency_price && ( + + )} + + {entry.stuff_price && ( + + )} + + ); +} + +interface PriceInternalProps { + icon: string; + value: number; +} + +function PriceInternal({ icon, value }: PriceInternalProps) { + const locale = useLocale(); return (
- - {formatCompact(locale, entry.currency_price.amount)} + + {formatCompact(locale, value)}
); diff --git a/packages/website-ue/src/pages/[api]/currencies/[id].webp.ts b/packages/website-ue/src/pages/[api]/currencies/[id].webp.ts index 00688efda..fd1cb6eee 100644 --- a/packages/website-ue/src/pages/[api]/currencies/[id].webp.ts +++ b/packages/website-ue/src/pages/[api]/currencies/[id].webp.ts @@ -5,7 +5,7 @@ import { getStaticPaths as _getStaticPaths } from "../_index"; export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => { const group = api.metadata.group("CurrencyEntity"); - return group.map(({ name }) => ({ params: { id: name } })); + return group.map(({ id }) => ({ params: { id } })); }); export async function GET({ params }: { params: { id: string } }) { diff --git a/packages/website-ue/src/pages/[api]/stuff/[id].webp.ts b/packages/website-ue/src/pages/[api]/stuff/[id].webp.ts new file mode 100644 index 000000000..8bd29ec85 --- /dev/null +++ b/packages/website-ue/src/pages/[api]/stuff/[id].webp.ts @@ -0,0 +1,14 @@ +import { api } from "../../../api/dynamic"; +import { imageProxy } from "../../../api/imageProxy"; +import { mixStaticPaths } from "../../../astro/mixStaticPaths"; +import { getStaticPaths as _getStaticPaths } from "../_index"; + +export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => { + const group = api.metadata.group("ProxyEntity"); + return group.map(({ id }) => ({ params: { id } })); +}); + +export async function GET({ params }: { params: { id: string } }) { + const icon = await api.stuffIcon(params.id); + return await imageProxy(icon); +}