brutalism design

This commit is contained in:
2026-05-14 01:05:01 +06:00
parent 6a2111092b
commit edef0a70d2
42 changed files with 1114 additions and 316 deletions

View File

@@ -0,0 +1,33 @@
import type { ChatMessage, ResponseError } from '@shared/api/generated-chad-api.ts'
import type { InfiniteData, QueryKey } from '@tanstack/vue-query'
import api from '@shared/api/client.ts'
import { useInfiniteQuery } from '@tanstack/vue-query'
interface Response {
messages: ChatMessage[]
nextCursor?: string
}
type PageParam = string | undefined
export function qChatMessages() {
return useInfiniteQuery<Response, ResponseError, InfiniteData<Response, PageParam>, QueryKey, PageParam>({
queryKey: ['chat-messages'],
queryFn: async ({ pageParam }) => {
const response = await api.chad.chatMessages({ cursor: pageParam, limit: 30 })
return {
messages: response.data.messages.reverse(),
nextCursor: response.data.nextCursor,
}
},
select: data => ({
pages: [...data.pages].reverse(),
pageParams: [...data.pageParams].reverse(),
}),
initialPageParam: undefined,
getNextPageParam: (lastPage) => {
return lastPage.nextCursor
},
shallow: true,
})
}