mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Patching a bug when delete an organization, add refetch.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import {PageParams} from "@/types/next";
|
import {PageParams} from "@/types/next";
|
||||||
import {Page, PageActions, PageContent, PageDescription, PageHeader, PageTitle} from "@/features/layout/page";
|
import {Page, PageActions, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
|
||||||
import {currentUser} from "@/lib/auth/current-user";
|
import {currentUser} from "@/lib/auth/current-user";
|
||||||
import {getActiveMember, getOrganization} from "@/lib/auth/auth";
|
import {getActiveMember, getOrganization} from "@/lib/auth/auth";
|
||||||
import {notFound} from "next/navigation";
|
import {notFound} from "next/navigation";
|
||||||
@@ -27,7 +27,6 @@ export default async function RoutePage(props: PageParams<{ slug: string }>) {
|
|||||||
notFound();
|
notFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
<PageHeader>
|
<PageHeader>
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
|
|
||||||
import {Check, ChevronDown} from "lucide-react";
|
import {Check, ChevronDown} from "lucide-react";
|
||||||
|
|
||||||
import {cn} from "@/lib/utils";
|
import {cn} from "@/lib/utils";
|
||||||
import {Button} from "@/components/ui/button";
|
import {Button} from "@/components/ui/button";
|
||||||
import {Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList} from "@/components/ui/command";
|
import {Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList} from "@/components/ui/command";
|
||||||
@@ -110,7 +108,6 @@ export type comboBoxFormItemProps = comboBoxProps & {
|
|||||||
onChange: any;
|
onChange: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Combobox to use when working with zodForm. */
|
|
||||||
export function ComboBoxFormItem(props: comboBoxFormItemProps) {
|
export function ComboBoxFormItem(props: comboBoxFormItemProps) {
|
||||||
const {values: choices, searchField = false, value, name, onChange} = props;
|
const {values: choices, searchField = false, value, name, onChange} = props;
|
||||||
|
|
||||||
|
|||||||
+3
@@ -14,6 +14,8 @@ export type DeleteOrganizationButtonProps = {
|
|||||||
|
|
||||||
export const DeleteOrganizationButton = (props: DeleteOrganizationButtonProps) => {
|
export const DeleteOrganizationButton = (props: DeleteOrganizationButtonProps) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const {data: organizations, refetch} = authClient.useListOrganizations();
|
||||||
|
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationFn: () => deleteOrganizationAction(props.organizationSlug),
|
mutationFn: () => deleteOrganizationAction(props.organizationSlug),
|
||||||
|
|
||||||
@@ -25,6 +27,7 @@ export const DeleteOrganizationButton = (props: DeleteOrganizationButtonProps) =
|
|||||||
router.push("/");
|
router.push("/");
|
||||||
toast.success(result.data.actionSuccess?.message || "Organization deleted.");
|
toast.success(result.data.actionSuccess?.message || "Organization deleted.");
|
||||||
router.refresh()
|
router.refresh()
|
||||||
|
refetch()
|
||||||
} else {
|
} else {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const errorMsg = result?.data?.actionError?.message || result?.data?.actionError?.messageParams?.message || "Failed to delete the organization.";
|
const errorMsg = result?.data?.actionError?.message || result?.data?.actionError?.messageParams?.message || "Failed to delete the organization.";
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import {ComboBox} from "@/components/wrappers/common/combobox";
|
|||||||
import {useSidebar} from "@/components/ui/sidebar";
|
import {useSidebar} from "@/components/ui/sidebar";
|
||||||
import {useRouter} from "next/navigation";
|
import {useRouter} from "next/navigation";
|
||||||
import {authClient} from "@/lib/auth/auth-client";
|
import {authClient} from "@/lib/auth/auth-client";
|
||||||
import {auth} from "@/lib/auth/auth";
|
|
||||||
|
|
||||||
|
|
||||||
export function OrganizationCombobox() {
|
export function OrganizationCombobox() {
|
||||||
@@ -16,9 +15,6 @@ export function OrganizationCombobox() {
|
|||||||
|
|
||||||
if (!organizations) return null;
|
if (!organizations) return null;
|
||||||
|
|
||||||
console.log("organizations", organizations);
|
|
||||||
console.log("activeOrganization", activeOrganization);
|
|
||||||
|
|
||||||
const values = organizations.map((organization) => {
|
const values = organizations.map((organization) => {
|
||||||
return {
|
return {
|
||||||
value: organization.slug,
|
value: organization.slug,
|
||||||
@@ -26,8 +22,6 @@ export function OrganizationCombobox() {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const onValueChange = async (slug: string) => {
|
const onValueChange = async (slug: string) => {
|
||||||
|
|
||||||
await authClient.organization.setActive({
|
await authClient.organization.setActive({
|
||||||
|
|||||||
Reference in New Issue
Block a user