Optimize table loading (#866)
* wip * wip * Ok * Deleted unused code * Fixed lint * Minor fixes * Minor fixes * Minor Fixes * Minor merge fixes * Ok * Fix storybook tests * Removed console.log * Fix login * asd * Fixed storybook * Added await * Fixed await * Added sleep for failing test * Fix sleep * Fix test * Fix tests --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -48,15 +48,19 @@ export function CompanyAccountOwnerPicker({
|
||||
searchOnFields: ['firstName', 'lastName'],
|
||||
});
|
||||
|
||||
async function handleEntitySelected(selectedUser: UserForSelect) {
|
||||
await updateCompany({
|
||||
variables: {
|
||||
where: { id: company.id },
|
||||
data: {
|
||||
accountOwner: { connect: { id: selectedUser.id } },
|
||||
async function handleEntitySelected(
|
||||
selectedUser: UserForSelect | null | undefined,
|
||||
) {
|
||||
if (selectedUser) {
|
||||
await updateCompany({
|
||||
variables: {
|
||||
where: { id: company.id },
|
||||
data: {
|
||||
accountOwner: { connect: { id: selectedUser.id } },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
onSubmit?.();
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { getOperationName } from '@apollo/client/utilities';
|
||||
|
||||
import { EditableCellChip } from '@/ui/table/editable-cell/types/EditableChip';
|
||||
@ -22,17 +21,10 @@ type OwnProps = {
|
||||
export function CompanyEditableNameChipCell({ company }: OwnProps) {
|
||||
const [updateCompany] = useUpdateOneCompanyMutation();
|
||||
|
||||
const [internalValue, setInternalValue] = useState(company.name ?? '');
|
||||
|
||||
useEffect(() => {
|
||||
setInternalValue(company.name ?? '');
|
||||
}, [company.name]);
|
||||
|
||||
return (
|
||||
<EditableCellChip
|
||||
value={internalValue}
|
||||
value={company.name}
|
||||
placeholder="Name"
|
||||
changeHandler={setInternalValue}
|
||||
ChipComponent={
|
||||
<CompanyChip
|
||||
id={company.id}
|
||||
@ -40,18 +32,17 @@ export function CompanyEditableNameChipCell({ company }: OwnProps) {
|
||||
pictureUrl={getLogoUrlFromDomainName(company.domainName)}
|
||||
/>
|
||||
}
|
||||
onSubmit={() =>
|
||||
onSubmit={(newName) =>
|
||||
updateCompany({
|
||||
variables: {
|
||||
where: { id: company.id },
|
||||
data: {
|
||||
name: internalValue,
|
||||
name: newName,
|
||||
},
|
||||
},
|
||||
refetchQueries: [getOperationName(GET_COMPANY) ?? ''],
|
||||
})
|
||||
}
|
||||
onCancel={() => setInternalValue(company.name ?? '')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user