diff --git a/src/blocks/Author/Author.tsx b/src/blocks/Author/Author.tsx index ceb9c7d5..81890043 100644 --- a/src/blocks/Author/Author.tsx +++ b/src/blocks/Author/Author.tsx @@ -17,7 +17,7 @@ export const Author = (props: AuthorProps) => { const {post} = useContext(PostPageContext); - const author = post?.authors?.find(({id}: {id: number}) => id === authorId); + const author = post?.authors?.find(({id}: {id: number | string}) => id === authorId); const authorItem = useMemo(() => { const imageUrl = author?.avatar ?? image; diff --git a/src/components/PostInfo/components/Save.tsx b/src/components/PostInfo/components/Save.tsx index a6b8176f..3f11d7b4 100644 --- a/src/components/PostInfo/components/Save.tsx +++ b/src/components/PostInfo/components/Save.tsx @@ -19,7 +19,7 @@ const b = block('post-info'); type SaveProps = QAProps & { title: string | number; - postId: number; + postId: number | string; hasUserLike: boolean; handleUserLike: () => void; theme?: 'light' | 'dark'; diff --git a/src/hooks/useLikes.ts b/src/hooks/useLikes.ts index 088c1d0a..99f525bf 100644 --- a/src/hooks/useLikes.ts +++ b/src/hooks/useLikes.ts @@ -5,7 +5,7 @@ import {ToggleLikeCallbackType} from '../models/common'; type UseLikesProps = { hasLike?: boolean; count?: number; - postId?: number; + postId?: number | string; toggleLikeCallback?: ToggleLikeCallbackType; }; diff --git a/src/models/blocks.ts b/src/models/blocks.ts index 60d677d1..5c6c8861 100644 --- a/src/models/blocks.ts +++ b/src/models/blocks.ts @@ -13,7 +13,7 @@ import {PaddingsYFMProps} from './paddings'; // blocks props export type AuthorProps = ClassNameProps & { - authorId: number; + authorId: number | string; image: string; } & PaddingsYFMProps & QAProps; diff --git a/src/models/common.ts b/src/models/common.ts index 377d396a..891064a2 100644 --- a/src/models/common.ts +++ b/src/models/common.ts @@ -17,7 +17,7 @@ export interface ClassNameProps { } export type Author = { - id: number; + id: number | string; avatar: string | null; createdAt: string; updatedAt: string; @@ -31,7 +31,7 @@ export type Author = { }; export type Service = { - id: number; + id: number | string; slug: string; name: string; } & { @@ -67,14 +67,14 @@ export type Tag = { icon?: string; isDeleted?: boolean; locale?: string; - blogTagId?: number; + blogTagId?: number | string; count?: number; }; export interface PostData { author?: string; authors?: Author[]; - blogPostId?: number; + blogPostId?: number | string; content?: string; date: string; description?: string; @@ -153,7 +153,7 @@ export type ToggleLikeCallbackType = ({ postId, hasLike, }: { - postId?: number; + postId?: number | string; hasLike?: boolean; }) => void; diff --git a/src/utils/common.ts b/src/utils/common.ts index 8c2695f8..a06af33f 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -91,9 +91,9 @@ export const getTags = memoize((tags: Tag[], blogPath: string) => { }); }); -const stub = (postId: number) => postId; +const stub = (postId: number | string) => postId; -export const postLikeStatus = debounce((postId: number, hasUserLike: boolean) => { +export const postLikeStatus = debounce((postId: number | string, hasUserLike: boolean) => { (hasUserLike ? stub : stub)(postId); }, 300);