feat: setting default attributes after deal creating

This commit is contained in:
2025-10-28 17:21:21 +04:00
parent ea6a6df371
commit 8019fa566c
5 changed files with 13 additions and 4 deletions

View File

@ -34,7 +34,7 @@ const PageBody = () => {
if (view === "table") { if (view === "table") {
return { withPagination: true, projectId: selectedProject?.id }; return { withPagination: true, projectId: selectedProject?.id };
} }
return { boardId: selectedBoard?.id }; return { boardId: selectedBoard?.id, projectId: selectedProject?.id };
}; };
return ( return (

View File

@ -54,6 +54,7 @@ const useDealsContextState = ({
const dealsCrud = useDealsCrud({ const dealsCrud = useDealsCrud({
...dealsListObjects, ...dealsListObjects,
projectId,
boardId, boardId,
statuses, statuses,
}); });

View File

@ -16,6 +16,7 @@ import { getNewLexorank } from "@/utils/lexorank/generation";
type UseDealsOperationsProps = { type UseDealsOperationsProps = {
deals: DealSchema[]; deals: DealSchema[];
boardId?: number; boardId?: number;
projectId?: number;
statuses: StatusSchema[]; statuses: StatusSchema[];
queryKey: any[]; queryKey: any[];
}; };
@ -28,6 +29,7 @@ export type DealsCrud = {
export const useDealsCrud = ({ export const useDealsCrud = ({
deals, deals,
projectId,
boardId, boardId,
statuses, statuses,
queryKey, queryKey,
@ -41,7 +43,7 @@ export const useDealsCrud = ({
delete: deleteDealMutation(), delete: deleteDealMutation(),
}, },
getCreateEntity: data => { getCreateEntity: data => {
if (!boardId || statuses.length === 0) return null; if (!boardId || !projectId || statuses.length === 0) return null;
const firstStatus = statuses[0]; const firstStatus = statuses[0];
const filteredDeals = deals.filter( const filteredDeals = deals.filter(
d => d.status.id === firstStatus.id d => d.status.id === firstStatus.id
@ -58,6 +60,7 @@ export const useDealsCrud = ({
...data, ...data,
name: data.name!, name: data.name!,
boardId, boardId,
projectId,
statusId: firstStatus.id, statusId: firstStatus.id,
lexorank: newLexorank.toString(), lexorank: newLexorank.toString(),
}; };

View File

@ -510,6 +510,10 @@ export type CreateDealSchema = {
* Name * Name
*/ */
name: string; name: string;
/**
* Projectid
*/
projectId: number;
/** /**
* Boardid * Boardid
*/ */

View File

@ -102,14 +102,14 @@ export const zBoardSchema = z.object({
* Body_upload_product_barcode_image * Body_upload_product_barcode_image
*/ */
export const zBodyUploadProductBarcodeImage = z.object({ export const zBodyUploadProductBarcodeImage = z.object({
upload_file: z.any(), upload_file: z.string(),
}); });
/** /**
* Body_upload_product_image * Body_upload_product_image
*/ */
export const zBodyUploadProductImage = z.object({ 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({ export const zCreateDealSchema = z.object({
name: z.string(), name: z.string(),
projectId: z.int(),
boardId: z.int(), boardId: z.int(),
lexorank: z.string(), lexorank: z.string(),
statusId: z.int(), statusId: z.int(),