Add back pickers on all pages, fix command menu (#2662)

* Add back pickers on all pages, fix command menu

* Fix lint
This commit is contained in:
Charles Bochet
2023-11-22 22:32:25 +01:00
committed by GitHub
parent 41c0cebf48
commit ec3cfe6fdb
42 changed files with 425 additions and 300 deletions
@@ -0,0 +1,34 @@
import { useRecoilCallback } from 'recoil';
import { v4 } from 'uuid';
import { useCreateOneObjectRecord } from '@/object-record/hooks/useCreateOneObjectRecord';
import { Opportunity } from '@/pipeline/types/Opportunity';
import { boardCardIdsByColumnIdFamilyState } from '@/ui/object/record-board/states/boardCardIdsByColumnIdFamilyState';
export const useCreateOpportunity = () => {
const { createOneObject: createOneOpportunity } =
useCreateOneObjectRecord<Opportunity>({
objectNameSingular: 'opportunity',
});
const createOpportunity = useRecoilCallback(
({ set }) =>
async (companyId: string, pipelineStepId: string) => {
const newUuid = v4();
set(boardCardIdsByColumnIdFamilyState(pipelineStepId), (oldValue) => [
...oldValue,
newUuid,
]);
await createOneOpportunity?.({
id: newUuid,
pipelineStepId,
companyId: companyId,
});
},
[createOneOpportunity],
);
return { createOpportunity };
};