storecode fix
This commit is contained in:
parent
d3765ceaf8
commit
810e4997ae
@ -242,3 +242,7 @@ export const PIPELINE = {
|
|||||||
salesOfficers: '/api/papi2/sales-officers'
|
salesOfficers: '/api/papi2/sales-officers'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const HIDDEN_FORM_FIELDS = [
|
||||||
|
'store_code_3',
|
||||||
|
];
|
||||||
|
|||||||
@ -28,7 +28,7 @@ export function CallCard({ row, isDetailView = false }: { row: Record<string, an
|
|||||||
|
|
||||||
|
|
||||||
const storeName = formatValue(storeObj?.business_name || storeObj?.distributor_name || row.store_name || row.customer_name || (typeof row.store === 'string' ? row.store : 'Unknown Store'));
|
const storeName = formatValue(storeObj?.business_name || storeObj?.distributor_name || row.store_name || row.customer_name || (typeof row.store === 'string' ? row.store : 'Unknown Store'));
|
||||||
const storeCode = formatValue(storeObj?.store_code || row.store_code || '—');
|
const storeCode = formatValue(storeObj?.store_code_2 || row.store_code_2 || '—');
|
||||||
|
|
||||||
// Phone and Email
|
// Phone and Email
|
||||||
const storeEmail = formatValue(storeObj?.email || row.email || row.store_email || '—');
|
const storeEmail = formatValue(storeObj?.email || row.email || row.store_email || '—');
|
||||||
@ -274,7 +274,7 @@ export function CallCard({ row, isDetailView = false }: { row: Record<string, an
|
|||||||
{hasDistributor && (
|
{hasDistributor && (
|
||||||
<div className="mt-6 border-t border-gray-100 pt-6">
|
<div className="mt-6 border-t border-gray-100 pt-6">
|
||||||
<p className="z-card-meta mb-3 text-slate-700 font-bold">Distributor Details</p>
|
<p className="z-card-meta mb-3 text-slate-700 font-bold">Distributor Details</p>
|
||||||
|
|
||||||
{distName !== '—' && (
|
{distName !== '—' && (
|
||||||
<div className="z-card-store-row" style={{ marginBottom: '12px' }}>
|
<div className="z-card-store-row" style={{ marginBottom: '12px' }}>
|
||||||
<Truck size={18} className="z-card-store-icon" />
|
<Truck size={18} className="z-card-store-icon" />
|
||||||
|
|||||||
@ -20,7 +20,7 @@ export function StoreCard({ row, isDetailView = false, onEdit }: { row: Record<s
|
|||||||
|
|
||||||
// Store Details
|
// Store Details
|
||||||
const storeName = formatValue(row.business_name || row.store_name || row.name || 'Unknown Store');
|
const storeName = formatValue(row.business_name || row.store_name || row.name || 'Unknown Store');
|
||||||
const storeCode = formatValue(row.store_code || row.code || '—');
|
const storeCode = formatValue(row.store_code_2 || row.code || '—');
|
||||||
const ownerName = formatValue(row.owner_name || row.contact_person || '—');
|
const ownerName = formatValue(row.owner_name || row.contact_person || '—');
|
||||||
const phoneObj = row.phone_number as Record<string, unknown> | null;
|
const phoneObj = row.phone_number as Record<string, unknown> | null;
|
||||||
const phone = formatValue(phoneObj?.phone_with_dial_code || phoneObj?.phone || row.phone || row.mobile || '—');
|
const phone = formatValue(phoneObj?.phone_with_dial_code || phoneObj?.phone || row.phone || row.mobile || '—');
|
||||||
|
|||||||
@ -53,7 +53,7 @@ export function CallDetail({
|
|||||||
setData(r.data || {});
|
setData(r.data || {});
|
||||||
if (onDataLoad) onDataLoad(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) {
|
if (storeCode) {
|
||||||
orderBookingClient.request<{ potential: { potential: any[] } }>(
|
orderBookingClient.request<{ potential: { potential: any[] } }>(
|
||||||
'POST',
|
'POST',
|
||||||
@ -98,7 +98,7 @@ export function CallDetail({
|
|||||||
// Extract store info with fallbacks matching reference
|
// Extract store info with fallbacks matching reference
|
||||||
const selectStore = (rowSrc.select_store || data?.select_store || {}) as Record<string, any>;
|
const selectStore = (rowSrc.select_store || data?.select_store || {}) as Record<string, any>;
|
||||||
const storeName = selectStore.business_name || selectStore.store_name || rowSrc.store_name || 'No data';
|
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 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 phone = selectStore.phone_number?.phone || selectStore.phone_number?.phone_with_dial_code || selectStore.phone || 'No data';
|
||||||
const email = selectStore.email || 'No data';
|
const email = selectStore.email || 'No data';
|
||||||
@ -550,17 +550,17 @@ export function CallDetail({
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-2 rounded-xl p-4 flex items-center justify-between shadow-sm bg-primary text-white">
|
<div className="mt-2 rounded-xl p-4 flex items-center justify-between shadow-sm bg-primary text-white">
|
||||||
<span className="text-xs font-bold uppercase tracking-wider opacity-90">Total Order</span>
|
<span className="text-xs font-bold uppercase tracking-wider opacity-90">Total Order</span>
|
||||||
<div className="flex items-center gap-6">
|
<div className="flex items-center gap-6">
|
||||||
<div className="flex flex-col items-end">
|
<div className="flex flex-col items-end">
|
||||||
<span className="text-[10px] font-medium uppercase opacity-80">Bags</span>
|
<span className="text-[10px] font-medium uppercase opacity-80">Bags</span>
|
||||||
<span className="text-lg font-black">{totalBags}</span>
|
<span className="text-lg font-black">{totalBags}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col items-end">
|
<div className="flex flex-col items-end">
|
||||||
<span className="text-[10px] font-medium uppercase opacity-80">Total Kgs</span>
|
<span className="text-[10px] font-medium uppercase opacity-80">Total Kgs</span>
|
||||||
<span className="text-lg font-black text-emerald-300">{totalKgs.toLocaleString()}</span>
|
<span className="text-lg font-black text-emerald-300">{totalKgs.toLocaleString()}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
@ -611,7 +611,7 @@ export function CallDetail({
|
|||||||
<div className="flex justify-between items-center">
|
<div className="flex justify-between items-center">
|
||||||
<span className="text-primary font-bold text-[13px] uppercase tracking-wide">{item.name}</span>
|
<span className="text-primary font-bold text-[13px] uppercase tracking-wide">{item.name}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-between items-center bg-white rounded-lg py-1.5 px-3 border border-primary-light-border mt-0.5">
|
<div className="flex justify-between items-center bg-white rounded-lg py-1.5 px-3 border border-primary-light-border mt-0.5">
|
||||||
<div className="flex flex-col gap-0.5">
|
<div className="flex flex-col gap-0.5">
|
||||||
<span className="text-[10px] font-bold text-primary uppercase tracking-wider">Potential</span>
|
<span className="text-[10px] font-bold text-primary uppercase tracking-wider">Potential</span>
|
||||||
|
|||||||
@ -10,10 +10,11 @@ import { NearestStoresMap } from '../maps/NearestStoresMap';
|
|||||||
|
|
||||||
export interface DailyLogDetailProps extends WiredDetailViewProps {
|
export interface DailyLogDetailProps extends WiredDetailViewProps {
|
||||||
onBack?: () => void;
|
onBack?: () => void;
|
||||||
|
refreshKey?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DailyLogDetail({ instanceId, onBack }: DailyLogDetailProps) {
|
export function DailyLogDetail({ instanceId, onBack, refreshKey }: DailyLogDetailProps) {
|
||||||
const { data, loading, error } = useDetailViewData(dailyReportsClient, DAILY_REPORTS.detailViews.DAILY_LOGS, instanceId);
|
const { data, loading, error } = useDetailViewData(dailyReportsClient, DAILY_REPORTS.detailViews.DAILY_LOGS, instanceId, refreshKey);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -11,9 +11,10 @@ export interface WiredDetailViewProps {
|
|||||||
columns?: 1 | 2 | 3;
|
columns?: 1 | 2 | 3;
|
||||||
onDataLoad?: (data: Record<string, unknown>) => void;
|
onDataLoad?: (data: Record<string, unknown>) => void;
|
||||||
onBack?: () => void;
|
onBack?: () => void;
|
||||||
|
refreshKey?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function OrderDetail({ instanceId, onDataLoad, onBack }: WiredDetailViewProps) {
|
export function OrderDetail({ instanceId, onDataLoad, onBack, refreshKey }: WiredDetailViewProps) {
|
||||||
const [data, setData] = useState<Record<string, unknown> | null>(null);
|
const [data, setData] = useState<Record<string, unknown> | null>(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
@ -37,7 +38,7 @@ export function OrderDetail({ instanceId, onDataLoad, onBack }: WiredDetailViewP
|
|||||||
}
|
}
|
||||||
run();
|
run();
|
||||||
return () => { live = false; };
|
return () => { live = false; };
|
||||||
}, [instanceId]);
|
}, [instanceId, refreshKey]);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -11,9 +11,10 @@ export interface StoreDetailProps {
|
|||||||
instanceId: string | number;
|
instanceId: string | number;
|
||||||
onBack?: () => void;
|
onBack?: () => void;
|
||||||
onEdit?: () => void;
|
onEdit?: () => void;
|
||||||
|
refreshKey?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function StoreDetail({ instanceId, onBack, onEdit }: StoreDetailProps) {
|
export function StoreDetail({ instanceId, onBack, onEdit, refreshKey }: StoreDetailProps) {
|
||||||
const [data, setData] = useState<Record<string, unknown> | null>(null);
|
const [data, setData] = useState<Record<string, unknown> | null>(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
@ -34,7 +35,7 @@ export function StoreDetail({ instanceId, onBack, onEdit }: StoreDetailProps) {
|
|||||||
}
|
}
|
||||||
run();
|
run();
|
||||||
return () => { live = false; };
|
return () => { live = false; };
|
||||||
}, [instanceId]);
|
}, [instanceId, refreshKey]);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return (
|
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';
|
const badgeClass = isSuccess ? 'bg-emerald-100 text-emerald-700' : 'bg-blue-100 text-blue-700';
|
||||||
|
|
||||||
// Store Overview
|
// Store Overview
|
||||||
const storeCode = extract('store_code', remainingData) || '-';
|
const storeCode = extract('store_code_2', remainingData) || '-';
|
||||||
const businessName = extract('business_name', remainingData) || '-';
|
const businessName = extract('business_name', remainingData) || '-';
|
||||||
const area = extract('area', remainingData);
|
const area = extract('area', remainingData);
|
||||||
const completeAddress = extract('complete_address', remainingData);
|
const completeAddress = extract('complete_address', remainingData);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import type { ZinoClient } from '../../api/client';
|
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<Record<string, any> | null>(null);
|
const [data, setData] = useState<Record<string, any> | null>(null);
|
||||||
const [config, setConfig] = useState<any>(null);
|
const [config, setConfig] = useState<any>(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
@ -29,7 +29,7 @@ export function useDetailViewData(client: ZinoClient, dvUid: string | undefined,
|
|||||||
return () => {
|
return () => {
|
||||||
live = false;
|
live = false;
|
||||||
};
|
};
|
||||||
}, [client, dvUid, instanceId]);
|
}, [client, dvUid, instanceId, refreshKey]);
|
||||||
|
|
||||||
return { data, config, loading, error };
|
return { data, config, loading, error };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import {
|
|||||||
WfLookupField,
|
WfLookupField,
|
||||||
RadioField,
|
RadioField,
|
||||||
} from './fields';
|
} 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 {
|
export interface DynamicFormProps {
|
||||||
client: ZinoClient;
|
client: ZinoClient;
|
||||||
@ -80,9 +80,9 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
const mapPrefillData = (sourceData: Record<string, unknown>) => {
|
const mapPrefillData = (sourceData: Record<string, unknown>) => {
|
||||||
res.fields.forEach(f => {
|
res.fields.forEach(f => {
|
||||||
if (imageFieldIds.has(f.id)) return;
|
if (imageFieldIds.has(f.id)) return;
|
||||||
|
|
||||||
const getBaseId = (id: string) => id.replace(/_\d+$/, '');
|
const getBaseId = (id: string) => id.replace(/_\d+$/, '');
|
||||||
|
|
||||||
if (sourceData[f.id] !== undefined) {
|
if (sourceData[f.id] !== undefined) {
|
||||||
defaultValues[f.id] = sourceData[f.id];
|
defaultValues[f.id] = sourceData[f.id];
|
||||||
} else if (f.mapped_workflow_field && sourceData[f.mapped_workflow_field] !== undefined) {
|
} 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;
|
const userEmail = user?.email;
|
||||||
if (userEmail) {
|
if (userEmail) {
|
||||||
try {
|
try {
|
||||||
const headers: Record<string, string> = {
|
const headers: Record<string, string> = {
|
||||||
'templateid': '192',
|
'templateid': '192',
|
||||||
'x-pipeline-version': 'draft'
|
'x-pipeline-version': 'draft'
|
||||||
};
|
};
|
||||||
@ -162,7 +162,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
if (Array.isArray(summaryData)) {
|
if (Array.isArray(summaryData)) {
|
||||||
summaryData = summaryData[0] || {};
|
summaryData = summaryData[0] || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map the API response keys to match the form field keys
|
// Map the API response keys to match the form field keys
|
||||||
if (summaryData.productive_call !== undefined) {
|
if (summaryData.productive_call !== undefined) {
|
||||||
summaryData.total_productive_calls = summaryData.productive_call;
|
summaryData.total_productive_calls = summaryData.productive_call;
|
||||||
@ -170,7 +170,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
if (summaryData.non_productive_call !== undefined) {
|
if (summaryData.non_productive_call !== undefined) {
|
||||||
summaryData.total_non_productive_calls = summaryData.non_productive_call;
|
summaryData.total_non_productive_calls = summaryData.non_productive_call;
|
||||||
}
|
}
|
||||||
|
|
||||||
mapPrefillData(summaryData);
|
mapPrefillData(summaryData);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('Failed to load productive call summary', 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<Record<string, unknown>>({});
|
const [values, setValues] = useState<Record<string, unknown>>({});
|
||||||
const [submitting, setSubmitting] = useState(false);
|
const [submitting, setSubmitting] = useState(false);
|
||||||
const [submitError, setSubmitError] = useState<string | null>(null);
|
const [submitError, setSubmitError] = useState<string | null>(null);
|
||||||
|
|
||||||
const clickedActionRef = useRef<string | null>(null);
|
const clickedActionRef = useRef<string | null>(null);
|
||||||
|
const hasSubmittedRef = useRef(false);
|
||||||
|
|
||||||
const handleFieldChange = (fieldId: string, newVal: unknown, rawRow?: any) => {
|
const handleFieldChange = (fieldId: string, newVal: unknown, rawRow?: any) => {
|
||||||
setValues(prev => {
|
setValues(prev => {
|
||||||
const next = { ...prev, [fieldId]: newVal };
|
const next = { ...prev, [fieldId]: newVal };
|
||||||
|
|
||||||
const getBaseIdForField = (id: string) => id.replace(/_\d+$/, '');
|
const getBaseIdForField = (id: string) => id.replace(/_\d+$/, '');
|
||||||
const fieldDef = schema?.fields.find(f => f.id === fieldId);
|
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+$/, '');
|
const getBaseId = (id: string) => id.replace(/_\d+$/, '');
|
||||||
for (const key of Object.keys(rawRow)) {
|
for (const key of Object.keys(rawRow)) {
|
||||||
const lowerKey = key.toLowerCase();
|
const lowerKey = key.toLowerCase();
|
||||||
let targetCol = schema?.fields.find(c =>
|
let targetCol = schema?.fields.find(c =>
|
||||||
c.id.toLowerCase() === lowerKey ||
|
c.id.toLowerCase() === lowerKey ||
|
||||||
(c.mapped_workflow_field || '').toLowerCase() === lowerKey ||
|
(c.mapped_workflow_field || '').toLowerCase() === lowerKey ||
|
||||||
getBaseId(c.id).toLowerCase() === lowerKey ||
|
getBaseId(c.id).toLowerCase() === lowerKey ||
|
||||||
c.name.toLowerCase().replace(/\s+/g, '') === lowerKey.replace(/_/g, '')
|
c.name.toLowerCase().replace(/\s+/g, '') === lowerKey.replace(/_/g, '')
|
||||||
);
|
);
|
||||||
if (targetCol && targetCol.id !== fieldId) {
|
if (targetCol && targetCol.id !== fieldId) {
|
||||||
@ -237,10 +238,10 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
|
|
||||||
for (const key of Object.keys(rawData)) {
|
for (const key of Object.keys(rawData)) {
|
||||||
const lowerKey = key.toLowerCase();
|
const lowerKey = key.toLowerCase();
|
||||||
let targetCol = schema?.fields.find(c =>
|
let targetCol = schema?.fields.find(c =>
|
||||||
c.id.toLowerCase() === lowerKey ||
|
c.id.toLowerCase() === lowerKey ||
|
||||||
(c.mapped_workflow_field || '').toLowerCase() === lowerKey ||
|
(c.mapped_workflow_field || '').toLowerCase() === lowerKey ||
|
||||||
getBaseId(c.id).toLowerCase() === lowerKey ||
|
getBaseId(c.id).toLowerCase() === lowerKey ||
|
||||||
c.name.toLowerCase().replace(/\s+/g, '') === lowerKey.replace(/_/g, '')
|
c.name.toLowerCase().replace(/\s+/g, '') === lowerKey.replace(/_/g, '')
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -250,32 +251,32 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
targetCol = undefined;
|
targetCol = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!targetCol && (fieldId === 'route_name_2' || fieldId.startsWith('route_name'))) {
|
if (!targetCol && (fieldId === 'route_name_2' || fieldId.startsWith('route_name'))) {
|
||||||
targetCol = schema?.fields.find(c => {
|
targetCol = schema?.fields.find(c => {
|
||||||
const mappedName = (c.mapped_workflow_field || '').toLowerCase();
|
const mappedName = (c.mapped_workflow_field || '').toLowerCase();
|
||||||
const nameFallback = (c.name || '').toLowerCase().replace(/\s+/g, '_');
|
const nameFallback = (c.name || '').toLowerCase().replace(/\s+/g, '_');
|
||||||
const fieldName = mappedName || nameFallback;
|
const fieldName = mappedName || nameFallback;
|
||||||
|
|
||||||
return fieldName === `distributor_${lowerKey}` ||
|
return fieldName === `distributor_${lowerKey}` ||
|
||||||
(lowerKey === 'phone' && fieldName === 'distributor_phone_number') ||
|
(lowerKey === 'phone' && fieldName === 'distributor_phone_number') ||
|
||||||
(lowerKey === 'email' && fieldName === 'distributor_email');
|
(lowerKey === 'email' && fieldName === 'distributor_email');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!targetCol) {
|
if (!targetCol) {
|
||||||
const pKey = prefix + lowerKey;
|
const pKey = prefix + lowerKey;
|
||||||
targetCol = schema?.fields.find(c =>
|
targetCol = schema?.fields.find(c =>
|
||||||
c.id.toLowerCase() === pKey ||
|
c.id.toLowerCase() === pKey ||
|
||||||
(c.mapped_workflow_field || '').toLowerCase() === pKey ||
|
(c.mapped_workflow_field || '').toLowerCase() === pKey ||
|
||||||
getBaseId(c.id).toLowerCase() === pKey ||
|
getBaseId(c.id).toLowerCase() === pKey ||
|
||||||
c.name.toLowerCase().replace(/\s+/g, '') === pKey.replace(/_/g, '')
|
c.name.toLowerCase().replace(/\s+/g, '') === pKey.replace(/_/g, '')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetCol && targetCol.id !== fieldId) {
|
if (targetCol && targetCol.id !== fieldId) {
|
||||||
let fillVal = rawData[key];
|
let fillVal = rawData[key];
|
||||||
|
|
||||||
if ((targetCol.data_type === 'select' || targetCol.data_type === 'multiselect') && targetCol.properties?.options) {
|
if ((targetCol.data_type === 'select' || targetCol.data_type === 'multiselect') && targetCol.properties?.options) {
|
||||||
const matchedOpt = targetCol.properties.options.find(
|
const matchedOpt = targetCol.properties.options.find(
|
||||||
(o: any) => String(o.value).toLowerCase() === String(fillVal).toLowerCase()
|
(o: any) => String(o.value).toLowerCase() === String(fillVal).toLowerCase()
|
||||||
@ -304,12 +305,12 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
let totalKgs = 0;
|
let totalKgs = 0;
|
||||||
|
|
||||||
const getBaseId = (id: string) => id.replace(/_\d+$/, '');
|
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'
|
c.id === 'bags' || getBaseId(c.id) === 'bags' || c.mapped_workflow_field === 'bags' || c.name.toLowerCase() === 'bags'
|
||||||
)?.id || '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'
|
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';
|
)?.id || 'row_kgs';
|
||||||
|
|
||||||
@ -327,7 +328,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
if (tkField) next[tkField.id] = totalKgs;
|
if (tkField) next[tkField.id] = totalKgs;
|
||||||
else next['total_kgs'] = totalKgs;
|
else next['total_kgs'] = totalKgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
return next;
|
return next;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -340,7 +341,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Filter out disabled fields (usually server-generated IDs)
|
// 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 actionField = fields.find(f => f.name.toLowerCase() === 'action' && f.data_type === 'radio');
|
||||||
const normalFields = fields.filter(f => f !== actionField);
|
const normalFields = fields.filter(f => f !== actionField);
|
||||||
@ -357,7 +358,12 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const f of fields) {
|
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 (val == null) continue;
|
||||||
|
|
||||||
if (f.data_type === 'phone' && typeof val === 'string') {
|
if (f.data_type === 'phone' && typeof val === 'string') {
|
||||||
@ -388,7 +394,8 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
} else {
|
} else {
|
||||||
res = await client.startInstance(currentActivityId, payload);
|
res = await client.startInstance(currentActivityId, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasSubmittedRef.current = true;
|
||||||
let pending = [...chainQueue];
|
let pending = [...chainQueue];
|
||||||
let chainSource = (res as any).activity_chain || schema.activity_chain || [];
|
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
|
// Remove any existing occurrences from pending to avoid duplicates
|
||||||
pending = pending.filter(p => !newActivities.some((n: any) => n.activity_uid === p.activity_uid));
|
pending = pending.filter(p => !newActivities.some((n: any) => n.activity_uid === p.activity_uid));
|
||||||
|
|
||||||
// Prepend the new activities for depth-first execution (nested chaining)
|
// Prepend the new activities for depth-first execution (nested chaining)
|
||||||
pending = [...newActivities, ...pending];
|
pending = [...newActivities, ...pending];
|
||||||
|
|
||||||
@ -418,21 +425,21 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
if (nextActivity) {
|
if (nextActivity) {
|
||||||
let nextPrefillData = undefined;
|
let nextPrefillData = undefined;
|
||||||
if (nextActivity.activity_uid === ORDER_BOOKING.activities.POTENTIAL_MINING.uid) {
|
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) {
|
if (!storeCodeToSend) {
|
||||||
let storeId = values['select_store'] || chainedPrefillData?.['select_store'] || (schema?.prefill_data as any)?.select_store || (schema?.data as any)?.select_store;
|
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) {
|
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);
|
storeId = (storeId as any).value || (storeId as any).instance_id || String(storeId);
|
||||||
}
|
}
|
||||||
if (!storeCodeToSend && storeId) {
|
if (!storeCodeToSend && storeId) {
|
||||||
try {
|
try {
|
||||||
const detailRes = await client.detailView(STORE.detailViews.STORE, storeId);
|
const detailRes = await client.detailView(STORE.detailViews.STORE, storeId);
|
||||||
if (detailRes.data && detailRes.data.store_code) {
|
if (detailRes.data && (detailRes.data.store_code_2 || detailRes.data.store_code)) {
|
||||||
storeCodeToSend = String(detailRes.data.store_code);
|
storeCodeToSend = String(detailRes.data.store_code_2 || detailRes.data.store_code);
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
try {
|
try {
|
||||||
const lookupRes = await client.wfLookupRecords({
|
const lookupRes = await client.wfLookupRecords({
|
||||||
activityId: ORDER_BOOKING.activities.LOG_VISIT.uid,
|
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 arr = Array.isArray(lookupRes) ? lookupRes : (lookupRes.data || lookupRes.records || []);
|
||||||
const row = arr.find((r: any) => String(r.instance_id || r.id) === String(storeId));
|
const row = arr.find((r: any) => String(r.instance_id || r.id) === String(storeId));
|
||||||
if (row && row.store_code) {
|
if (row && (row.store_code_2 || row.store_code)) {
|
||||||
storeCodeToSend = String(row.store_code);
|
storeCodeToSend = String(row.store_code_2 || row.store_code);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Failed to fetch store code:", err);
|
console.error("Failed to fetch store code:", err);
|
||||||
@ -451,7 +458,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!storeCodeToSend) {
|
if (!storeCodeToSend) {
|
||||||
storeCodeToSend = String(values['select_store'] || chainedPrefillData?.['select_store'] || (schema?.prefill_data as any)?.select_store || '');
|
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[] } }>(
|
const pmRes = await client.request<{ potential: { potential: any[] } }>(
|
||||||
'POST',
|
'POST',
|
||||||
'/api/papi2/potential-mining',
|
'/api/papi2/potential-mining',
|
||||||
{
|
{
|
||||||
instance_id: String(res.instance_id ?? currentInstanceId),
|
instance_id: String(res.instance_id ?? currentInstanceId),
|
||||||
store_code: storeCodeToSend
|
store_code: storeCodeToSend
|
||||||
},
|
},
|
||||||
@ -483,7 +490,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
console.error("Failed to fetch potential mining for chain", e);
|
console.error("Failed to fetch potential mining for chain", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setChainedPrefillData(prev => ({
|
setChainedPrefillData(prev => ({
|
||||||
...prev,
|
...prev,
|
||||||
...values,
|
...values,
|
||||||
@ -510,7 +517,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
const type = f.data_type;
|
const type = f.data_type;
|
||||||
const val = values[f.id];
|
const val = values[f.id];
|
||||||
const isDisabled = schema.field_defaults?.[f.id]?.disabled || f.properties?.disabled;
|
const isDisabled = schema.field_defaults?.[f.id]?.disabled || f.properties?.disabled;
|
||||||
|
|
||||||
const isPlaceOrder = currentActivityId === ORDER_BOOKING.activities.PLACE_ORDER.uid;
|
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';
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const renderField = () => {
|
const renderField = () => {
|
||||||
if (type === 'wf_lookup') {
|
if (type === 'wf_lookup') {
|
||||||
return (
|
return (
|
||||||
@ -660,7 +667,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
required={f.mandatory}
|
required={f.mandatory}
|
||||||
type="text"
|
type="text"
|
||||||
value={(displayVal as string) ?? ''}
|
value={(displayVal as string) ?? ''}
|
||||||
onChange={() => {}}
|
onChange={() => { }}
|
||||||
disabled
|
disabled
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@ -693,7 +700,10 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
|
|
||||||
<div className="flex items-center justify-end gap-3 mt-4 pt-4 border-t border-border-subtle">
|
<div className="flex items-center justify-end gap-3 mt-4 pt-4 border-t border-border-subtle">
|
||||||
{onCancel && (
|
{onCancel && (
|
||||||
<Button type="button" variant="secondary" onClick={onCancel} disabled={submitting}>
|
<Button type="button" variant="secondary" onClick={() => {
|
||||||
|
if (hasSubmittedRef.current) onSuccess?.();
|
||||||
|
else onCancel?.();
|
||||||
|
}} disabled={submitting}>
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { useState, useEffect, useCallback, useRef } from 'react';
|
import { useState, useEffect, useCallback, useRef } from 'react';
|
||||||
import type { ZinoClient } from '../../api/client';
|
import type { ZinoClient } from '../../api/client';
|
||||||
import type { FormScreenResponse } from '../../api/types';
|
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 { Button } from '../buttons/Button';
|
||||||
import { Select } from '../reusable/Select';
|
import { Select } from '../reusable/Select';
|
||||||
import { DateField, TimeField, FileInput, TextField } from './fields';
|
import { DateField, TimeField, FileInput, TextField } from './fields';
|
||||||
@ -308,7 +308,12 @@ export function LogVisitForm({ client, onSuccess, onCancel, onActivityChange }:
|
|||||||
const payload: Record<string, any> = {};
|
const payload: Record<string, any> = {};
|
||||||
validFieldIds.forEach(fieldId => {
|
validFieldIds.forEach(fieldId => {
|
||||||
const val = valuesRef.current[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;
|
payload[fieldId] = val;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -365,7 +370,7 @@ export function LogVisitForm({ client, onSuccess, onCancel, onActivityChange }:
|
|||||||
instanceId={chainedActivity.instanceId}
|
instanceId={chainedActivity.instanceId}
|
||||||
customPrefillData={chainedActivity.prefillData}
|
customPrefillData={chainedActivity.prefillData}
|
||||||
onSuccess={onSuccess}
|
onSuccess={onSuccess}
|
||||||
onCancel={onCancel}
|
onCancel={onSuccess}
|
||||||
onActivityChange={onActivityChange}
|
onActivityChange={onActivityChange}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@ -388,7 +393,7 @@ export function LogVisitForm({ client, onSuccess, onCancel, onActivityChange }:
|
|||||||
const lowerId = fieldId.toLowerCase();
|
const lowerId = fieldId.toLowerCase();
|
||||||
const lowerName = f.name.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
|
// Skip daily_log and route_code (or hidden fields) from visual rendering
|
||||||
if (
|
if (
|
||||||
|
|||||||
@ -403,7 +403,7 @@ export function SmartGridField({
|
|||||||
editingIdx === null ? 'grid-rows-[1fr] opacity-100 mt-4' : 'grid-rows-[0fr] opacity-0 mt-0 hidden'
|
editingIdx === null ? 'grid-rows-[1fr] opacity-100 mt-4' : 'grid-rows-[0fr] opacity-0 mt-0 hidden'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<div className="overflow-hidden min-h-0">
|
<div className={`min-h-0 ${editingIdx === null ? 'overflow-visible' : 'overflow-hidden'}`}>
|
||||||
<div className="p-4 border border-border-subtle rounded-2xl bg-card shadow-sm">
|
<div className="p-4 border border-border-subtle rounded-2xl bg-card shadow-sm">
|
||||||
<h4 className="text-sm font-semibold text-strong mb-4 flex items-center gap-2">
|
<h4 className="text-sm font-semibold text-strong mb-4 flex items-center gap-2">
|
||||||
Add New Item
|
Add New Item
|
||||||
|
|||||||
@ -49,7 +49,7 @@ export function AnalyticsChart({ data }: AnalyticsChartProps) {
|
|||||||
<Card key={chart.chart_uid || idx} title={title} className="shadow-sm">
|
<Card key={chart.chart_uid || idx} title={title} className="shadow-sm">
|
||||||
<div className="h-[320px] w-full mt-4 [&_.recharts-wrapper]:!outline-none [&_.recharts-surface]:!outline-none [&_*]:!outline-none">
|
<div className="h-[320px] w-full mt-4 [&_.recharts-wrapper]:!outline-none [&_.recharts-surface]:!outline-none [&_*]:!outline-none">
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<BarChart data={formattedRows} margin={{ top: 25, right: 10, left: -20, bottom: 0 }}>
|
<BarChart data={formattedRows} margin={{ top: 25, right: 10, left: -20, bottom: 20 }}>
|
||||||
<defs>
|
<defs>
|
||||||
<linearGradient id={`colorGradient-${idx}`} x1="0" y1="0" x2="0" y2="1">
|
<linearGradient id={`colorGradient-${idx}`} x1="0" y1="0" x2="0" y2="1">
|
||||||
<stop offset="0%" stopColor="var(--primary-color)" stopOpacity={1} />
|
<stop offset="0%" stopColor="var(--primary-color)" stopOpacity={1} />
|
||||||
@ -62,7 +62,10 @@ export function AnalyticsChart({ data }: AnalyticsChartProps) {
|
|||||||
axisLine={false}
|
axisLine={false}
|
||||||
tickLine={false}
|
tickLine={false}
|
||||||
tick={{ fontSize: 12, fill: '#64748B' }}
|
tick={{ fontSize: 12, fill: '#64748B' }}
|
||||||
|
angle={-45}
|
||||||
|
textAnchor="end"
|
||||||
dy={10}
|
dy={10}
|
||||||
|
height={60}
|
||||||
/>
|
/>
|
||||||
<YAxis
|
<YAxis
|
||||||
axisLine={false}
|
axisLine={false}
|
||||||
|
|||||||
@ -88,7 +88,7 @@ export function AllDailyLogsPage() {
|
|||||||
title={instanceId != null ? `Daily Log #${instanceId}` : undefined}
|
title={instanceId != null ? `Daily Log #${instanceId}` : undefined}
|
||||||
width="lg"
|
width="lg"
|
||||||
>
|
>
|
||||||
{instanceId != null && <DailyLogDetail instanceId={instanceId} />}
|
{instanceId != null && <DailyLogDetail instanceId={instanceId} refreshKey={refreshKey} />}
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -27,7 +27,7 @@ export function CallsPage() {
|
|||||||
setMiningLoading(true);
|
setMiningLoading(true);
|
||||||
setMiningPrefill(undefined);
|
setMiningPrefill(undefined);
|
||||||
try {
|
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) {
|
if (!storeCode) {
|
||||||
console.warn("Store code not found on selected row, proceeding anyway.");
|
console.warn("Store code not found on selected row, proceeding anyway.");
|
||||||
@ -72,7 +72,7 @@ export function CallsPage() {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-full bg-transparent w-full relative">
|
<div className="flex flex-col h-full bg-transparent w-full relative">
|
||||||
<div className="flex-1 pb-24 w-full overflow-y-auto">
|
<div className="flex-1 pb-24 w-full overflow-y-auto">
|
||||||
<CallDetail instanceId={instanceId} onDataLoad={setSelectedRow} onBack={() => { navigate(`/calls`); setIsFabOpen(false); }} />
|
<CallDetail instanceId={instanceId} refreshKey={refreshKey} onDataLoad={setSelectedRow} onBack={() => { navigate(`/calls`); setIsFabOpen(false); }} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="fixed bottom-24 right-6 flex flex-col items-end gap-3 z-50">
|
<div className="fixed bottom-24 right-6 flex flex-col items-end gap-3 z-50">
|
||||||
@ -105,6 +105,17 @@ export function CallsPage() {
|
|||||||
Place Order
|
Place Order
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
} else if (stateName === 'visited') {
|
||||||
|
return (
|
||||||
|
<Button size="sm" onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
setActiveActivity({ id: ORDER_BOOKING.activities.PRODUCTIVITY_OF_VISIT.uid, name: 'Productivity of Visit' });
|
||||||
|
setIsFabOpen(false);
|
||||||
|
}}>
|
||||||
|
Productivity of Visit
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
} else if (stateName.includes('no order') || stateName.includes('non-productive') || stateName.includes('non productive')) {
|
} else if (stateName.includes('no order') || stateName.includes('non-productive') || stateName.includes('non productive')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ export function DailyLogsPage() {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-full bg-transparent w-full relative">
|
<div className="flex flex-col h-full bg-transparent w-full relative">
|
||||||
<div className="flex-1 pb-24 w-full overflow-y-auto">
|
<div className="flex-1 pb-24 w-full overflow-y-auto">
|
||||||
<DailyLogDetail instanceId={instanceId} onBack={() => navigate(`/daily`)} />
|
<DailyLogDetail instanceId={instanceId} refreshKey={refreshKey} onBack={() => navigate(`/daily`)} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -29,7 +29,7 @@ export function OrdersPage() {
|
|||||||
setMiningLoading(true);
|
setMiningLoading(true);
|
||||||
setMiningPrefill(undefined);
|
setMiningPrefill(undefined);
|
||||||
try {
|
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) {
|
if (!storeCode) {
|
||||||
console.warn("Store code not found on selected row, proceeding anyway.");
|
console.warn("Store code not found on selected row, proceeding anyway.");
|
||||||
@ -74,7 +74,7 @@ export function OrdersPage() {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-full bg-transparent w-full relative">
|
<div className="flex flex-col h-full bg-transparent w-full relative">
|
||||||
<div className="flex-1 pb-24 w-full overflow-y-auto">
|
<div className="flex-1 pb-24 w-full overflow-y-auto">
|
||||||
<OrderDetail instanceId={instanceId} onDataLoad={setSelectedRow} onBack={() => { navigate(`/orders`); setIsFabOpen(false); }} />
|
<OrderDetail instanceId={instanceId} refreshKey={refreshKey} onDataLoad={setSelectedRow} onBack={() => { navigate(`/orders`); setIsFabOpen(false); }} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="fixed bottom-24 right-6 flex flex-col items-end gap-3 z-50">
|
<div className="fixed bottom-24 right-6 flex flex-col items-end gap-3 z-50">
|
||||||
@ -107,6 +107,17 @@ export function OrdersPage() {
|
|||||||
Place Order
|
Place Order
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
} else if (stateName === 'visited') {
|
||||||
|
return (
|
||||||
|
<Button size="sm" onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
setActiveActivity({ id: ORDER_BOOKING.activities.PRODUCTIVITY_OF_VISIT.uid, name: 'Productivity of Visit' });
|
||||||
|
setIsFabOpen(false);
|
||||||
|
}}>
|
||||||
|
Productivity of Visit
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
} else if (stateName.includes('no order') || stateName.includes('non-productive') || stateName.includes('non productive')) {
|
} else if (stateName.includes('no order') || stateName.includes('non-productive') || stateName.includes('non productive')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@ export function StoresPage() {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-full bg-transparent w-full relative">
|
<div className="flex flex-col h-full bg-transparent w-full relative">
|
||||||
<div className="flex-1 pb-24 w-full overflow-y-auto">
|
<div className="flex-1 pb-24 w-full overflow-y-auto">
|
||||||
<StoreDetail instanceId={instanceId} onBack={() => navigate(`/stores`)} />
|
<StoreDetail instanceId={instanceId} refreshKey={refreshKey} onBack={() => navigate(`/stores`)} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Edit store modal can still open over the detail view if needed */}
|
{/* Edit store modal can still open over the detail view if needed */}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user