feat: setting default attributes after deal creating
This commit is contained in:
@ -34,7 +34,7 @@ const PageBody = () => {
|
||||
if (view === "table") {
|
||||
return { withPagination: true, projectId: selectedProject?.id };
|
||||
}
|
||||
return { boardId: selectedBoard?.id };
|
||||
return { boardId: selectedBoard?.id, projectId: selectedProject?.id };
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@ -54,6 +54,7 @@ const useDealsContextState = ({
|
||||
|
||||
const dealsCrud = useDealsCrud({
|
||||
...dealsListObjects,
|
||||
projectId,
|
||||
boardId,
|
||||
statuses,
|
||||
});
|
||||
|
||||
@ -16,6 +16,7 @@ import { getNewLexorank } from "@/utils/lexorank/generation";
|
||||
type UseDealsOperationsProps = {
|
||||
deals: DealSchema[];
|
||||
boardId?: number;
|
||||
projectId?: number;
|
||||
statuses: StatusSchema[];
|
||||
queryKey: any[];
|
||||
};
|
||||
@ -28,6 +29,7 @@ export type DealsCrud = {
|
||||
|
||||
export const useDealsCrud = ({
|
||||
deals,
|
||||
projectId,
|
||||
boardId,
|
||||
statuses,
|
||||
queryKey,
|
||||
@ -41,7 +43,7 @@ export const useDealsCrud = ({
|
||||
delete: deleteDealMutation(),
|
||||
},
|
||||
getCreateEntity: data => {
|
||||
if (!boardId || statuses.length === 0) return null;
|
||||
if (!boardId || !projectId || statuses.length === 0) return null;
|
||||
const firstStatus = statuses[0];
|
||||
const filteredDeals = deals.filter(
|
||||
d => d.status.id === firstStatus.id
|
||||
@ -58,6 +60,7 @@ export const useDealsCrud = ({
|
||||
...data,
|
||||
name: data.name!,
|
||||
boardId,
|
||||
projectId,
|
||||
statusId: firstStatus.id,
|
||||
lexorank: newLexorank.toString(),
|
||||
};
|
||||
|
||||
@ -510,6 +510,10 @@ export type CreateDealSchema = {
|
||||
* Name
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Projectid
|
||||
*/
|
||||
projectId: number;
|
||||
/**
|
||||
* Boardid
|
||||
*/
|
||||
|
||||
@ -102,14 +102,14 @@ export const zBoardSchema = z.object({
|
||||
* Body_upload_product_barcode_image
|
||||
*/
|
||||
export const zBodyUploadProductBarcodeImage = z.object({
|
||||
upload_file: z.any(),
|
||||
upload_file: z.string(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Body_upload_product_image
|
||||
*/
|
||||
export const zBodyUploadProductImage = z.object({
|
||||
upload_file: z.any(),
|
||||
upload_file: z.string(),
|
||||
});
|
||||
|
||||
/**
|
||||
@ -386,6 +386,7 @@ export const zCreateDealProductResponse = z.object({
|
||||
*/
|
||||
export const zCreateDealSchema = z.object({
|
||||
name: z.string(),
|
||||
projectId: z.int(),
|
||||
boardId: z.int(),
|
||||
lexorank: z.string(),
|
||||
statusId: z.int(),
|
||||
|
||||
Reference in New Issue
Block a user