Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Fix sending feedback outside of project pages

Joshen Lim977170c91ba3
diff --git a/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx b/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx
index 025a70c11fe..fd8a1b3ca52 100644
--- a/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx
+++ b/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx
@@ -37,7 +37,7 @@ const FeedbackWidget = ({
setScreenshot,
}: FeedbackWidgetProps) => {
const router = useRouter()
- const { ref } = useParams()
+ const { ref, slug } = useParams()
const { ui } = useStore()
const inputRef = useRef<any>(null)
@@ -101,7 +101,7 @@ const FeedbackWidget = ({
message: 'Please include a message in your feedback.',
duration: 4000,
})
- } else if (feedback.length > 0 && ref !== undefined) {
+ } else if (feedback.length > 0) {
setSending(true)
const attachmentUrl = screenshot
@@ -113,6 +113,7 @@ const FeedbackWidget = ({
try {
await submitFeedback({
projectRef: ref,
+ organizationSlug: slug,
message: formattedFeedback,
pathname: router.asPath,
})
diff --git a/studio/data/feedback/feedback-send.ts b/studio/data/feedback/feedback-send.ts
index a6a6e0074dd..969919c3979 100644
--- a/studio/data/feedback/feedback-send.ts
+++ b/studio/data/feedback/feedback-send.ts
@@ -1,26 +1,34 @@
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import toast from 'react-hot-toast'
-import { post } from 'lib/common/fetch'
-import { API_URL } from 'lib/constants'
+import { post } from 'data/fetchers'
import { ResponseError } from 'types'
export type SendFeedbackVariables = {
- projectRef: string
message: string
- pathname: string
+ pathname?: string
+ projectRef?: string
+ organizationSlug?: string
}
-export async function sendFeedback({ projectRef, message, pathname }: SendFeedbackVariables) {
- const response = await post(`${API_URL}/feedback/send`, {
- projectRef,
- message,
- pathname,
- category: 'Feedback',
- tags: ['dashboard-feedback'],
+export async function sendFeedback({
+ message,
+ pathname,
+ projectRef,
+ organizationSlug,
+}: SendFeedbackVariables) {
+ const { data, error } = await post(`/platform/feedback/send`, {
+ body: {
+ message,
+ category: 'Feedback',
+ tags: ['dashboard-feedback'],
+ projectRef,
+ organizationSlug,
+ pathname,
+ },
})
- if (response.error) throw response.error
- return response
+ if (error) throw error
+ return data
}
type SendFeedbackData = Awaited<ReturnType<typeof sendFeedback>>