From d3ab4bac51729ebde9e1fd0bba12c896ced40a89 Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Wed, 20 May 2026 12:22:03 -0500 Subject: [PATCH] error wrapper hoc --- .../website-ue/src/hocs/withErrorWrapper.tsx | 10 ++- .../pages/[...locale]/tanks/[slug]/_index.tsx | 89 ++++++++++--------- 2 files changed, 52 insertions(+), 47 deletions(-) diff --git a/packages/website-ue/src/hocs/withErrorWrapper.tsx b/packages/website-ue/src/hocs/withErrorWrapper.tsx index 786575ec0..6a78a9656 100644 --- a/packages/website-ue/src/hocs/withErrorWrapper.tsx +++ b/packages/website-ue/src/hocs/withErrorWrapper.tsx @@ -1,12 +1,14 @@ import type { ReactNode } from "react"; import { ErrorWrapper } from "../components/ErrorWrapper"; -export function withErrorWrapper( +export function withErrorWrapper( Component: (props: Props) => ReactNode, ) { return function (props: Props) { - - - ; + return ( + + + + ); }; } diff --git a/packages/website-ue/src/pages/[...locale]/tanks/[slug]/_index.tsx b/packages/website-ue/src/pages/[...locale]/tanks/[slug]/_index.tsx index 901f38a92..8d8b4e37e 100644 --- a/packages/website-ue/src/pages/[...locale]/tanks/[slug]/_index.tsx +++ b/packages/website-ue/src/pages/[...locale]/tanks/[slug]/_index.tsx @@ -1,6 +1,7 @@ import { Fragment, useMemo } from "react"; import { api } from "../../../../api/dynamic"; import { TankopediaLoadout } from "../../../../components/TankopediaLoadout"; +import { withErrorWrapper } from "../../../../hocs/withErrorWrapper"; import { withLocale } from "../../../../hocs/withLocale"; import { useAwait } from "../../../../hooks/useAwait"; import { useCharacteristicRenderer } from "../../../../hooks/useCharacteristicRenderer"; @@ -13,59 +14,61 @@ interface PageProps { id: string; } -export const Page = withLocale(({ id }: PageProps) => { - const protagonistTank = useAwait(() => api.tank(id), `tank-${id}`); +export const Page = withErrorWrapper( + withLocale(({ id }) => { + const protagonistTank = useAwait(() => api.tank(id), `tank-${id}`); - Tankopedia.useInitialization(protagonistTank); + Tankopedia.useInitialization(protagonistTank); - const renderCharacteristic = useCharacteristicRenderer(); + const renderCharacteristic = useCharacteristicRenderer(); - const protagonist = Tankopedia.use((state) => state.protagonist); - const protagonistEquipment = useEquipment(protagonistTank.tank!); + const protagonist = Tankopedia.use((state) => state.protagonist); + const protagonistEquipment = useEquipment(protagonistTank.tank!); - const { characteristics } = useMemo( - () => - computeCharacteristics( - protagonistTank, - protagonistEquipment, - protagonist, - ), - [protagonist], - ); + const { characteristics } = useMemo( + () => + computeCharacteristics( + protagonistTank, + protagonistEquipment, + protagonist, + ), + [protagonist], + ); - return ( - <> -

{protagonist.id}

+ return ( + <> +

{protagonist.id}

-
+
- + -

characteristics

+

characteristics

- {characteristicsOrder.map((group) => { - return ( - -

{group.group}

+ {characteristicsOrder.map((group) => { + return ( + +

{group.group}

- {group.order.map((item) => { - if ("toy" in item) { - return toy: {item.toy}; - } + {group.order.map((item) => { + if ("toy" in item) { + return toy: {item.toy}; + } - const value = characteristics[item.name]; + const value = characteristics[item.name]; - if (value == null) return null; + if (value == null) return null; - return ( - - {item.name}: {renderCharacteristic(value, item)} - - ); - })} -
- ); - })} - - ); -}); + return ( + + {item.name}: {renderCharacteristic(value, item)} + + ); + })} +
+ ); + })} + + ); + }), +);