From 819b43bd77cfb4885e9c96372a43fb3715ba1e30 Mon Sep 17 00:00:00 2001 From: suryac Date: Tue, 18 Aug 2026 11:46:13 +0530 Subject: [PATCH] fix: limit for select and made it as constant --- src/api/config.ts | 3 +++ src/components/forms/LogVisitForm.tsx | 6 +++--- src/components/forms/fields/WfLookupField.tsx | 3 ++- src/screens/DailySalesReportPage.tsx | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/api/config.ts b/src/api/config.ts index aff1339..7aaebf2 100644 --- a/src/api/config.ts +++ b/src/api/config.ts @@ -270,3 +270,6 @@ export const PIPELINE = { export const HIDDEN_FORM_FIELDS = [ 'store_code_3' ]; + +export const LOOKUP_RECORD_LIMIT = 500; +export const MAX_SKUS_PER_CHUNK = 20; diff --git a/src/components/forms/LogVisitForm.tsx b/src/components/forms/LogVisitForm.tsx index c6a9f91..022c64e 100644 --- a/src/components/forms/LogVisitForm.tsx +++ b/src/components/forms/LogVisitForm.tsx @@ -1,7 +1,7 @@ import React, { useState, useEffect, useCallback, useRef } from 'react'; import type { ZinoClient } from '../../api/client'; import type { FormScreenResponse } from '../../api/types'; -import { ORDER_BOOKING, PIPELINE } from '../../api/config'; +import { ORDER_BOOKING, PIPELINE, LOOKUP_RECORD_LIMIT } from '../../api/config'; import { Button } from '../buttons/Button'; import { Select } from '../reusable/Select'; import { DateField, TimeField, FileInput, TextField } from './fields'; @@ -184,7 +184,7 @@ export function LogVisitForm({ client, onSuccess, onCancel, onActivityChange }: activityId, fieldId: 'select_store', formData: formDataToSend, - limit: 400, + limit: LOOKUP_RECORD_LIMIT, }); const arr = Array.isArray(lookupRes) @@ -253,7 +253,7 @@ export function LogVisitForm({ client, onSuccess, onCancel, onActivityChange }: activityId, fieldId: 'daily_log', formData: payload, - limit: 400, + limit: LOOKUP_RECORD_LIMIT, }); const arr = Array.isArray(dailyLogLookupRes) diff --git a/src/components/forms/fields/WfLookupField.tsx b/src/components/forms/fields/WfLookupField.tsx index b215559..0aa3eda 100644 --- a/src/components/forms/fields/WfLookupField.tsx +++ b/src/components/forms/fields/WfLookupField.tsx @@ -1,5 +1,6 @@ import { useState, useEffect } from 'react'; import type { ZinoClient } from '../../../api/client'; +import { LOOKUP_RECORD_LIMIT } from '../../../api/config'; import { SelectField } from './SelectField'; export interface WfLookupFieldProps { @@ -31,7 +32,7 @@ export function WfLookupField({ label, required, value, onChange, client, config activityId, fieldId, formData: JSON.parse(formDataStr), - limit: 400 + limit: LOOKUP_RECORD_LIMIT }) .then(res => { if (!mounted) return; diff --git a/src/screens/DailySalesReportPage.tsx b/src/screens/DailySalesReportPage.tsx index 7e6d6a7..6459021 100644 --- a/src/screens/DailySalesReportPage.tsx +++ b/src/screens/DailySalesReportPage.tsx @@ -5,7 +5,8 @@ import { SALES_REPORT_ROUTES, ROUTE_WISE_DISTRIBUTORS, BASE_URL, - PIPELINE + PIPELINE, + MAX_SKUS_PER_CHUNK } from '../api/config'; import { Download, Printer } from 'lucide-react'; import jsPDF from 'jspdf'; @@ -93,7 +94,6 @@ export function DailySalesReportPage() { }; // Split headers into chunks of exactly MAX_SKUS_PER_CHUNK, even if it means splitting a brand. - const MAX_SKUS_PER_CHUNK = 20; const headerChunks: any[][] = []; let currentChunk: any[] = []; let currentSkuCount = 0;