Skip to content

Commit 86886f6

Browse files
author
Zhirair
committed
fix: feature to use uuids as entity ids
1 parent 7a15a02 commit 86886f6

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

src/blocks/Author/Author.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const Author = (props: AuthorProps) => {
1717

1818
const {post} = useContext(PostPageContext);
1919

20-
const author = post?.authors?.find(({id}: {id: number}) => id === authorId);
20+
const author = post?.authors?.find(({id}: {id: number | string}) => id === authorId);
2121

2222
const authorItem = useMemo(() => {
2323
const imageUrl = author?.avatar ?? image;

src/components/PostInfo/components/Save.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const b = block('post-info');
1919

2020
type SaveProps = QAProps & {
2121
title: string | number;
22-
postId: number;
22+
postId: number | string;
2323
hasUserLike: boolean;
2424
handleUserLike: () => void;
2525
theme?: 'light' | 'dark';

src/hooks/useLikes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {ToggleLikeCallbackType} from '../models/common';
55
type UseLikesProps = {
66
hasLike?: boolean;
77
count?: number;
8-
postId?: number;
8+
postId?: number | string;
99
toggleLikeCallback?: ToggleLikeCallbackType;
1010
};
1111

src/models/blocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {PaddingsYFMProps} from './paddings';
1313

1414
// blocks props
1515
export type AuthorProps = ClassNameProps & {
16-
authorId: number;
16+
authorId: number | string;
1717
image: string;
1818
} & PaddingsYFMProps &
1919
QAProps;

src/models/common.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface ClassNameProps {
1717
}
1818

1919
export type Author = {
20-
id: number;
20+
id: number | string;
2121
avatar: string | null;
2222
createdAt: string;
2323
updatedAt: string;
@@ -31,7 +31,7 @@ export type Author = {
3131
};
3232

3333
export type Service = {
34-
id: number;
34+
id: number | string;
3535
slug: string;
3636
name: string;
3737
} & {
@@ -67,14 +67,14 @@ export type Tag = {
6767
icon?: string;
6868
isDeleted?: boolean;
6969
locale?: string;
70-
blogTagId?: number;
70+
blogTagId?: number | string;
7171
count?: number;
7272
};
7373

7474
export interface PostData {
7575
author?: string;
7676
authors?: Author[];
77-
blogPostId?: number;
77+
blogPostId?: number | string;
7878
content?: string;
7979
date: string;
8080
description?: string;
@@ -153,7 +153,7 @@ export type ToggleLikeCallbackType = ({
153153
postId,
154154
hasLike,
155155
}: {
156-
postId?: number;
156+
postId?: number | string;
157157
hasLike?: boolean;
158158
}) => void;
159159

src/utils/common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ export const getTags = memoize((tags: Tag[], blogPath: string) => {
9191
});
9292
});
9393

94-
const stub = (postId: number) => postId;
94+
const stub = (postId: number | string) => postId;
9595

96-
export const postLikeStatus = debounce((postId: number, hasUserLike: boolean) => {
96+
export const postLikeStatus = debounce((postId: number | string, hasUserLike: boolean) => {
9797
(hasUserLike ? stub : stub)(postId);
9898
}, 300);
9999

0 commit comments

Comments
 (0)