"use client"; import { useActionState } from "react"; import { Rule, Select } from "@unlocalhosted/metalui"; import type { FormState } from "@/app/actions/types"; import { DeleteZone } from "./delete-zone"; import { BookmarkIcon, GlobeIcon, LockIcon, PlusIcon } from "./icons"; import { ChoiceCards, TextareaField, TextField } from "./settings-fields"; import { PlateBody, PlateFooter } from "./settings-plate"; import { Alert, Avatar, Box, Button } from "./ui"; type Action = (prev: FormState, formData: FormData) => Promise; export type ListFields = { name: string; description: string; visibility: "public" | "private" }; /** A list's name, description and visibility; new lists also choose their owner (you, or an organization). */ export function ListForm({ action, owners, owner, list }: { action: Action; owners: string[]; owner: string; list?: ListFields }) { const [state, formAction, pending] = useActionState(action, undefined); return (
{!list && (
Owner {owners.length > 1 ? ( )}
)}
Visibility , title: "Public", description: "Anyone can see the list. Private repositories in it stay hidden from those who can’t see them." }, { value: "private", icon: , title: "Private", description: "Only you can see it, or for an organization’s list, its members." }, ]} />
{state?.error && {state.error}}
); } export function DeleteListZone({ action, name }: { action: Action; name: string }) { return ( This will permanently delete the list {name}. } openLabel="Delete List" confirmLabel="I Understand, Delete This List" /> ); }