Skip to content

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

Fix support form again (#29809)

Joshen Limf8acc373814d
diff --git a/apps/studio/components/interfaces/Support/SupportFormV2.tsx b/apps/studio/components/interfaces/Support/SupportFormV2.tsx
index f9649b5c160..ba04ce4cbe6 100644
--- a/apps/studio/components/interfaces/Support/SupportFormV2.tsx
+++ b/apps/studio/components/interfaces/Support/SupportFormV2.tsx
@@ -136,7 +136,7 @@ export const SupportFormV2 = ({ setSentCategory, setSelectedProject }: SupportFo
isLoading: isLoadingSubscription,
isSuccess: isSuccessSubscription,
} = useOrgSubscriptionQuery({
- orgSlug: organizationSlug,
+ orgSlug: organizationSlug === 'no-org' ? undefined : organizationSlug,
})
const {
@@ -200,6 +200,7 @@ export const SupportFormV2 = ({ setSentCategory, setSelectedProject }: SupportFo
const payload = {
...values,
+ organizationSlug: values.organizationSlug === 'no-org' ? undefined : values.organizationSlug,
library:
values.category === 'Problem' && selectedLibrary !== undefined ? selectedLibrary.key : '',
message: formatMessage(values.message, attachments),
@@ -256,7 +257,9 @@ export const SupportFormV2 = ({ setSentCategory, setSelectedProject }: SupportFo
useEffect(() => {
// For prefilling form fields via URL, project ref will taking higher precedence than org slug
if (isSuccessOrganizations && isSuccessProjects) {
- if (ref) {
+ if (organizations.length === 0) {
+ form.setValue('organizationSlug', 'no-org')
+ } else if (ref) {
const selectedProject = allProjects.find((p) => p.ref === ref)
if (selectedProject !== undefined) {
form.setValue('organizationSlug', selectedProject.organization_slug)
@@ -323,8 +326,14 @@ export const SupportFormV2 = ({ setSentCategory, setSelectedProject }: SupportFo
<SelectTrigger_Shadcn_ className="w-full">
<SelectValue_Shadcn_ asChild placeholder="Select an organization">
<div className="flex items-center gap-x-2">
- {(organizations ?? []).find((o) => o.slug === field.value)?.name}
- {isLoadingSubscription && <Loader2 size={14} className="animate-spin" />}
+ {organizationSlug === 'no-org' ? (
+ <span>No specific organization</span>
+ ) : (
+ (organizations ?? []).find((o) => o.slug === field.value)?.name
+ )}
+ {organizationSlug !== 'no-org' && isLoadingSubscription && (
+ <Loader2 size={14} className="animate-spin" />
+ )}
{isSuccessSubscription && (
<Badge variant="outline" className="capitalize">
{subscriptionPlanId}
@@ -338,6 +347,11 @@ export const SupportFormV2 = ({ setSentCategory, setSelectedProject }: SupportFo
{organizations?.map((org) => (
<SelectItem_Shadcn_ value={org.slug}>{org.name}</SelectItem_Shadcn_>
))}
+ {isSuccessOrganizations && (organizations ?? []).length === 0 && (
+ <SelectItem_Shadcn_ value="no-org">
+ No specific organization
+ </SelectItem_Shadcn_>
+ )}
</SelectGroup_Shadcn_>
</SelectContent_Shadcn_>
</Select_Shadcn_>
diff --git a/apps/studio/data/subscriptions/org-subscription-query.ts b/apps/studio/data/subscriptions/org-subscription-query.ts
index 5521589596a..7f70b0f22f8 100644
--- a/apps/studio/data/subscriptions/org-subscription-query.ts
+++ b/apps/studio/data/subscriptions/org-subscription-query.ts
@@ -56,14 +56,6 @@ export const useOrgSubscriptionQuery = <TData = OrgSubscriptionData>(
}
export const useHasAccessToProjectLevelPermissions = (slug: string) => {
- const canReadSubscriptions = useCheckPermissions(
- PermissionAction.BILLING_READ,
- 'stripe.subscriptions'
- )
- const { data: subscription } = useOrgSubscriptionQuery(
- { orgSlug: slug },
- { enabled: canReadSubscriptions }
- )
-
+ const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: slug })
return subscription?.plan.id === 'enterprise'
}