ぼざクリタグ広場 https://hub.nizika.monster
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

31 lines
765 B

  1. import { apiDelete, apiGet, apiPost } from '@/lib/api'
  2. import type { Post } from '@/types'
  3. export const fetchPosts = async (
  4. { tags, match, page, limit, cursor }: {
  5. tags: string
  6. match: 'any' | 'all'
  7. page?: number
  8. limit?: number
  9. cursor?: string }
  10. ): Promise<{
  11. posts: Post[]
  12. count: number
  13. nextCursor: string }> => await apiGet ('/posts', {
  14. params: {
  15. tags,
  16. match,
  17. ...(page && { page }),
  18. ...(limit && { limit }),
  19. ...(cursor && { cursor }) } })
  20. export const fetchPost = async (id: string): Promise<Post> => await apiGet (`/posts/${ id }`)
  21. export const toggleViewedFlg = async (id: string, viewed: boolean): Promise<void> => {
  22. await (viewed ? apiPost : apiDelete) (`/posts/${ id }/viewed`)
  23. }