TopCommentsComment

Комментарий дня/месяца

Props

comment

  • type: TopComment
  • required: true

Комментарий из API, типы в types.ts

Events

Event namePropertiesDescription
toggle-ratecommentId number - — id комментария
isRateUp boolean - — новое значение liked
Изменение рейтинга

Types

import type { AvatarLinkUser } from '#sf/components/user/avatar-link/types';
import type { GetCommentsApiParams } from '#sf/sections/journal/api';

type Unknown = Record<string, unknown>;

export type TopComment = Unknown & {
  id: number;
  files: any[];
  params?: Pick<GetCommentsApiParams, 'rate_bad' | 'rate_good'>;
  text: string;
  author: AvatarLinkUser;
  topic: Unknown & {
    id: number;
    friendly_url: string;
    topic: string;
  };
};

Test data

import { testUserAvatarLink } from '#sf/components/user/avatar-link/test-data';

import type { TopComment } from './types';

export const testTopComment: TopComment = {
  id: 0,
  topic: {
    id: 0,
    topic: 'test topic title',
    status: 1,
    friendly_url: '0000-test-url',
    created_at: 1673613694,
    isFavorite: false,
  },
  author: testUserAvatarLink,
  text: 'test comment text',
  files: [
    {
      url: 'advantages/accessory.svg',
      name: 'test',
    },
  ],
  params: {
    rate_good: 10,
    rate_bad: 5,
  },
};