mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
fix: server/client error on some dialogs.
This commit is contained in:
@@ -8,36 +8,61 @@ import {
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog";
|
||||
import {ProjectForm} from "@/features/projects/components/project.form";
|
||||
import {useState} from "react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {ReactNode, useState} from "react";
|
||||
import {Button, buttonVariants} from "@/components/ui/button";
|
||||
import {Plus} from "lucide-react";
|
||||
import {DatabaseWith} from "@/db/schema/07_database";
|
||||
import {Organization} from "@/db/schema/03_organization";
|
||||
import {ProjectWith} from "@/db/schema/06_project";
|
||||
import {GearIcon} from "@radix-ui/react-icons";
|
||||
import {EmptyStatePlaceholder} from "@/components/wrappers/common/empty-state-placeholder";
|
||||
|
||||
type ProjectDialogProps = {
|
||||
children?: React.ReactNode;
|
||||
children?: ReactNode;
|
||||
databases: DatabaseWith[];
|
||||
organization: Organization;
|
||||
project?: ProjectWith;
|
||||
isEdit?: boolean;
|
||||
isEmpty?: boolean;
|
||||
};
|
||||
|
||||
export const ProjectDialog = ({children, databases, organization, project}: ProjectDialogProps) => {
|
||||
export const ProjectDialog = ({
|
||||
databases,
|
||||
organization,
|
||||
project,
|
||||
isEdit = false,
|
||||
isEmpty = false
|
||||
}: ProjectDialogProps) => {
|
||||
const [open, setOpen] = useState(false);
|
||||
const isEdit = !!project;
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>
|
||||
{children ? children : <Button><Plus className="mr-2 h-4 w-4"/> Create Project</Button>}
|
||||
<div>
|
||||
{isEdit ?
|
||||
<div className={buttonVariants({variant: "outline", className: "cursor-pointer"})}>
|
||||
<GearIcon className="w-7 h-7"/>
|
||||
</div>
|
||||
:
|
||||
<>
|
||||
{isEmpty ?
|
||||
<EmptyStatePlaceholder text="Create new Project"/>
|
||||
:
|
||||
<Button><Plus className="mr-2 h-4 w-4"/> Create Project</Button>
|
||||
}
|
||||
</>
|
||||
}
|
||||
</div>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogContent
|
||||
onOpenAutoFocus={(e) => e.preventDefault()}
|
||||
>
|
||||
<DialogHeader>
|
||||
<DialogTitle>{isEdit ? `Edit ${project.name}` : "Create new project"}</DialogTitle>
|
||||
<DialogTitle>{isEdit ? `Edit ${project?.name}` : "Create new project"}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<ProjectForm
|
||||
onSuccess={() => setOpen(false)}
|
||||
databases={databases}
|
||||
<ProjectForm
|
||||
onSuccess={() => setOpen(false)}
|
||||
databases={databases}
|
||||
organization={organization}
|
||||
defaultValues={project ? {
|
||||
...project,
|
||||
|
||||
Reference in New Issue
Block a user