Opportunity fields (#744)

* Add opportunity probability and point of contact

* Have requests sent properly

* Add probaility field
This commit is contained in:
Emilien Chauvet
2023-07-18 17:32:15 -07:00
committed by GitHub
parent 87a116d369
commit f98e49c26e
7 changed files with 139 additions and 21 deletions

View File

@ -12,17 +12,15 @@ import { selectedBoardCardsState } from '@/pipeline/states/selectedBoardCardsSta
import { BoardCardEditableFieldDate } from '@/ui/board/card-field/components/BoardCardEditableFieldDate';
import { ChipVariant } from '@/ui/chip/components/EntityChip';
import { NumberEditableField } from '@/ui/editable-field/variants/components/NumberEditableField';
import { IconCurrencyDollar } from '@/ui/icon';
import { IconCheck, IconCurrencyDollar } from '@/ui/icon';
import { IconCalendarEvent } from '@/ui/icon';
import { Checkbox } from '@/ui/input/components/Checkbox';
import { useRecoilScopedState } from '@/ui/recoil-scope/hooks/useRecoilScopedState';
import {
PipelineProgress,
useUpdateOnePipelineProgressMutation,
} from '~/generated/graphql';
import { useUpdateOnePipelineProgressMutation } from '~/generated/graphql';
import { getLogoUrlFromDomainName } from '~/utils';
import { CompanyAccountOwnerEditableField } from '../editable-field/components/CompanyAccountOwnerEditableField';
import { PipelineProgressForBoard } from '../types/CompanyProgress';
import { CompanyChip } from './CompanyChip';
@ -104,14 +102,14 @@ export function CompanyBoardCard() {
}
const handleCardUpdate = useCallback(
async (
pipelineProgress: Pick<PipelineProgress, 'id' | 'amount' | 'closeDate'>,
) => {
async (pipelineProgress: PipelineProgressForBoard) => {
await updatePipelineProgress({
variables: {
id: pipelineProgress.id,
amount: pipelineProgress.amount,
closeDate: pipelineProgress.closeDate || null,
closeDate: pipelineProgress.closeDate,
probability: pipelineProgress.probability,
pointOfContactId: pipelineProgress.pointOfContactId || undefined,
},
refetchQueries: [
getOperationName(GET_PIPELINE_PROGRESS) ?? '',
@ -169,6 +167,17 @@ export function CompanyBoardCard() {
}}
/>
</span>
<NumberEditableField
icon={<IconCheck />}
placeholder="Opportunity probability for closing"
value={pipelineProgress.probability}
onSubmit={(value) =>
handleCardUpdate({
...pipelineProgress,
probability: value,
})
}
/>
</StyledBoardCardBody>
</StyledBoardCard>
</StyledBoardCardWrapper>

View File

@ -1,10 +1,17 @@
import { Company, PipelineProgress } from '~/generated/graphql';
import { Company, Person, PipelineProgress } from '~/generated/graphql';
export type CompanyForBoard = Pick<Company, 'id' | 'name' | 'domainName'>;
export type PipelineProgressForBoard = Pick<
PipelineProgress,
'id' | 'amount' | 'closeDate' | 'progressableId'
>;
| 'id'
| 'amount'
| 'closeDate'
| 'progressableId'
| 'probability'
| 'pointOfContactId'
> & {
pointOfContact?: Pick<Person, 'id' | 'firstName' | 'lastName'> | null;
};
export type CompanyProgress = {
company: CompanyForBoard;

View File

@ -37,6 +37,13 @@ export const GET_PIPELINE_PROGRESS = gql`
progressableId
amount
closeDate
pointOfContactId
pointOfContact {
id
firstName
lastName
}
probability
}
}
`;
@ -46,10 +53,17 @@ export const UPDATE_PIPELINE_PROGRESS = gql`
$id: String
$amount: Int
$closeDate: DateTime
$probability: Int
$pointOfContactId: String
) {
updateOnePipelineProgress(
where: { id: $id }
data: { amount: { set: $amount }, closeDate: { set: $closeDate } }
data: {
amount: { set: $amount }
closeDate: { set: $closeDate }
probability: { set: $probability }
pointOfContact: { connect: { id: $pointOfContactId } }
}
) {
id
amount