Ready for release soon.
@@ -1,3 +1,2 @@
|
|||||||
nodeLinker: node-modules
|
nodeLinker: node-modules
|
||||||
|
|
||||||
yarnPath: .yarn/releases/yarn-4.6.0.cjs
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import * as drizzleDb from "@/db";
|
|||||||
import {db} from "@/db";
|
import {db} from "@/db";
|
||||||
import {EDbmsSchema} from "@/db/schema/types";
|
import {EDbmsSchema} from "@/db/schema/types";
|
||||||
import {eq} from "drizzle-orm";
|
import {eq} from "drizzle-orm";
|
||||||
|
import {isUuidv4} from "@/utils/verify-uuid";
|
||||||
|
|
||||||
export type databaseAgent = {
|
export type databaseAgent = {
|
||||||
name: string,
|
name: string,
|
||||||
@@ -34,6 +35,14 @@ export async function POST(
|
|||||||
const body: Body = await request.json();
|
const body: Body = await request.json();
|
||||||
const lastContact = new Date();
|
const lastContact = new Date();
|
||||||
|
|
||||||
|
if (!isUuidv4(agentId)) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{error: "agentId is not a valid uuid"},
|
||||||
|
{status: 500}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const agent = await db.query.agent.findFirst({
|
const agent = await db.query.agent.findFirst({
|
||||||
where: eq(drizzleDb.schemas.agent.id, agentId),
|
where: eq(drizzleDb.schemas.agent.id, agentId),
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export async function GET(
|
|||||||
{status: 403}
|
{status: 403}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
//@ts-ignore
|
||||||
const expiresAt = parseInt(expires, 10);
|
const expiresAt = parseInt(expires, 10);
|
||||||
if (Date.now() > expiresAt) {
|
if (Date.now() > expiresAt) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
|
|||||||
|
After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 90 KiB |
|
After Width: | Height: | Size: 7.7 KiB |
@@ -1,28 +1,31 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import type { Metadata } from "next";
|
import type {Metadata} from "next";
|
||||||
import { Inter } from "next/font/google";
|
import {Inter} from "next/font/google";
|
||||||
|
|
||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
import { Providers } from "./providers";
|
import {Providers} from "./providers";
|
||||||
import { cn } from "@/lib/utils";
|
import {cn} from "@/lib/utils";
|
||||||
|
|
||||||
const inter = Inter({ subsets: ["latin"] });
|
const inter = Inter({subsets: ["latin"]});
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Portabase",
|
title: process.env.NEXT_PUBLIC_PROJECT_NAME ?? "App Title",
|
||||||
description: "Manage all your database instances from one place !",
|
description: process.env.NEXT_PUBLIC_PROJECT_DESCRIPTION ?? undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RootLayout({
|
export default function RootLayout({
|
||||||
children,
|
children,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}>) {
|
}>) {
|
||||||
return (
|
return (
|
||||||
<html lang="en" suppressHydrationWarning>
|
<html lang="en" suppressHydrationWarning>
|
||||||
<body className={cn(inter.className, "h-full")}>
|
<head>
|
||||||
<Providers>{children}</Providers>
|
<meta name="apple-mobile-web-app-title" content="Portabase"/>
|
||||||
</body>
|
</head>
|
||||||
|
<body className={cn(inter.className, "h-full")}>
|
||||||
|
<Providers>{children}</Providers>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "Portabase",
|
||||||
|
"short_name": "Portabase",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "/web-app-manifest-192x192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/web-app-manifest-512x512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"theme_color": "#ffffff",
|
||||||
|
"background_color": "#ffffff",
|
||||||
|
"display": "standalone"
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
FROM node:23.5.0-alpine AS base
|
FROM node:23.5.0-alpine AS base
|
||||||
|
|
||||||
ENV YARN_VERSION=4.6.0
|
ENV YARN_VERSION=4.9.1
|
||||||
|
|
||||||
RUN apk add --no-cache libc6-compat
|
RUN apk add --no-cache libc6-compat
|
||||||
RUN apk add --no-cache openssl
|
RUN apk add --no-cache openssl
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev -p 80",
|
"dev": "next dev --turbopack -p 80",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
@@ -110,5 +110,5 @@
|
|||||||
"typescript": "^5.8.3",
|
"typescript": "^5.8.3",
|
||||||
"zenstack": "2.14.2"
|
"zenstack": "2.14.2"
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@4.8.1+sha512.bc946f2a022d7a1a38adfc15b36a66a3807a67629789496c3714dd1703d2e6c6b1c69ff9ec3b43141ac7a1dd853b7685638eb0074300386a59c18df351ef8ff6"
|
"packageManager": "yarn@4.9.1"
|
||||||
}
|
}
|
||||||
|
|||||||
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 61 KiB |
@@ -1,17 +1,17 @@
|
|||||||
"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";
|
||||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
import {Popover, PopoverContent, PopoverTrigger} from "@/components/ui/popover";
|
||||||
import { FormControl } from "@/components/ui/form";
|
import {FormControl} from "@/components/ui/form";
|
||||||
import { SidebarMenuButton } from "@/components/ui/sidebar";
|
import {SidebarMenuButton} from "@/components/ui/sidebar";
|
||||||
import { Separator } from "@/components/ui/separator";
|
import {Separator} from "@/components/ui/separator";
|
||||||
import { CreateOrganizationModal } from "@/components/wrappers/dashboard/organization/create-organisation-modal";
|
import {CreateOrganizationModal} from "@/components/wrappers/dashboard/organization/create-organisation-modal";
|
||||||
|
|
||||||
export type comboBoxProps = {
|
export type comboBoxProps = {
|
||||||
values: Array<{ value: string; label: string }>;
|
values: Array<{ value: string; label: string }>;
|
||||||
@@ -19,10 +19,18 @@ export type comboBoxProps = {
|
|||||||
onValueChange?: any;
|
onValueChange?: any;
|
||||||
searchField?: boolean;
|
searchField?: boolean;
|
||||||
sideBar?: boolean;
|
sideBar?: boolean;
|
||||||
|
reload?: () => void;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function ComboBox(props: comboBoxProps) {
|
export function ComboBox(props: comboBoxProps) {
|
||||||
const { values: choices, defaultValue: defaultChoice = "", onValueChange, searchField = false, sideBar = false } = props;
|
const {
|
||||||
|
values: choices,
|
||||||
|
defaultValue: defaultChoice = "",
|
||||||
|
onValueChange,
|
||||||
|
searchField = false,
|
||||||
|
sideBar = false
|
||||||
|
} = props;
|
||||||
|
|
||||||
const [value, setValue] = useState<string>();
|
const [value, setValue] = useState<string>();
|
||||||
|
|
||||||
@@ -31,53 +39,68 @@ export function ComboBox(props: comboBoxProps) {
|
|||||||
}, [defaultChoice]);
|
}, [defaultChoice]);
|
||||||
|
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
const [openModal, setOpenModal] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover open={open} onOpenChange={setOpen}>
|
<div>
|
||||||
<PopoverTrigger asChild>
|
<CreateOrganizationModal
|
||||||
{sideBar ? (
|
open={openModal}
|
||||||
<SidebarMenuButton>
|
onSuccess={() => {
|
||||||
{value ? choices.find((choice) => choice.value === value)?.label : "Select choice..."}
|
props.reload?.();
|
||||||
<ChevronDown className="ml-auto" />
|
}}
|
||||||
</SidebarMenuButton>
|
onOpenChange={setOpenModal}
|
||||||
) : (
|
/>
|
||||||
<Button variant="outline" role="combobox" aria-expanded={open} className="w-full justify-between">
|
|
||||||
{value ? choices.find((choice) => choice.value === value)?.label : "Select choice..."}
|
<Popover open={open} onOpenChange={setOpen}>
|
||||||
<ChevronDown className="opacity-50" />
|
<PopoverTrigger asChild>
|
||||||
</Button>
|
{sideBar ? (
|
||||||
)}
|
<SidebarMenuButton>
|
||||||
</PopoverTrigger>
|
{value ? choices.find((choice) => choice.value === value)?.label : "Select choice..."}
|
||||||
<PopoverContent className="p-0 popover-content-width-full">
|
<ChevronDown className="ml-auto"/>
|
||||||
<Command>
|
</SidebarMenuButton>
|
||||||
{searchField ? <CommandInput placeholder="Search choice..." className="h-9" /> : null}
|
) : (
|
||||||
<CommandList>
|
<Button variant="outline" role="combobox" aria-expanded={open}
|
||||||
<CommandEmpty>No choice found.</CommandEmpty>
|
className="w-full justify-between">
|
||||||
<CommandGroup>
|
{value ? choices.find((choice) => choice.value === value)?.label : "Select choice..."}
|
||||||
{choices.map((choice) => (
|
<ChevronDown className="opacity-50"/>
|
||||||
<CommandItem
|
</Button>
|
||||||
key={choice.value}
|
)}
|
||||||
value={choice.value}
|
</PopoverTrigger>
|
||||||
onSelect={(currentValue) => {
|
<PopoverContent className="p-0 popover-content-width-full">
|
||||||
setValue(currentValue);
|
<Command>
|
||||||
onValueChange(currentValue);
|
{searchField ? <CommandInput placeholder="Search choice..." className="h-9"/> : null}
|
||||||
setOpen(false);
|
<CommandList>
|
||||||
}}
|
<CommandEmpty>No choice found.</CommandEmpty>
|
||||||
>
|
<CommandGroup>
|
||||||
{choice.label}
|
{choices.map((choice) => (
|
||||||
<Check className={cn("ml-auto", value === choice.value ? "opacity-100" : "opacity-0")} />
|
<CommandItem
|
||||||
</CommandItem>
|
key={choice.value}
|
||||||
))}
|
value={choice.value}
|
||||||
</CommandGroup>
|
onSelect={(currentValue) => {
|
||||||
</CommandList>
|
setValue(currentValue);
|
||||||
</Command>
|
onValueChange(currentValue);
|
||||||
<Separator />
|
setOpen(false);
|
||||||
{sideBar ? (
|
}}
|
||||||
<CreateOrganizationModal>
|
>
|
||||||
<SidebarMenuButton>+ Create new organization</SidebarMenuButton>
|
{choice.label}
|
||||||
</CreateOrganizationModal>
|
<Check
|
||||||
) : null}
|
className={cn("ml-auto", value === choice.value ? "opacity-100" : "opacity-0")}/>
|
||||||
</PopoverContent>
|
</CommandItem>
|
||||||
</Popover>
|
))}
|
||||||
|
</CommandGroup>
|
||||||
|
</CommandList>
|
||||||
|
</Command>
|
||||||
|
<Separator/>
|
||||||
|
{sideBar ? (
|
||||||
|
<SidebarMenuButton onClick={() => {
|
||||||
|
setOpen(false)
|
||||||
|
setOpenModal(true)
|
||||||
|
}
|
||||||
|
}>+ Create new organization</SidebarMenuButton>
|
||||||
|
) : null}
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +112,7 @@ export type comboBoxFormItemProps = comboBoxProps & {
|
|||||||
|
|
||||||
/** Combobox to use when working with zodForm. */
|
/** 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;
|
||||||
|
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
@@ -97,15 +120,16 @@ export function ComboBoxFormItem(props: comboBoxFormItemProps) {
|
|||||||
<Popover open={open} onOpenChange={setOpen}>
|
<Popover open={open} onOpenChange={setOpen}>
|
||||||
<PopoverTrigger asChild>
|
<PopoverTrigger asChild>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Button variant="outline" role="combobox" aria-expanded={open} className={cn("w-full justify-between", !value && "text-muted-foreground")}>
|
<Button variant="outline" role="combobox" aria-expanded={open}
|
||||||
|
className={cn("w-full justify-between", !value && "text-muted-foreground")}>
|
||||||
{value ? choices.find((choice) => choice.value === value)?.label : `Select ${name}`}
|
{value ? choices.find((choice) => choice.value === value)?.label : `Select ${name}`}
|
||||||
<ChevronDown className="opacity-50" />
|
<ChevronDown className="opacity-50"/>
|
||||||
</Button>
|
</Button>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent className="p-0 popover-content-width-full">
|
<PopoverContent className="p-0 popover-content-width-full">
|
||||||
<Command>
|
<Command>
|
||||||
{searchField ? <CommandInput placeholder="Search choice..." className="h-9" /> : null}
|
{searchField ? <CommandInput placeholder="Search choice..." className="h-9"/> : null}
|
||||||
<CommandList>
|
<CommandList>
|
||||||
<CommandEmpty>No {name} found.</CommandEmpty>
|
<CommandEmpty>No {name} found.</CommandEmpty>
|
||||||
<CommandGroup>
|
<CommandGroup>
|
||||||
@@ -119,7 +143,8 @@ export function ComboBoxFormItem(props: comboBoxFormItemProps) {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{choice.label}
|
{choice.label}
|
||||||
<Check className={cn("ml-auto", choice.value === value ? "opacity-100" : "opacity-0")} />
|
<Check
|
||||||
|
className={cn("ml-auto", choice.value === value ? "opacity-100" : "opacity-0")}/>
|
||||||
</CommandItem>
|
</CommandItem>
|
||||||
))}
|
))}
|
||||||
</CommandGroup>
|
</CommandGroup>
|
||||||
|
|||||||
@@ -1,25 +1,26 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useMutation } from "@tanstack/react-query";
|
import {useMutation} from "@tanstack/react-query";
|
||||||
|
|
||||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
|
import {Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle} from "@/components/ui/dialog";
|
||||||
import { Button } from "@/components/ui/button";
|
import {Button} from "@/components/ui/button";
|
||||||
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, useZodForm } from "@/components/ui/form";
|
import {Form, FormControl, FormField, FormItem, FormLabel, FormMessage, useZodForm} from "@/components/ui/form";
|
||||||
import { Input } from "@/components/ui/input";
|
import {Input} from "@/components/ui/input";
|
||||||
import { OrganizationSchema } from "@/components/wrappers/dashboard/organization/organization.schema";
|
import {OrganizationSchema} from "@/components/wrappers/dashboard/organization/organization.schema";
|
||||||
import { createOrganizationAction } from "@/components/wrappers/dashboard/organization/organization.action";
|
import {createOrganizationAction} from "@/components/wrappers/dashboard/organization/organization.action";
|
||||||
import { useRouter } from "next/navigation";
|
import {useRouter} from "next/navigation";
|
||||||
import { useState } from "react";
|
import {useState} from "react";
|
||||||
import { authClient } from "@/lib/auth/auth-client";
|
import {authClient} from "@/lib/auth/auth-client";
|
||||||
|
|
||||||
export type createOrganizationModalProps = {
|
export type createOrganizationModalProps = {
|
||||||
children: any;
|
open: boolean;
|
||||||
|
onOpenChange: (open: boolean) => void;
|
||||||
|
onSuccess?: () => void;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function CreateOrganizationModal(props: createOrganizationModalProps) {
|
export function CreateOrganizationModal({open, onOpenChange, onSuccess}: createOrganizationModalProps) {
|
||||||
const [open, setOpen] = useState(false);
|
|
||||||
|
|
||||||
const { children } = props;
|
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ export function CreateOrganizationModal(props: createOrganizationModalProps) {
|
|||||||
schema: OrganizationSchema,
|
schema: OrganizationSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationFn: async (values: OrganizationSchema) => {
|
mutationFn: async (values: OrganizationSchema) => {
|
||||||
console.log(values);
|
console.log(values);
|
||||||
@@ -35,18 +37,18 @@ export function CreateOrganizationModal(props: createOrganizationModalProps) {
|
|||||||
|
|
||||||
if (result && result.data) {
|
if (result && result.data) {
|
||||||
if (result.data.success && result.data.value) {
|
if (result.data.success && result.data.value) {
|
||||||
setOpen(false);
|
onOpenChange(false);
|
||||||
await authClient.organization.setActive({ organizationSlug: result.data.value.slug });
|
await authClient.organization.setActive({organizationSlug: result.data.value.slug});
|
||||||
router.replace(`/dashboard/${result.data.value.slug}/home`);
|
onSuccess?.();
|
||||||
|
router.replace(`/dashboard/home`);
|
||||||
|
// router.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={setOpen}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogTrigger asChild>{children}</DialogTrigger>
|
|
||||||
|
|
||||||
<DialogContent className="sm:max-w-[425px] w-full">
|
<DialogContent className="sm:max-w-[425px] w-full">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>Create a new organization</DialogTitle>
|
<DialogTitle>Create a new organization</DialogTitle>
|
||||||
@@ -65,13 +67,13 @@ export function CreateOrganizationModal(props: createOrganizationModalProps) {
|
|||||||
control={form.control}
|
control={form.control}
|
||||||
name="name"
|
name="name"
|
||||||
defaultValue=""
|
defaultValue=""
|
||||||
render={({ field }) => (
|
render={({field}) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Name</FormLabel>
|
<FormLabel>Name</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input {...field} />
|
<Input {...field} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
@@ -79,7 +81,7 @@ export function CreateOrganizationModal(props: createOrganizationModalProps) {
|
|||||||
control={form.control}
|
control={form.control}
|
||||||
name="slug"
|
name="slug"
|
||||||
defaultValue=""
|
defaultValue=""
|
||||||
render={({ field }) => (
|
render={({field}) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Slug</FormLabel>
|
<FormLabel>Slug</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
@@ -91,7 +93,7 @@ export function CreateOrganizationModal(props: createOrganizationModalProps) {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { ComboBox } from "@/components/wrappers/common/combobox";
|
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";
|
||||||
|
|
||||||
export function OrganizationCombobox() {
|
export function OrganizationCombobox() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { state } = useSidebar();
|
const {state} = useSidebar();
|
||||||
|
|
||||||
const { data: organizations } = authClient.useListOrganizations();
|
const {data: organizations, refetch} = authClient.useListOrganizations();
|
||||||
const { data: activeOrganization } = authClient.useActiveOrganization();
|
const {data: activeOrganization, refetch: refetchActiveOrga} = authClient.useActiveOrganization();
|
||||||
|
|
||||||
if (!organizations) return null;
|
if (!organizations) return null;
|
||||||
|
|
||||||
@@ -28,9 +28,16 @@ export function OrganizationCombobox() {
|
|||||||
await authClient.organization.setActive({
|
await authClient.organization.setActive({
|
||||||
organizationSlug: slug,
|
organizationSlug: slug,
|
||||||
});
|
});
|
||||||
// router.replace(`/dashboard/${slug}/home`);
|
|
||||||
router.refresh();
|
router.refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
return <>{state === "expanded" && <ComboBox sideBar values={values} defaultValue={activeOrganization?.slug} onValueChange={onValueChange} />}</>;
|
const handleReset = () => {
|
||||||
|
refetch();
|
||||||
|
refetchActiveOrga()
|
||||||
|
router.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
return <>{state === "expanded" &&
|
||||||
|
<ComboBox sideBar values={values} defaultValue={activeOrganization?.slug} onValueChange={onValueChange}
|
||||||
|
reload={handleReset}/>}</>;
|
||||||
}
|
}
|
||||||
|
|||||||