This commit is contained in:
2026-02-04 00:51:40 +09:00
parent 4c559b30fe
commit 914dc43889
7 changed files with 120 additions and 85 deletions
+14 -3
View File
@@ -1,6 +1,6 @@
import { apiDelete, apiGet, apiPost } from '@/lib/api'
import type { Post } from '@/types'
import type { Post, PostTagChange } from '@/types'
export const fetchPosts = async (
@@ -13,8 +13,8 @@ export const fetchPosts = async (
): Promise<{
posts: Post[]
count: number
nextCursor: string }> => await apiGet ('/posts', {
params: {
nextCursor: string }> =>
await apiGet ('/posts', { params: {
tags,
match,
...(page && { page }),
@@ -25,6 +25,17 @@ export const fetchPosts = async (
export const fetchPost = async (id: string): Promise<Post> => await apiGet (`/posts/${ id }`)
export const fetchPostChanges = async (
{ id, page, limit }: {
id?: string
page: number
limit: number },
): Promise<{
changes: PostTagChange[]
count: number }> =>
await apiGet ('/posts/changes', { params: { ...(id && { id }), page, limit } })
export const toggleViewedFlg = async (id: string, viewed: boolean): Promise<void> => {
await (viewed ? apiPost : apiDelete) (`/posts/${ id }/viewed`)
}