diff --git a/src/modules/posts/api/get/fetchPostProjects.ts b/src/modules/posts/api/get/fetchPostProjects.ts index e8f224e..3918820 100644 --- a/src/modules/posts/api/get/fetchPostProjects.ts +++ b/src/modules/posts/api/get/fetchPostProjects.ts @@ -39,7 +39,7 @@ export const fetchPostProjects = async (tag: number): Promise => { const newPost: App.Card = { id: post.id, title: post.title.rendered, - preview: image?.src || null, + preview: image?.src || "", }; result.push(newPost); diff --git a/src/modules/posts/api/get/fetchPosts.ts b/src/modules/posts/api/get/fetchPosts.ts index 84527e0..a624c8c 100644 --- a/src/modules/posts/api/get/fetchPosts.ts +++ b/src/modules/posts/api/get/fetchPosts.ts @@ -36,7 +36,7 @@ export const fetchPosts = async (): Promise => { if (postCategories.includes("projects")) { const newProject: App.Card = { ...newPost, - preview: image?.src || null, + preview: image?.src || "", }; result.projects[post.id] = newProject; } else if (postCategories.includes("labs")) { @@ -44,7 +44,7 @@ export const fetchPosts = async (): Promise => { const excerptElement = Parse(post.excerpt.rendered)[0]; const newLab: App.LabCard = { ...newPost, - preview: image?.src || undefined, + preview: image?.src || "", previewText: (excerptElement as any)?.props?.children || "", }; result.labs[post.id] = newLab; @@ -53,6 +53,7 @@ export const fetchPosts = async (): Promise => { ...newPost, content: parseContent(post.content.rendered), tag: post.tags[0], + categories: postCategories, }; result.other.push(newWpPostPage); } diff --git a/src/shared/Components/Field/Field.tsx b/src/shared/Components/Field/Field.tsx index c1a4472..6203ed6 100644 --- a/src/shared/Components/Field/Field.tsx +++ b/src/shared/Components/Field/Field.tsx @@ -16,7 +16,8 @@ type FieldType = | "file" | "textarea" | "textarea" - | "password"; + | "password" + | "tel"; interface FieldProps { type: FieldType; diff --git a/src/shared/assets/images/index.js b/src/shared/assets/images/index.ts similarity index 100% rename from src/shared/assets/images/index.js rename to src/shared/assets/images/index.ts diff --git a/src/shared/assets/images/numbers/index.js b/src/shared/assets/images/numbers/index.ts similarity index 100% rename from src/shared/assets/images/numbers/index.js rename to src/shared/assets/images/numbers/index.ts diff --git a/src/shared/types/app.d.ts b/src/shared/types/app.d.ts index 651e974..1ed265c 100644 --- a/src/shared/types/app.d.ts +++ b/src/shared/types/app.d.ts @@ -301,14 +301,15 @@ declare namespace App { export interface WpPostPage extends WpPost { content: ParsedContent[]; tag: number; + categories?: string[]; } export interface Card extends WpPost { - preview?: string | null; + preview: string; } export interface LabCard extends Card { - previewText?: string | null; + previewText: string; } export interface PostsResult { diff --git a/src/widgets/CardList/CardListFunctions.ts b/src/widgets/CardList/CardListFunctions.ts index 989c739..b95ffd8 100644 --- a/src/widgets/CardList/CardListFunctions.ts +++ b/src/widgets/CardList/CardListFunctions.ts @@ -1,19 +1,25 @@ import { CardData } from "@/shared/Components/Card/types"; import { App, SKBKit } from "@/shared/types/app"; + +function hasPreviewText(post: App.Card | App.LabCard): post is App.LabCard { + return 'previewText' in post; +} + export const transformPostsToCardData = ( - posts: App.WpPost[] + posts: App.Card[] | App.LabCard[] ): Record => { return posts.reduce((acc, post) => { acc[post.id] = { id: post.id.toString(), name: post.title, - previewText: post.previewText || "", + previewText: hasPreviewText(post) ? post.previewText : "", link: `/post/${post.id}`, preview: post.preview || "", }; return acc; }, {} as Record); }; + export const transformNewsToCardData = ( news: SKBKit.News[] ): Record => { diff --git a/src/widgets/Footer/Footer.tsx b/src/widgets/Footer/Footer.tsx index 6a85e66..33f3811 100644 --- a/src/widgets/Footer/Footer.tsx +++ b/src/widgets/Footer/Footer.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from "react"; +import { useState } from "react"; import { Link } from "react-router-dom"; import FooterLink from "./FooterLink"; import FooterContacts from "./FooterContacts"; @@ -73,7 +73,8 @@ const mockContacts: ContactsType = { }; function Footer({ links = mockLinks, contacts = mockContacts }: FooterProps) { - const [mediaList, setMediaList] = useState(links); + // TODO: добавить setMediaList + const [mediaList] = useState(links); return (