Skip to content

Commit 69b9b40

Browse files
committed
fix(tasks): use requestJson with createMothershipChatContract instead of raw fetch
1 parent f83b43e commit 69b9b40

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

apps/sim/hooks/queries/tasks.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
22
import { requestJson } from '@/lib/api/client/request'
33
import {
44
addMothershipChatResourceContract,
5+
createMothershipChatContract,
56
deleteMothershipChatContract,
67
forkMothershipChatContract,
78
listMothershipChatsContract,
@@ -527,15 +528,8 @@ export function useMarkTaskUnread(workspaceId?: string) {
527528
}
528529

529530
async function createChat(workspaceId: string): Promise<{ id: string }> {
530-
// boundary-raw-fetch: fire-and-forget POST inside a mutation, no shared request helper for this endpoint
531-
const response = await fetch('/api/mothership/chats', {
532-
method: 'POST',
533-
headers: { 'Content-Type': 'application/json' },
534-
body: JSON.stringify({ workspaceId }),
535-
})
536-
if (!response.ok) throw new Error('Failed to create chat')
537-
const data = await response.json()
538-
return { id: data.id }
531+
const { id } = await requestJson(createMothershipChatContract, { body: { workspaceId } })
532+
return { id }
539533
}
540534

541535
export function useCreateTask(workspaceId?: string) {

0 commit comments

Comments
 (0)