Saas-Teamspace/components/project-select.tsx
2024-11-25 01:24:37 -05:00

91 lines
2.5 KiB
TypeScript

import * as React from "react"
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
import { Button } from "@/components/ui/button"
import { PlusCircle } from "lucide-react"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
export function ProjectSelect() {
const [open, setOpen] = React.useState(false)
const [projectName, setProjectName] = React.useState("")
// This would be fetched from your backend
const projects = [
{ id: "1", name: "Marketing Website" },
{ id: "2", name: "Mobile App" },
{ id: "3", name: "Dashboard Redesign" },
]
const handleCreateProject = () => {
// Handle project creation here
setOpen(false)
setProjectName("")
}
return (
<div className="flex items-center gap-2">
<Select>
<SelectTrigger className="w-[200px]">
<SelectValue placeholder="Select project" />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectLabel>Projects</SelectLabel>
{projects.map((project) => (
<SelectItem key={project.id} value={project.id}>
{project.name}
</SelectItem>
))}
</SelectGroup>
</SelectContent>
</Select>
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
<Button variant="outline" size="icon">
<PlusCircle className="h-4 w-4" />
</Button>
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Create New Project</DialogTitle>
<DialogDescription>
Add a new project to organize your tasks.
</DialogDescription>
</DialogHeader>
<div className="grid gap-4 py-4">
<div className="grid gap-2">
<Label htmlFor="name">Project name</Label>
<Input
id="name"
value={projectName}
onChange={(e) => setProjectName(e.target.value)}
placeholder="Enter project name"
/>
</div>
</div>
<DialogFooter>
<Button onClick={handleCreateProject}>Create Project</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</div>
)
}