Files
supabase/apps/docs/lib/fetch/feedback.ts
Chris Chinchilla c9baed829f Revert "feat(docs): route docs page feedback comments to Postgres" (#47027)
Reverts supabase/supabase#46941

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

* **New Features**
* Feedback is now automatically routed to the appropriate documentation
team based on the section being viewed.

* **Improvements**
* Streamlined feedback submission process—votes and comments are now
collected more efficiently in a single submission.
* Enhanced feedback data handling and organization for better team
collaboration.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-06-17 11:49:45 +00:00

51 lines
1.2 KiB
TypeScript

import { type UseMutationOptions, useMutation } from '@tanstack/react-query'
import { type ResponseError } from '~/types/fetch'
import { post } from './fetchWrappers'
type SendFeedbackVariables = {
title: string
message: string
isHelpful: boolean
pathname?: string
team?: string
}
export async function sendFeedback({
message,
pathname,
title,
isHelpful,
team,
}: SendFeedbackVariables) {
const { data, error } = await post('/platform/feedback/docs', {
body: {
page: pathname ?? '',
isHelpful,
title,
feedback: message,
team,
},
})
if (error) throw Error(`Couldn't send feedback`, { cause: error })
return data
}
type SendFeedbackData = Awaited<ReturnType<typeof sendFeedback>>
export const useSendFeedbackMutation = (
options: Omit<
UseMutationOptions<SendFeedbackData, ResponseError, SendFeedbackVariables>,
'mutationFn'
> = {}
) => {
return useMutation<SendFeedbackData, ResponseError, SendFeedbackVariables>({
...options,
mutationFn: (vars) => sendFeedback(vars),
onError: (error, vars, ctx) => {
console.error(error)
options.onError?.(error, vars, ctx)
},
})
}