// Copyright 2024 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React, { useCallback, useState } from 'react'; import { v4 as generateUuid } from 'uuid'; import { Modal } from './Modal'; import type { LocalizerType } from '../types/I18N'; import { Button, ButtonVariant } from './Button'; import { Avatar, AvatarSize } from './Avatar'; import { Input } from './Input'; import type { CallLinkType } from '../types/CallLink'; import { getColorForCallLink } from '../util/getColorForCallLink'; export type CallLinkAddNameModalProps = Readonly<{ i18n: LocalizerType; callLink: CallLinkType; onClose: () => void; onUpdateCallLinkName: (name: string) => void; }>; export function CallLinkAddNameModal({ i18n, callLink, onClose, onUpdateCallLinkName, }: CallLinkAddNameModalProps): JSX.Element { const [formId] = useState(() => generateUuid()); const [nameId] = useState(() => generateUuid()); const [nameInput, setNameInput] = useState(callLink.name); const handleNameInputChange = useCallback((nextNameInput: string) => { setNameInput(nextNameInput); }, []); const handleSubmit = useCallback(() => { const nameValue = nameInput.trim(); if (nameValue === callLink.name) { return; } onUpdateCallLinkName(nameValue); onClose(); }, [nameInput, callLink, onUpdateCallLinkName, onClose]); return ( } >
); }