import * as React from "react" import { useTranslate } from "@workspace/i18n" import { Button } from "@workspace/ui/components/button" import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@workspace/ui/components/dialog" import { Input } from "@workspace/ui/components/input" import { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText, } from "@workspace/ui/components/input-group" import { mediaMessages } from "./messages" export interface MediaFolderDialogProps { description: string initialName?: string lockedSuffix?: string maxLength?: number open: boolean pending?: boolean title: string onOpenChange: (open: boolean) => void onSubmit: (name: string) => void } export function MediaFolderDialog({ description, initialName = "", lockedSuffix, maxLength = 50, open, pending, title, onOpenChange, onSubmit, }: MediaFolderDialogProps) { const t = useTranslate() const [name, setName] = React.useState(initialName) React.useEffect(() => { if (open) setName(initialName) }, [initialName, open]) const normalizedName = name.trim() const input = ( setName(event.target.value)} /> ) return (
{ event.preventDefault() if (normalizedName) onSubmit(normalizedName) }} > {title} {description} {lockedSuffix ? ( setName(event.target.value)} /> {lockedSuffix} ) : ( input )}
) }