Files
astuto/app/javascript/interfaces/IPost.ts
Riccardo Graziosi 20f93736f5 Improve UI/UX of Post page (#416)
* Show post content and likes before fetching from backend API
* Autofocus reply and edit forms for comments
* Autofocus title field in post edit form
* More UI/UX improvements
2024-09-26 19:45:48 +02:00

49 lines
1.3 KiB
TypeScript

import IPostJSON from "./json/IPost";
// 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;
interface IPost {
id: number;
title: string;
slug?: string;
description?: string;
approvalStatus: PostApprovalStatus;
boardId: number;
postStatusId?: number;
likeCount: number;
liked: number;
commentsCount: number;
hotness: number;
userId: number;
userEmail: string;
userFullName: string;
createdAt: string;
}
export default IPost;
export const postJSON2JS = (postJSON: IPostJSON): IPost => ({
id: postJSON.id,
title: postJSON.title,
slug: postJSON.slug,
description: postJSON.description,
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,
createdAt: postJSON.created_at,
});