fix: POC assigning in opportunities (#1443)
* fix: opportunities-poc-select * gql codegen * code review changes
This commit is contained in:
@ -3,6 +3,7 @@ import styled from '@emotion/styled';
|
||||
import { useRecoilState } from 'recoil';
|
||||
|
||||
import { CompanyPicker } from '@/companies/components/CompanyPicker';
|
||||
import { companyProgressesFamilyState } from '@/companies/states/companyProgressesFamilyState';
|
||||
import { PeoplePicker } from '@/people/components/PeoplePicker';
|
||||
import { EntityForSelect } from '@/ui/input/relation-picker/types/EntityForSelect';
|
||||
import { Entity } from '@/ui/input/relation-picker/types/EntityTypeForSelect';
|
||||
@ -32,7 +33,7 @@ function RelationPicker({
|
||||
handleCancel,
|
||||
}: {
|
||||
fieldDefinition: FieldDefinition<FieldRelationMetadata>;
|
||||
fieldValue: FieldRelationValue;
|
||||
fieldValue: FieldRelationValue & { companyId?: string };
|
||||
handleEntitySubmit: (newRelationId: EntityForSelect | null) => void;
|
||||
handleCancel: () => void;
|
||||
}) {
|
||||
@ -41,6 +42,7 @@ function RelationPicker({
|
||||
return (
|
||||
<PeoplePicker
|
||||
personId={fieldValue ? fieldValue.id : ''}
|
||||
companyId={fieldValue?.companyId ?? ''}
|
||||
onSubmit={handleEntitySubmit}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
@ -78,6 +80,11 @@ export function GenericEditableRelationFieldEditMode() {
|
||||
EditableFieldDefinitionContext,
|
||||
) as FieldDefinition<FieldRelationMetadata>;
|
||||
|
||||
const [companyProgress] = useRecoilState(
|
||||
companyProgressesFamilyState(currentEditableFieldEntityId ?? ''),
|
||||
);
|
||||
const { company } = companyProgress ?? {};
|
||||
|
||||
// TODO: we could use a hook that would return the field value with the right type
|
||||
const [fieldValue, setFieldValue] = useRecoilState<any | null>(
|
||||
genericEntityFieldFamilySelector({
|
||||
@ -119,7 +126,7 @@ export function GenericEditableRelationFieldEditMode() {
|
||||
<StyledRelationPickerContainer>
|
||||
<RelationPicker
|
||||
fieldDefinition={currentEditableFieldDefinition}
|
||||
fieldValue={fieldValue}
|
||||
fieldValue={{ ...fieldValue, companyId: company?.id }}
|
||||
handleEntitySubmit={handleSubmit}
|
||||
handleCancel={handleCancel}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user