diff --git a/src/api/config.ts b/src/api/config.ts index 5397f6e..f6c2d45 100644 --- a/src/api/config.ts +++ b/src/api/config.ts @@ -242,3 +242,7 @@ export const PIPELINE = { salesOfficers: '/api/papi2/sales-officers' } }; + +export const HIDDEN_FORM_FIELDS = [ + 'store_code_3', +]; diff --git a/src/components/cards/CallCard.tsx b/src/components/cards/CallCard.tsx index dbabfdc..be7cf13 100644 --- a/src/components/cards/CallCard.tsx +++ b/src/components/cards/CallCard.tsx @@ -28,7 +28,7 @@ export function CallCard({ row, isDetailView = false }: { row: Record

Distributor Details

- + {distName !== '—' && (
diff --git a/src/components/cards/StoreCard.tsx b/src/components/cards/StoreCard.tsx index 15dce8f..0525276 100644 --- a/src/components/cards/StoreCard.tsx +++ b/src/components/cards/StoreCard.tsx @@ -20,7 +20,7 @@ export function StoreCard({ row, isDetailView = false, onEdit }: { row: Record | null; const phone = formatValue(phoneObj?.phone_with_dial_code || phoneObj?.phone || row.phone || row.mobile || '—'); diff --git a/src/components/dv/CallDetail.tsx b/src/components/dv/CallDetail.tsx index 68c2620..e98758b 100644 --- a/src/components/dv/CallDetail.tsx +++ b/src/components/dv/CallDetail.tsx @@ -53,7 +53,7 @@ export function CallDetail({ setData(r.data || {}); if (onDataLoad) onDataLoad(r.data || {}); - const storeCode = (r.data?.select_store as any)?.store_code || (r.data?.select_store as any)?.code || (r.data as any)?.store_code || (r.data as any)?.store?.store_code; + const storeCode = (r.data?.select_store as any)?.store_code_2 || (r.data?.select_store as any)?.code || (r.data as any)?.store_code || (r.data as any)?.store?.store_code; if (storeCode) { orderBookingClient.request<{ potential: { potential: any[] } }>( 'POST', @@ -98,7 +98,7 @@ export function CallDetail({ // Extract store info with fallbacks matching reference const selectStore = (rowSrc.select_store || data?.select_store || {}) as Record; const storeName = selectStore.business_name || selectStore.store_name || rowSrc.store_name || 'No data'; - const storeCode = selectStore.store_code || selectStore.code || 'No data'; + const storeCode = selectStore.store_code_2 || selectStore.code || 'No data'; const ownerName = selectStore.owner_name || selectStore.contact_person || 'No data'; const phone = selectStore.phone_number?.phone || selectStore.phone_number?.phone_with_dial_code || selectStore.phone || 'No data'; const email = selectStore.email || 'No data'; @@ -550,17 +550,17 @@ export function CallDetail({ })}
- Total Order -
-
- Bags - {totalBags} -
-
- Total Kgs - {totalKgs.toLocaleString()} -
-
+ Total Order +
+
+ Bags + {totalBags} +
+
+ Total Kgs + {totalKgs.toLocaleString()} +
+
) : ( @@ -611,7 +611,7 @@ export function CallDetail({
{item.name}
- +
Potential diff --git a/src/components/dv/DailyLogDetail.tsx b/src/components/dv/DailyLogDetail.tsx index 8fcee04..d84dcd8 100644 --- a/src/components/dv/DailyLogDetail.tsx +++ b/src/components/dv/DailyLogDetail.tsx @@ -10,10 +10,11 @@ import { NearestStoresMap } from '../maps/NearestStoresMap'; export interface DailyLogDetailProps extends WiredDetailViewProps { onBack?: () => void; + refreshKey?: number; } -export function DailyLogDetail({ instanceId, onBack }: DailyLogDetailProps) { - const { data, loading, error } = useDetailViewData(dailyReportsClient, DAILY_REPORTS.detailViews.DAILY_LOGS, instanceId); +export function DailyLogDetail({ instanceId, onBack, refreshKey }: DailyLogDetailProps) { + const { data, loading, error } = useDetailViewData(dailyReportsClient, DAILY_REPORTS.detailViews.DAILY_LOGS, instanceId, refreshKey); if (error) { return ( diff --git a/src/components/dv/OrderDetail.tsx b/src/components/dv/OrderDetail.tsx index e20b4a4..a4d011c 100644 --- a/src/components/dv/OrderDetail.tsx +++ b/src/components/dv/OrderDetail.tsx @@ -11,9 +11,10 @@ export interface WiredDetailViewProps { columns?: 1 | 2 | 3; onDataLoad?: (data: Record) => void; onBack?: () => void; + refreshKey?: number; } -export function OrderDetail({ instanceId, onDataLoad, onBack }: WiredDetailViewProps) { +export function OrderDetail({ instanceId, onDataLoad, onBack, refreshKey }: WiredDetailViewProps) { const [data, setData] = useState | null>(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); @@ -37,7 +38,7 @@ export function OrderDetail({ instanceId, onDataLoad, onBack }: WiredDetailViewP } run(); return () => { live = false; }; - }, [instanceId]); + }, [instanceId, refreshKey]); if (error) { return ( diff --git a/src/components/dv/StoreDetail.tsx b/src/components/dv/StoreDetail.tsx index 1341591..b2b4444 100644 --- a/src/components/dv/StoreDetail.tsx +++ b/src/components/dv/StoreDetail.tsx @@ -11,9 +11,10 @@ export interface StoreDetailProps { instanceId: string | number; onBack?: () => void; onEdit?: () => void; + refreshKey?: number; } -export function StoreDetail({ instanceId, onBack, onEdit }: StoreDetailProps) { +export function StoreDetail({ instanceId, onBack, onEdit, refreshKey }: StoreDetailProps) { const [data, setData] = useState | null>(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); @@ -34,7 +35,7 @@ export function StoreDetail({ instanceId, onBack, onEdit }: StoreDetailProps) { } run(); return () => { live = false; }; - }, [instanceId]); + }, [instanceId, refreshKey]); if (error) { return ( @@ -77,7 +78,7 @@ export function StoreDetail({ instanceId, onBack, onEdit }: StoreDetailProps) { const badgeClass = isSuccess ? 'bg-emerald-100 text-emerald-700' : 'bg-blue-100 text-blue-700'; // Store Overview - const storeCode = extract('store_code', remainingData) || '-'; + const storeCode = extract('store_code_2', remainingData) || '-'; const businessName = extract('business_name', remainingData) || '-'; const area = extract('area', remainingData); const completeAddress = extract('complete_address', remainingData); diff --git a/src/components/dv/useDetailViewData.ts b/src/components/dv/useDetailViewData.ts index 711f3ba..ab71301 100644 --- a/src/components/dv/useDetailViewData.ts +++ b/src/components/dv/useDetailViewData.ts @@ -1,7 +1,7 @@ import { useState, useEffect } from 'react'; import type { ZinoClient } from '../../api/client'; -export function useDetailViewData(client: ZinoClient, dvUid: string | undefined, instanceId: string | number) { +export function useDetailViewData(client: ZinoClient, dvUid: string | undefined, instanceId: string | number, refreshKey?: number) { const [data, setData] = useState | null>(null); const [config, setConfig] = useState(null); const [loading, setLoading] = useState(true); @@ -29,7 +29,7 @@ export function useDetailViewData(client: ZinoClient, dvUid: string | undefined, return () => { live = false; }; - }, [client, dvUid, instanceId]); + }, [client, dvUid, instanceId, refreshKey]); return { data, config, loading, error }; } diff --git a/src/components/forms/DynamicForm.tsx b/src/components/forms/DynamicForm.tsx index c2313d6..dcdd8e0 100644 --- a/src/components/forms/DynamicForm.tsx +++ b/src/components/forms/DynamicForm.tsx @@ -17,7 +17,7 @@ import { WfLookupField, RadioField, } from './fields'; -import { ORDER_BOOKING, STORE, DAILY_REPORTS } from '../../api/config'; +import { ORDER_BOOKING, STORE, DAILY_REPORTS, HIDDEN_FORM_FIELDS } from '../../api/config'; export interface DynamicFormProps { client: ZinoClient; @@ -80,9 +80,9 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: const mapPrefillData = (sourceData: Record) => { res.fields.forEach(f => { if (imageFieldIds.has(f.id)) return; - + const getBaseId = (id: string) => id.replace(/_\d+$/, ''); - + if (sourceData[f.id] !== undefined) { defaultValues[f.id] = sourceData[f.id]; } else if (f.mapped_workflow_field && sourceData[f.mapped_workflow_field] !== undefined) { @@ -145,7 +145,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: const userEmail = user?.email; if (userEmail) { try { - const headers: Record = { + const headers: Record = { 'templateid': '192', 'x-pipeline-version': 'draft' }; @@ -162,7 +162,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: if (Array.isArray(summaryData)) { summaryData = summaryData[0] || {}; } - + // Map the API response keys to match the form field keys if (summaryData.productive_call !== undefined) { summaryData.total_productive_calls = summaryData.productive_call; @@ -170,7 +170,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: if (summaryData.non_productive_call !== undefined) { summaryData.total_non_productive_calls = summaryData.non_productive_call; } - + mapPrefillData(summaryData); } catch (e) { console.warn('Failed to load productive call summary', e); @@ -196,13 +196,14 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: const [values, setValues] = useState>({}); const [submitting, setSubmitting] = useState(false); const [submitError, setSubmitError] = useState(null); - + const clickedActionRef = useRef(null); + const hasSubmittedRef = useRef(false); const handleFieldChange = (fieldId: string, newVal: unknown, rawRow?: any) => { setValues(prev => { const next = { ...prev, [fieldId]: newVal }; - + const getBaseIdForField = (id: string) => id.replace(/_\d+$/, ''); const fieldDef = schema?.fields.find(f => f.id === fieldId); @@ -210,10 +211,10 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: const getBaseId = (id: string) => id.replace(/_\d+$/, ''); for (const key of Object.keys(rawRow)) { const lowerKey = key.toLowerCase(); - let targetCol = schema?.fields.find(c => - c.id.toLowerCase() === lowerKey || - (c.mapped_workflow_field || '').toLowerCase() === lowerKey || - getBaseId(c.id).toLowerCase() === lowerKey || + let targetCol = schema?.fields.find(c => + c.id.toLowerCase() === lowerKey || + (c.mapped_workflow_field || '').toLowerCase() === lowerKey || + getBaseId(c.id).toLowerCase() === lowerKey || c.name.toLowerCase().replace(/\s+/g, '') === lowerKey.replace(/_/g, '') ); if (targetCol && targetCol.id !== fieldId) { @@ -237,10 +238,10 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: for (const key of Object.keys(rawData)) { const lowerKey = key.toLowerCase(); - let targetCol = schema?.fields.find(c => - c.id.toLowerCase() === lowerKey || - (c.mapped_workflow_field || '').toLowerCase() === lowerKey || - getBaseId(c.id).toLowerCase() === lowerKey || + let targetCol = schema?.fields.find(c => + c.id.toLowerCase() === lowerKey || + (c.mapped_workflow_field || '').toLowerCase() === lowerKey || + getBaseId(c.id).toLowerCase() === lowerKey || c.name.toLowerCase().replace(/\s+/g, '') === lowerKey.replace(/_/g, '') ); @@ -250,32 +251,32 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: targetCol = undefined; } } - + if (!targetCol && (fieldId === 'route_name_2' || fieldId.startsWith('route_name'))) { targetCol = schema?.fields.find(c => { const mappedName = (c.mapped_workflow_field || '').toLowerCase(); const nameFallback = (c.name || '').toLowerCase().replace(/\s+/g, '_'); const fieldName = mappedName || nameFallback; - - return fieldName === `distributor_${lowerKey}` || - (lowerKey === 'phone' && fieldName === 'distributor_phone_number') || - (lowerKey === 'email' && fieldName === 'distributor_email'); + + return fieldName === `distributor_${lowerKey}` || + (lowerKey === 'phone' && fieldName === 'distributor_phone_number') || + (lowerKey === 'email' && fieldName === 'distributor_email'); }); } if (!targetCol) { const pKey = prefix + lowerKey; - targetCol = schema?.fields.find(c => - c.id.toLowerCase() === pKey || - (c.mapped_workflow_field || '').toLowerCase() === pKey || - getBaseId(c.id).toLowerCase() === pKey || + targetCol = schema?.fields.find(c => + c.id.toLowerCase() === pKey || + (c.mapped_workflow_field || '').toLowerCase() === pKey || + getBaseId(c.id).toLowerCase() === pKey || c.name.toLowerCase().replace(/\s+/g, '') === pKey.replace(/_/g, '') ); } - + if (targetCol && targetCol.id !== fieldId) { let fillVal = rawData[key]; - + if ((targetCol.data_type === 'select' || targetCol.data_type === 'multiselect') && targetCol.properties?.options) { const matchedOpt = targetCol.properties.options.find( (o: any) => String(o.value).toLowerCase() === String(fillVal).toLowerCase() @@ -304,12 +305,12 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: let totalKgs = 0; const getBaseId = (id: string) => id.replace(/_\d+$/, ''); - - const bagsColId = fieldDef?.columns?.find(c => + + const bagsColId = fieldDef?.columns?.find(c => c.id === 'bags' || getBaseId(c.id) === 'bags' || c.mapped_workflow_field === 'bags' || c.name.toLowerCase() === 'bags' )?.id || 'bags'; - - const rowKgsColId = fieldDef?.columns?.find(c => + + const rowKgsColId = fieldDef?.columns?.find(c => c.id === 'row_kgs' || getBaseId(c.id) === 'row_kgs' || c.id === 'rowkgs' || getBaseId(c.id) === 'rowkgs' || c.mapped_workflow_field === 'row_kgs' )?.id || 'row_kgs'; @@ -327,7 +328,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: if (tkField) next[tkField.id] = totalKgs; else next['total_kgs'] = totalKgs; } - + return next; }); }; @@ -340,7 +341,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: } // Filter out disabled fields (usually server-generated IDs) - const fields = schema.fields.filter(f => !f.properties?.disabled); + const fields = schema.fields.filter(f => !f.properties?.disabled && !HIDDEN_FORM_FIELDS.includes(f.id)); const actionField = fields.find(f => f.name.toLowerCase() === 'action' && f.data_type === 'radio'); const normalFields = fields.filter(f => f !== actionField); @@ -357,7 +358,12 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: } for (const f of fields) { - const val = finalValues[f.id]; + let val = finalValues[f.id]; + const isNotesOrRemarks = f.id.toLowerCase().includes('notes') || f.id.toLowerCase().includes('remarks') || (f.name && (f.name.toLowerCase().includes('notes') || f.name.toLowerCase().includes('remarks'))); + if (isNotesOrRemarks && val == null) { + val = ''; + } + if (val == null) continue; if (f.data_type === 'phone' && typeof val === 'string') { @@ -388,7 +394,8 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: } else { res = await client.startInstance(currentActivityId, payload); } - + + hasSubmittedRef.current = true; let pending = [...chainQueue]; let chainSource = (res as any).activity_chain || schema.activity_chain || []; @@ -409,7 +416,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: // Remove any existing occurrences from pending to avoid duplicates pending = pending.filter(p => !newActivities.some((n: any) => n.activity_uid === p.activity_uid)); - + // Prepend the new activities for depth-first execution (nested chaining) pending = [...newActivities, ...pending]; @@ -418,21 +425,21 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: if (nextActivity) { let nextPrefillData = undefined; if (nextActivity.activity_uid === ORDER_BOOKING.activities.POTENTIAL_MINING.uid) { - let storeCodeToSend = String((values['select_store_row'] as any)?.store_code || (chainedPrefillData?.['select_store_row'] as any)?.store_code || ''); - + let storeCodeToSend = String((values['select_store_row'] as any)?.store_code_2 || (chainedPrefillData?.['select_store_row'] as any)?.store_code_2 || ''); + if (!storeCodeToSend) { let storeId = values['select_store'] || chainedPrefillData?.['select_store'] || (schema?.prefill_data as any)?.select_store || (schema?.data as any)?.select_store; if (typeof storeId === 'object' && storeId !== null) { - storeCodeToSend = (storeId as any).store_code || storeCodeToSend; + storeCodeToSend = (storeId as any).store_code_2 || storeCodeToSend; storeId = (storeId as any).value || (storeId as any).instance_id || String(storeId); } if (!storeCodeToSend && storeId) { try { const detailRes = await client.detailView(STORE.detailViews.STORE, storeId); - if (detailRes.data && detailRes.data.store_code) { - storeCodeToSend = String(detailRes.data.store_code); + if (detailRes.data && (detailRes.data.store_code_2 || detailRes.data.store_code)) { + storeCodeToSend = String(detailRes.data.store_code_2 || detailRes.data.store_code); } - } catch(e) { + } catch (e) { try { const lookupRes = await client.wfLookupRecords({ activityId: ORDER_BOOKING.activities.LOG_VISIT.uid, @@ -442,8 +449,8 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: }); const arr = Array.isArray(lookupRes) ? lookupRes : (lookupRes.data || lookupRes.records || []); const row = arr.find((r: any) => String(r.instance_id || r.id) === String(storeId)); - if (row && row.store_code) { - storeCodeToSend = String(row.store_code); + if (row && (row.store_code_2 || row.store_code)) { + storeCodeToSend = String(row.store_code_2 || row.store_code); } } catch (err) { console.error("Failed to fetch store code:", err); @@ -451,7 +458,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: } } } - + if (!storeCodeToSend) { storeCodeToSend = String(values['select_store'] || chainedPrefillData?.['select_store'] || (schema?.prefill_data as any)?.select_store || ''); } @@ -460,7 +467,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: const pmRes = await client.request<{ potential: { potential: any[] } }>( 'POST', '/api/papi2/potential-mining', - { + { instance_id: String(res.instance_id ?? currentInstanceId), store_code: storeCodeToSend }, @@ -483,7 +490,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: console.error("Failed to fetch potential mining for chain", e); } } - + setChainedPrefillData(prev => ({ ...prev, ...values, @@ -510,7 +517,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: const type = f.data_type; const val = values[f.id]; const isDisabled = schema.field_defaults?.[f.id]?.disabled || f.properties?.disabled; - + const isPlaceOrder = currentActivityId === ORDER_BOOKING.activities.PLACE_ORDER.uid; const isOrderId = f.name.toLowerCase() === 'order id' || f.id.toLowerCase().includes('order_id') || f.mapped_workflow_field === 'order_id'; @@ -518,7 +525,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: return null; } - + const renderField = () => { if (type === 'wf_lookup') { return ( @@ -660,7 +667,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: required={f.mandatory} type="text" value={(displayVal as string) ?? ''} - onChange={() => {}} + onChange={() => { }} disabled /> ); @@ -693,7 +700,10 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
{onCancel && ( - )} diff --git a/src/components/forms/LogVisitForm.tsx b/src/components/forms/LogVisitForm.tsx index 1c55d2f..a9d0bce 100644 --- a/src/components/forms/LogVisitForm.tsx +++ b/src/components/forms/LogVisitForm.tsx @@ -1,7 +1,7 @@ import { useState, useEffect, useCallback, useRef } from 'react'; import type { ZinoClient } from '../../api/client'; import type { FormScreenResponse } from '../../api/types'; -import { ORDER_BOOKING } from '../../api/config'; +import { ORDER_BOOKING, HIDDEN_FORM_FIELDS } from '../../api/config'; import { Button } from '../buttons/Button'; import { Select } from '../reusable/Select'; import { DateField, TimeField, FileInput, TextField } from './fields'; @@ -308,7 +308,12 @@ export function LogVisitForm({ client, onSuccess, onCancel, onActivityChange }: const payload: Record = {}; validFieldIds.forEach(fieldId => { const val = valuesRef.current[fieldId]; - if (val !== undefined && val !== null && val !== '') { + const fieldDef = validFields.find(f => f.id === fieldId); + const isNotesOrRemarks = fieldId.toLowerCase().includes('notes') || fieldId.toLowerCase().includes('remarks') || (fieldDef?.name && (fieldDef.name.toLowerCase().includes('notes') || fieldDef.name.toLowerCase().includes('remarks'))); + + if (isNotesOrRemarks && (val == null || val === '')) { + payload[fieldId] = ''; + } else if (val !== undefined && val !== null && val !== '') { payload[fieldId] = val; } }); @@ -365,7 +370,7 @@ export function LogVisitForm({ client, onSuccess, onCancel, onActivityChange }: instanceId={chainedActivity.instanceId} customPrefillData={chainedActivity.prefillData} onSuccess={onSuccess} - onCancel={onCancel} + onCancel={onSuccess} onActivityChange={onActivityChange} /> ); @@ -388,7 +393,7 @@ export function LogVisitForm({ client, onSuccess, onCancel, onActivityChange }: const lowerId = fieldId.toLowerCase(); const lowerName = f.name.toLowerCase(); - const isHidden = schema?.field_defaults?.[fieldId]?.hidden === true || (f.properties as any)?.hidden === true; + const isHidden = schema?.field_defaults?.[fieldId]?.hidden === true || (f.properties as any)?.hidden === true || HIDDEN_FORM_FIELDS.includes(fieldId); // Skip daily_log and route_code (or hidden fields) from visual rendering if ( diff --git a/src/components/forms/fields/SmartGridField.tsx b/src/components/forms/fields/SmartGridField.tsx index eb39499..7b3ed12 100644 --- a/src/components/forms/fields/SmartGridField.tsx +++ b/src/components/forms/fields/SmartGridField.tsx @@ -403,7 +403,7 @@ export function SmartGridField({ editingIdx === null ? 'grid-rows-[1fr] opacity-100 mt-4' : 'grid-rows-[0fr] opacity-0 mt-0 hidden' }`} > -
+

Add New Item diff --git a/src/components/reusable/AnalyticsChart.tsx b/src/components/reusable/AnalyticsChart.tsx index e21d8ed..df4920e 100644 --- a/src/components/reusable/AnalyticsChart.tsx +++ b/src/components/reusable/AnalyticsChart.tsx @@ -49,7 +49,7 @@ export function AnalyticsChart({ data }: AnalyticsChartProps) {
- + @@ -62,7 +62,10 @@ export function AnalyticsChart({ data }: AnalyticsChartProps) { axisLine={false} tickLine={false} tick={{ fontSize: 12, fill: '#64748B' }} + angle={-45} + textAnchor="end" dy={10} + height={60} /> - {instanceId != null && } + {instanceId != null && } ); diff --git a/src/screens/CallsPage.tsx b/src/screens/CallsPage.tsx index fc58421..51b1236 100644 --- a/src/screens/CallsPage.tsx +++ b/src/screens/CallsPage.tsx @@ -27,7 +27,7 @@ export function CallsPage() { setMiningLoading(true); setMiningPrefill(undefined); try { - const storeCode = selectedRow?.store_code || selectedRow?.code || selectedRow?.store?.store_code || selectedRow?.select_store?.store_code || selectedRow?.select_store?.code; + const storeCode = selectedRow?.select_store?.store_code_2 || selectedRow?.select_store?.store_code || selectedRow?.select_store?.code || selectedRow?.store_code_2 || selectedRow?.store_code || selectedRow?.code || selectedRow?.store?.store_code_2 || selectedRow?.store?.store_code; if (!storeCode) { console.warn("Store code not found on selected row, proceeding anyway."); @@ -72,7 +72,7 @@ export function CallsPage() { return (
- { navigate(`/calls`); setIsFabOpen(false); }} /> + { navigate(`/calls`); setIsFabOpen(false); }} />
@@ -105,6 +105,17 @@ export function CallsPage() { Place Order ); + } else if (stateName === 'visited') { + return ( + + ); } else if (stateName.includes('no order') || stateName.includes('non-productive') || stateName.includes('non productive')) { return null; } diff --git a/src/screens/DailyLogsPage.tsx b/src/screens/DailyLogsPage.tsx index 3a9e38b..c629b98 100644 --- a/src/screens/DailyLogsPage.tsx +++ b/src/screens/DailyLogsPage.tsx @@ -24,7 +24,7 @@ export function DailyLogsPage() { return (
- navigate(`/daily`)} /> + navigate(`/daily`)} />
); diff --git a/src/screens/OrdersPage.tsx b/src/screens/OrdersPage.tsx index 6fbbd3f..9299895 100644 --- a/src/screens/OrdersPage.tsx +++ b/src/screens/OrdersPage.tsx @@ -29,7 +29,7 @@ export function OrdersPage() { setMiningLoading(true); setMiningPrefill(undefined); try { - const storeCode = selectedRow?.store_code || selectedRow?.code || selectedRow?.store?.store_code || selectedRow?.select_store?.store_code || selectedRow?.select_store?.code; + const storeCode = selectedRow?.select_store?.store_code_2 || selectedRow?.select_store?.store_code || selectedRow?.select_store?.code || selectedRow?.store_code_2 || selectedRow?.store_code || selectedRow?.code || selectedRow?.store?.store_code_2 || selectedRow?.store?.store_code; if (!storeCode) { console.warn("Store code not found on selected row, proceeding anyway."); @@ -74,7 +74,7 @@ export function OrdersPage() { return (
- { navigate(`/orders`); setIsFabOpen(false); }} /> + { navigate(`/orders`); setIsFabOpen(false); }} />
@@ -107,6 +107,17 @@ export function OrdersPage() { Place Order ); + } else if (stateName === 'visited') { + return ( + + ); } else if (stateName.includes('no order') || stateName.includes('non-productive') || stateName.includes('non productive')) { return null; } diff --git a/src/screens/StoresPage.tsx b/src/screens/StoresPage.tsx index 5bf954a..cc89682 100644 --- a/src/screens/StoresPage.tsx +++ b/src/screens/StoresPage.tsx @@ -23,7 +23,7 @@ export function StoresPage() { return (
- navigate(`/stores`)} /> + navigate(`/stores`)} />
{/* Edit store modal can still open over the detail view if needed */}