Files
twenty/front/src/modules/companies/components/CompanyAccountOwnerCell.tsx
Charles Bochet 4cb856a180 Design fixes (#696)
* Design fixes

* Fix design

* unused code

* Fix tests
2023-07-16 17:36:40 -07:00

53 lines
1.5 KiB
TypeScript

import { PersonChip } from '@/people/components/PersonChip';
import { RelationPickerHotkeyScope } from '@/ui/relation-picker/types/RelationPickerHotkeyScope';
import { EditableCell } from '@/ui/table/editable-cell/components/EditableCell';
import { useEditableCell } from '@/ui/table/editable-cell/hooks/useEditableCell';
import { Company, User } from '~/generated/graphql';
import { CompanyAccountOwnerPicker } from './CompanyAccountOwnerPicker';
export type CompanyAccountOnwer = Pick<Company, 'id'> & {
accountOwner?: Pick<User, 'id' | 'displayName' | 'avatarUrl'> | null;
};
export type OwnProps = {
company: CompanyAccountOnwer;
};
export function CompanyAccountOwnerCell({ company }: OwnProps) {
const { closeEditableCell } = useEditableCell();
function handleCancel() {
closeEditableCell();
}
function handleSubmit() {
closeEditableCell();
}
return (
<EditableCell
transparent
editHotkeyScope={{ scope: RelationPickerHotkeyScope.RelationPicker }}
editModeContent={
<CompanyAccountOwnerPicker
onCancel={handleCancel}
onSubmit={handleSubmit}
company={company}
/>
}
nonEditModeContent={
company.accountOwner?.displayName ? (
<PersonChip
id={company.accountOwner.id}
name={company.accountOwner?.displayName ?? ''}
picture={company.accountOwner?.avatarUrl ?? ''}
/>
) : (
<></>
)
}
/>
);
}