diff --git a/packages/website-ue/src/hocs/withErrorWrapper.tsx b/packages/website-ue/src/hocs/withErrorWrapper.tsx new file mode 100644 index 000000000..786575ec0 --- /dev/null +++ b/packages/website-ue/src/hocs/withErrorWrapper.tsx @@ -0,0 +1,12 @@ +import type { ReactNode } from "react"; +import { ErrorWrapper } from "../components/ErrorWrapper"; + +export function withErrorWrapper( + Component: (props: Props) => ReactNode, +) { + return function (props: Props) { + + + ; + }; +} diff --git a/packages/website-ue/src/hocs/withLocale.tsx b/packages/website-ue/src/hocs/withLocale.tsx new file mode 100644 index 000000000..fc7993ce2 --- /dev/null +++ b/packages/website-ue/src/hocs/withLocale.tsx @@ -0,0 +1,18 @@ +import type { ReactNode } from "react"; +import { LocaleProvider } from "../hooks/useLocale"; + +interface WithLocaleProps { + locale: string; +} + +export function withLocale( + Component: (props: Props) => ReactNode, +) { + return function ({ locale, ...props }: Props & WithLocaleProps) { + return ( + + + + ); + }; +} diff --git a/packages/website-ue/src/pages/[...locale]/avatars/_index.tsx b/packages/website-ue/src/pages/[...locale]/avatars/_index.tsx index 729529ecf..b51e6a0f7 100644 --- a/packages/website-ue/src/pages/[...locale]/avatars/_index.tsx +++ b/packages/website-ue/src/pages/[...locale]/avatars/_index.tsx @@ -1,21 +1,9 @@ import { AvatarControls } from "../../../components/AvatarControls"; import { AvatarsList } from "../../../components/AvatarsList"; import { Section } from "../../../components/Section"; -import { LocaleProvider } from "../../../hooks/useLocale"; +import { withLocale } from "../../../hocs/withLocale"; -interface PageProps { - locale: string; -} - -export function Page({ locale, ...props }: PageProps) { - return ( - - - - ); -} - -function Content() { +export const Page = withLocale(() => { return ( <>
@@ -27,4 +15,4 @@ function Content() {
); -} +}); diff --git a/packages/website-ue/src/pages/[...locale]/backgrounds/index.astro b/packages/website-ue/src/pages/[...locale]/backgrounds/index.astro deleted file mode 100644 index f58c46c27..000000000 --- a/packages/website-ue/src/pages/[...locale]/backgrounds/index.astro +++ /dev/null @@ -1,45 +0,0 @@ ---- -import { Grade } from "@protos/blitz_static_standard_grades_enum"; -import { api } from "../../../api/dynamic"; -import BaseLayout from "../../../layouts/BaseLayout.astro"; - -export { getStaticPaths } from "../index.astro"; - -const { locale } = Astro.props; -const { backgrounds } = await api.backgrounds(); ---- - - - { - backgrounds.map((background) => { - return ( - <> -

- {background.stuff_ui!.display_name}{" "} - {Grade[background.stuff_ui!.grade]}{" "} -

- -
{JSON.stringify(background.profile_background, null, 2)}
- - {background.stuff_ui!.description && ( -

{background.stuff_ui!.description}

- )} - {background.stuff_ui!.obtaining_methods && ( -

{background.stuff_ui!.obtaining_methods}

- )} - {background.stuff_ui!.features && ( -

{background.stuff_ui!.features}

- )} - - - - {background.sellable && ( -
{JSON.stringify(background.sellable, null, 2)}
- )} - -
- - ); - }) - } -
diff --git a/packages/website-ue/src/pages/[...locale]/settings/index.astro b/packages/website-ue/src/pages/[...locale]/settings/index.astro deleted file mode 100644 index 56c6c8190..000000000 --- a/packages/website-ue/src/pages/[...locale]/settings/index.astro +++ /dev/null @@ -1,15 +0,0 @@ ---- -import { Heading } from "../../../components/Heading"; -import { Section } from "../../../components/Section"; -import BaseLayout from "../../../layouts/BaseLayout.astro"; - -export { getStaticPaths } from "../index.astro"; - -const { locale } = Astro.props; ---- - - -
- Settings -
-
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 7de4a9416..901f38a92 100644 --- a/packages/website-ue/src/pages/[...locale]/tanks/[slug]/_index.tsx +++ b/packages/website-ue/src/pages/[...locale]/tanks/[slug]/_index.tsx @@ -1,48 +1,26 @@ import { Fragment, useMemo } from "react"; import { api } from "../../../../api/dynamic"; -import { ErrorWrapper } from "../../../../components/ErrorWrapper"; import { TankopediaLoadout } from "../../../../components/TankopediaLoadout"; +import { withLocale } from "../../../../hocs/withLocale"; import { useAwait } from "../../../../hooks/useAwait"; import { useCharacteristicRenderer } from "../../../../hooks/useCharacteristicRenderer"; import { useEquipment } from "../../../../hooks/useEquipment"; -import { LocaleProvider } from "../../../../hooks/useLocale"; import { Tankopedia } from "../../../../stores/tankopedia"; import { characteristicsOrder } from "../../../../tankopedia/characteristicsOrder"; import { computeCharacteristics } from "../../../../tankopedia/computeCharacteristics"; interface PageProps { id: string; - locale: string; } -export function Page(props: PageProps) { - return ( - - - - ); -} +export const Page = withLocale(({ id }: PageProps) => { + const protagonistTank = useAwait(() => api.tank(id), `tank-${id}`); -function Wrapper({ id, locale }: PageProps) { - const tank = useAwait(() => api.tank(id), `tank-${id}`); + Tankopedia.useInitialization(protagonistTank); - Tankopedia.useInitialization(tank); - - return ( - - - - ); -} - -function Content() { const renderCharacteristic = useCharacteristicRenderer(); const protagonist = Tankopedia.use((state) => state.protagonist); - const protagonistTank = useAwait( - () => api.tank(protagonist.id), - `tank-${protagonist.id}`, - ); const protagonistEquipment = useEquipment(protagonistTank.tank!); const { characteristics } = useMemo( @@ -63,105 +41,6 @@ function Content() { - {/*

upgrades

- - {protagonistTank.tank!.upgrade_lines.map((line) => { - return ( - <> -

- {line.name} ({protagonist.upgrades[line.name]}) -

- -
- {line.stages.map((stage, index) => { - if (stage.custom_picture) { - throw new Error("Custom picture not supported"); - } - - return ( - - ); - })} -
- - ); - })} */} -

characteristics

{characteristicsOrder.map((group) => { @@ -189,191 +68,4 @@ function Content() { })} ); - - // const parameters = aggregateParameters( - // protagonistTank.tank!, - // protagonist.upgrades, - // ); - - // if (parameters.modules_upgrades.length > 0) { - // throw new Error("Modules upgrades display not implemented"); - // } - - // return ( - // <> - //

{protagonist.id}

- - //
- - //

upgrades

- - // {protagonistTank.tank!.upgrade_lines.map((line) => { - // return ( - // <> - //

- // {line.name} ({protagonist.upgrades[line.name]}) - //

- - //
- // {line.stages.map((stage, index) => { - // if (stage.custom_picture) { - // throw new Error("Custom picture not supported"); - // } - - // return ( - // - // ); - // })} - //
- // - // ); - // })} - - //

characteristics

- - // {} - - //

parameters

- - //

attributes

- - // {parameters.attributes.map((attribute) => { - // return ( - // - // {TankAttributeChange_AttributeName[attribute.attribute_name]}:{" "} - // {attribute.value} - // - // ); - // })} - - //

penetration groups

- - // {parameters.penetration_groups_upgrades.map((upgrade) => { - // return ( - // <> - //

{PenetrationGroupUpgrade_TankPart[upgrade.tank_part]}

- - // - // primary armor ({upgrade.primary_armor.length}):{" "} - // {upgrade.primary_armor} - // - - //
- - // {upgrade.penetration_groups.map((group) => { - // return ( - // - // {group.group_name}: {group.armor} ( - // {PenetrationGroup_CommonData[group.common_data]}) - // - // ); - // })} - // - // ); - // })} - - //

modules ({parameters.modules_upgrades.length})

- - // {parameters.modules_upgrades.map((upgrade) => { - // return ( - // {ModuleUpgrade_AttributeName[upgrade.attribute_name]} - // ); - // })} - - //

shells

- - // {parameters.shells_upgrades.map((upgrade) => { - // return ( - // <> - //

- // {upgrade.shell_id}: {ShellUpgrade_ShellType[upgrade.shell_type]} - //

- - //
-  //             silver_price: {JSON.stringify(upgrade.silver_price, null, 2)}
-  //           
- - //
-  //             tray_shells: {JSON.stringify(upgrade.tray_shells, null, 2)}
-  //           
- // - // ); - // })} - // - // ); -} +}); diff --git a/packages/website-ue/src/pages/[...locale]/tanks/_index.tsx b/packages/website-ue/src/pages/[...locale]/tanks/_index.tsx index f1ead407a..97a6555fc 100644 --- a/packages/website-ue/src/pages/[...locale]/tanks/_index.tsx +++ b/packages/website-ue/src/pages/[...locale]/tanks/_index.tsx @@ -5,27 +5,15 @@ import { IncrementalLoader } from "../../../components/IncrementalLoader"; import { TankCard } from "../../../components/TankCard"; import { TankCards } from "../../../components/TankCards"; import { TankSearch } from "../../../components/TankSearch"; +import { withLocale } from "../../../hocs/withLocale"; import { useAwait } from "../../../hooks/useAwait"; -import { LocaleProvider } from "../../../hooks/useLocale"; import { useSearchableTanks } from "../../../hooks/useSearchableTanks"; import { useTierCompare } from "../../../hooks/useTierCompare"; import { TankFilters } from "../../../stores/tankFilters"; const { go } = fuzzysort; -interface PageProps { - locale: string; -} - -export function Page({ locale, ...props }: PageProps) { - return ( - - - - ); -} - -function Content() { +export const Page = withLocale(() => { const tanks = useAwait(() => api.tanks(), "tanks"); const compareTiers = useTierCompare(); @@ -60,7 +48,7 @@ function Content() { ); -} +}); interface ListProps { tanks: string[];