import * as React from "react"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "../ui/dialog"; import { LoaderCircle, Plus } from "lucide-react"; import type { MembershipRole } from "@/types/organizations"; import { RadioGroup, RadioGroupItem } from "../ui/radio"; import { Label } from "../ui/label"; interface AddOrganizationDialogProps { isDialogOpen: boolean; setIsDialogOpen: (isOpen: boolean) => void; onAddOrganization: ({ org, role, }: { org: string; role: MembershipRole; }) => Promise; } export default function AddOrganizationDialog({ isDialogOpen, setIsDialogOpen, onAddOrganization, }: AddOrganizationDialogProps) { const [org, setOrg] = useState(""); const [role, setRole] = useState("member"); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(""); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!org || org.trim() === "") { setError("Please enter a valid organization name."); return; } try { setIsLoading(true); await onAddOrganization({ org, role }); setError(""); setOrg(""); setRole("member"); setIsDialogOpen(false); } catch (err: any) { setError(err?.message || "Failed to add repository."); } finally { setIsLoading(false); } }; return ( Add Organization You can add public organizations
setOrg(e.target.value)} className="w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring" placeholder="e.g., microsoft" autoComplete="off" autoFocus required />
setRole(val as MembershipRole)} className="flex flex-col gap-y-2" >
{error &&

{error}

}
); }