From 4de84909cb30030c1dcdc8182556e19fc412c77d Mon Sep 17 00:00:00 2001 From: xomimishka Date: Thu, 24 Apr 2025 15:27:30 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=82=D0=B5=D0=BA=D1=83=D1=89=D0=B8=D1=85?= =?UTF-8?q?=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B9=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=20=D1=81=D0=BB=D0=B8=D1=8F=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/providers/router/ui/AppRouter.tsx | 4 ++-- src/modules/posts/api/get/fetchPostById.ts | 14 +++++++++++++- src/modules/posts/api/get/fetchPosts.ts | 2 +- src/pages/MainPage/ui/MainPage/MainPage.tsx | 10 +++++----- src/widgets/CardList/CardList.tsx | 6 +++--- src/widgets/CardList/CardListTemplate.tsx | 2 +- vite.config.ts | 2 +- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/app/providers/router/ui/AppRouter.tsx b/src/app/providers/router/ui/AppRouter.tsx index 13b5ee3..4ec36d2 100644 --- a/src/app/providers/router/ui/AppRouter.tsx +++ b/src/app/providers/router/ui/AppRouter.tsx @@ -1,8 +1,8 @@ import Root from "@/app/Layout/Root"; import { routeConfig } from "@/shared/config/routeConfig/routeConfig"; -import { createBrowserRouter } from "react-router-dom"; +import { createHashRouter } from "react-router-dom"; -export const appRouter = createBrowserRouter([ +export const appRouter = createHashRouter([ { element: , diff --git a/src/modules/posts/api/get/fetchPostById.ts b/src/modules/posts/api/get/fetchPostById.ts index dd373ad..c9781a4 100644 --- a/src/modules/posts/api/get/fetchPostById.ts +++ b/src/modules/posts/api/get/fetchPostById.ts @@ -4,13 +4,25 @@ import { parseContent } from "@/shared/api/parseContent"; import { App, WPv2 } from "@/shared/types/app"; export const fetchPostById = async (id: number): Promise => { - const post = await wp.posts().id(id).get() as WPv2.Post; + const [post, categories] = await Promise.all([ + wp.posts().id(id).get() as Promise, + wp.categories().get() as Promise, + ]); + + const categoryMap = new Map( + categories.map((c) => [c.id, c.name]) + ); + + const postCategories = post.categories.map( + (id) => categoryMap.get(id) || "" + ); const result: App.WpPostPage = { id: post.id, title: post.title.rendered, content: parseContent(post.content.rendered), tag: post.tags[0], + categories: postCategories, }; return result; diff --git a/src/modules/posts/api/get/fetchPosts.ts b/src/modules/posts/api/get/fetchPosts.ts index a624c8c..4367862 100644 --- a/src/modules/posts/api/get/fetchPosts.ts +++ b/src/modules/posts/api/get/fetchPosts.ts @@ -58,6 +58,6 @@ export const fetchPosts = async (): Promise => { result.other.push(newWpPostPage); } } - console.log('fetchPosts result', result); + return result; }; diff --git a/src/pages/MainPage/ui/MainPage/MainPage.tsx b/src/pages/MainPage/ui/MainPage/MainPage.tsx index 1f9daee..cb5b908 100644 --- a/src/pages/MainPage/ui/MainPage/MainPage.tsx +++ b/src/pages/MainPage/ui/MainPage/MainPage.tsx @@ -43,17 +43,17 @@ const MainPage = () => { - -
- -
-
+ +
+
+ +
diff --git a/src/widgets/CardList/CardList.tsx b/src/widgets/CardList/CardList.tsx index be7135c..809ee2a 100644 --- a/src/widgets/CardList/CardList.tsx +++ b/src/widgets/CardList/CardList.tsx @@ -66,7 +66,7 @@ const LabsList = ({ items={transformPostsToCardData(labs)} variant="lab" gridConfig={gridConfig} - title="Лаборатории" + title="Наши лаборатории" /> ); @@ -82,7 +82,7 @@ const ProjectsList = ({ if (isLoading) return (
-

Проекты

+

Наши проекты

); @@ -96,7 +96,7 @@ const ProjectsList = ({ items={transformPostsToCardData(projects)} variant="project" gridConfig={gridConfig} - title="Проекты" + title="Наши проекты" /> ); diff --git a/src/widgets/CardList/CardListTemplate.tsx b/src/widgets/CardList/CardListTemplate.tsx index 034892d..41355c8 100644 --- a/src/widgets/CardList/CardListTemplate.tsx +++ b/src/widgets/CardList/CardListTemplate.tsx @@ -8,7 +8,7 @@ export const CardListTemplate = ({ items, variant = "lab", // Значение по умолчанию gridConfig = { desktop: 3, tablet: 2, mobile: 1 }, - title = "Лаборатории", + title = "Наши лаборатории", }: CardListProps) => { const itemsArray = Object.values(items); diff --git a/vite.config.ts b/vite.config.ts index 3e9bd1e..4b3d5ee 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,7 +3,7 @@ import react from "@vitejs/plugin-react"; import path from "path"; export default defineConfig({ - base: '/wp-content/reactpress/apps/skb/dist/', + base: "/wp-content/reactpress/apps/skb/dist/index.html", plugins: [react()], resolve: { alias: {