Add optimistic rendering for table relations (#1296)
* Add optimistic rendering for table relations * fix pr * fix pr * fix pr * Fix PR --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -12,12 +12,16 @@ import { useInsertOneCompanyMutation } from '~/generated/graphql';
|
||||
|
||||
export type OwnProps = {
|
||||
companyId: string | null;
|
||||
onSubmit: (newCompany: EntityForSelect | null) => void;
|
||||
onSubmit: (newCompany: CompanyPickerSelectedCompany | null) => void;
|
||||
onCancel?: () => void;
|
||||
createModeEnabled?: boolean;
|
||||
width?: number;
|
||||
};
|
||||
|
||||
export type CompanyPickerSelectedCompany = EntityForSelect & {
|
||||
domainName: string;
|
||||
};
|
||||
|
||||
export function CompanyPickerCell({
|
||||
companyId,
|
||||
onSubmit,
|
||||
@ -42,10 +46,10 @@ export function CompanyPickerCell({
|
||||
selectedIds: [companyId ?? ''],
|
||||
});
|
||||
|
||||
async function handleEntitySelected(
|
||||
entity: EntityForSelect | null | undefined,
|
||||
async function handleCompanySelected(
|
||||
company: CompanyPickerSelectedCompany | null | undefined,
|
||||
) {
|
||||
onSubmit(entity ?? null);
|
||||
onSubmit(company ?? null);
|
||||
}
|
||||
|
||||
function handleStartCreation() {
|
||||
@ -69,6 +73,7 @@ export function CompanyPickerCell({
|
||||
id: companyCreated.id,
|
||||
name: companyCreated.name,
|
||||
entityType: Entity.Company,
|
||||
domainName: companyCreated.domainName,
|
||||
});
|
||||
setIsCreating(false);
|
||||
}
|
||||
@ -86,7 +91,7 @@ export function CompanyPickerCell({
|
||||
width={width}
|
||||
onCreate={createModeEnabled ? handleStartCreation : undefined}
|
||||
onCancel={onCancel}
|
||||
onEntitySelected={handleEntitySelected}
|
||||
onEntitySelected={handleCompanySelected}
|
||||
entities={{
|
||||
entitiesToSelect: companies.entitiesToSelect,
|
||||
selectedEntity: companies.selectedEntities[0],
|
||||
|
||||
Reference in New Issue
Block a user