2024-09-26 19:45:48 +02:00
|
|
|
import IPostJSON from "./json/IPost";
|
|
|
|
|
|
2024-07-12 20:38:46 +02:00
|
|
|
// Approval status
|
|
|
|
|
export const POST_APPROVAL_STATUS_APPROVED = 'approved';
|
|
|
|
|
export const POST_APPROVAL_STATUS_PENDING = 'pending';
|
|
|
|
|
export const POST_APPROVAL_STATUS_REJECTED = 'rejected';
|
|
|
|
|
|
|
|
|
|
export type PostApprovalStatus =
|
|
|
|
|
typeof POST_APPROVAL_STATUS_APPROVED |
|
|
|
|
|
typeof POST_APPROVAL_STATUS_PENDING |
|
|
|
|
|
typeof POST_APPROVAL_STATUS_REJECTED;
|
|
|
|
|
|
2019-08-26 14:29:56 +02:00
|
|
|
interface IPost {
|
|
|
|
|
id: number;
|
|
|
|
|
title: string;
|
2024-04-05 18:23:31 +02:00
|
|
|
slug?: string;
|
2019-08-26 14:29:56 +02:00
|
|
|
description?: string;
|
2025-01-28 16:55:48 +01:00
|
|
|
attachmentUrls?: string[];
|
2025-02-05 21:52:28 +01:00
|
|
|
hasAttachments?: boolean;
|
2024-07-12 20:38:46 +02:00
|
|
|
approvalStatus: PostApprovalStatus;
|
2019-09-11 18:30:59 +02:00
|
|
|
boardId: number;
|
|
|
|
|
postStatusId?: number;
|
2023-02-05 11:55:38 +01:00
|
|
|
likeCount: number;
|
2019-09-27 16:57:23 +02:00
|
|
|
liked: number;
|
2019-09-21 11:17:58 +02:00
|
|
|
commentsCount: number;
|
2019-09-27 16:57:23 +02:00
|
|
|
hotness: number;
|
2019-09-11 18:30:59 +02:00
|
|
|
userId: number;
|
2022-06-22 10:17:42 +02:00
|
|
|
userEmail: string;
|
|
|
|
|
userFullName: string;
|
2025-01-09 10:55:44 +01:00
|
|
|
userAvatar?: string;
|
2019-09-11 18:30:59 +02:00
|
|
|
createdAt: string;
|
2019-08-26 14:29:56 +02:00
|
|
|
}
|
|
|
|
|
|
2024-09-26 19:45:48 +02:00
|
|
|
export default IPost;
|
|
|
|
|
|
|
|
|
|
export const postJSON2JS = (postJSON: IPostJSON): IPost => ({
|
|
|
|
|
id: postJSON.id,
|
|
|
|
|
title: postJSON.title,
|
|
|
|
|
slug: postJSON.slug,
|
|
|
|
|
description: postJSON.description,
|
2025-02-05 21:52:28 +01:00
|
|
|
attachmentUrls: postJSON.attachment_urls,
|
|
|
|
|
hasAttachments: postJSON.has_attachments,
|
2024-09-26 19:45:48 +02:00
|
|
|
approvalStatus: postJSON.approval_status,
|
|
|
|
|
boardId: postJSON.board_id,
|
|
|
|
|
postStatusId: postJSON.post_status_id,
|
|
|
|
|
likeCount: postJSON.likes_count,
|
|
|
|
|
liked: postJSON.liked,
|
|
|
|
|
commentsCount: postJSON.comments_count,
|
|
|
|
|
hotness: postJSON.hotness,
|
|
|
|
|
userId: postJSON.user_id,
|
|
|
|
|
userEmail: postJSON.user_email,
|
|
|
|
|
userFullName: postJSON.user_full_name,
|
2025-01-09 10:55:44 +01:00
|
|
|
userAvatar: postJSON.user_avatar,
|
2024-09-26 19:45:48 +02:00
|
|
|
createdAt: postJSON.created_at,
|
|
|
|
|
});
|