JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr{ gilour

File "use-comments.ts"

Full Path: /home/markqprx/iniasli.pro/client/comments/requests/use-comments.ts
File size: 785 bytes
MIME-type: text/plain
Charset: utf-8

import {Commentable} from '@common/comments/commentable';
import {Comment} from '@common/comments/comment';
import {useInfiniteData} from '@common/ui/infinite-scroll/use-infinite-data';

interface QueryParams {
  perPage?: number;
}

export function commentsQueryKey(
  commentable: Commentable,
  params: QueryParams = {}
) {
  return ['comment', `${commentable.id}-${commentable.model_type}`, params];
}

export function useComments(
  commentable: Commentable,
  params: QueryParams = {}
) {
  return useInfiniteData<Comment>({
    queryKey: commentsQueryKey(commentable, params),
    endpoint: 'commentable/comments',
    //paginate: 'cursor',
    queryParams: {
      commentable_type: commentable.model_type,
      commentable_id: commentable.id,
      ...params,
    },
  });
}