import { Button, TableCell, TableRow, TextField } from '@mui/material'; import { Dispatch, useState } from 'react'; import { Profile } from '../../../../data/types'; import { DeleteProfileAction } from './actions/DeleteProfileAction'; import { UpdateProfileAction } from './actions/UpdateProfileAction'; interface ProfilesTableRowProps { profile: Profile; selected: string | undefined; setSelected: Dispatch; onDelete: () => void; } export default function ProfilesTableRow({ profile, selected, setSelected, onDelete }: ProfilesTableRowProps) { const [isEditing, setIsEditing] = useState(false); const [name, setName] = useState(profile.name); const handleClick = () => { setSelected(profile.id); }; const handleDoubleClick = () => { setIsEditing(true); }; const handleBlur = async () => { setIsEditing(false); try { await UpdateProfileAction({ id: profile.id, name }); } catch (error) { console.error("Couldn't update profile."); } }; const handleChange = (event: React.ChangeEvent) => { setName(event.target.value); }; const handleDelete = async () => { try { await DeleteProfileAction(profile.id); onDelete(); } catch (error) { console.error("Couldn't delete profile."); } }; return ( {isEditing ? ( ) : ( name )} ); }