import { useState } from 'react'; import styled from '@emotion/styled'; import { CellCommentChip } from '@/comments/components/comments/CellCommentChip'; import { useOpenCommentRightDrawer } from '@/comments/hooks/useOpenCommentRightDrawer'; import { EditableDoubleText } from '@/ui/components/editable-cell/types/EditableDoubleText'; import { CommentableType } from '~/generated/graphql'; import { Person } from '../interfaces/person.interface'; import { PersonChip } from './PersonChip'; type OwnProps = { person: Person; onChange: (firstname: string, lastname: string) => void; }; const StyledDiv = styled.div` align-items: center; display: flex; justify-content: space-between; width: 100%; `; export function EditablePeopleFullName({ person, onChange }: OwnProps) { const [firstnameValue, setFirstnameValue] = useState(person.firstname ?? ''); const [lastnameValue, setLastnameValue] = useState(person.lastname ?? ''); const openCommentRightDrawer = useOpenCommentRightDrawer(); function handleDoubleTextChange( firstValue: string, secondValue: string, ): void { setFirstnameValue(firstValue); setLastnameValue(secondValue); onChange(firstValue, secondValue); } function handleCommentClick(event: React.MouseEvent) { event.preventDefault(); event.stopPropagation(); openCommentRightDrawer([ { type: CommentableType.Person, id: person.id, }, ]); } return ( } /> ); }