store code fix
This commit is contained in:
parent
b288ebf6cc
commit
d9e932ce8c
@ -249,3 +249,7 @@ export const PIPELINE = {
|
||||
salesOfficers: '/api/papi2/sales-officers'
|
||||
}
|
||||
};
|
||||
|
||||
export const HIDDEN_FORM_FIELDS = [
|
||||
'store_code_3'
|
||||
];
|
||||
|
||||
@ -130,7 +130,7 @@ export function CallDetail({
|
||||
// Extract store info with fallbacks matching reference
|
||||
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 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';
|
||||
|
||||
@ -77,7 +77,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);
|
||||
|
||||
@ -17,7 +17,7 @@ import {
|
||||
WfLookupField,
|
||||
RadioField,
|
||||
} from './fields';
|
||||
import { ORDER_BOOKING, STORE, DAILY_REPORTS, PIPELINE } from '../../api/config';
|
||||
import { ORDER_BOOKING, STORE, DAILY_REPORTS, PIPELINE, HIDDEN_FORM_FIELDS } from '../../api/config';
|
||||
import { isCategoryColumn, isProductColumn } from './fields/gridUtils';
|
||||
|
||||
export interface DynamicFormProps {
|
||||
@ -75,14 +75,8 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
||||
}
|
||||
});
|
||||
}
|
||||
const imageFieldIds = new Set(
|
||||
res.fields.filter(f => f.data_type === 'image' || f.data_type === 'file').map(f => f.id)
|
||||
);
|
||||
|
||||
const mapPrefillData = (sourceData: Record<string, unknown>) => {
|
||||
res.fields.forEach(f => {
|
||||
if (imageFieldIds.has(f.id)) return;
|
||||
|
||||
const getBaseId = (id: string) => id.replace(/_\d+$/, '');
|
||||
|
||||
if (sourceData[f.id] !== undefined) {
|
||||
@ -132,13 +126,13 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
||||
|
||||
if (customPrefillData) {
|
||||
Object.entries(customPrefillData).forEach(([k, v]) => {
|
||||
if (!imageFieldIds.has(k)) defaultValues[k] = v;
|
||||
defaultValues[k] = v;
|
||||
});
|
||||
}
|
||||
|
||||
if (chainedPrefillData) {
|
||||
Object.entries(chainedPrefillData).forEach(([k, v]) => {
|
||||
if (!imageFieldIds.has(k)) defaultValues[k] = v;
|
||||
defaultValues[k] = v;
|
||||
});
|
||||
}
|
||||
|
||||
@ -593,16 +587,22 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
||||
phone: phoneNum,
|
||||
phone_with_dial_code: `+91${phoneNum}`
|
||||
};
|
||||
} else if ((f.data_type === 'image' || f.data_type === 'file') && Array.isArray(val) && val.length > 0 && val[0] instanceof File) {
|
||||
} else if ((f.data_type === 'image' || f.data_type === 'file') && Array.isArray(val)) {
|
||||
const uploadedFiles = [];
|
||||
for (const file of val) {
|
||||
const fileMeta = await client.uploadFile(file, { activityId: currentActivityId, fieldId: f.id, instanceId: currentInstanceId });
|
||||
uploadedFiles.push(fileMeta);
|
||||
if (file instanceof File) {
|
||||
const fileMeta = await client.uploadFile(file, { activityId: currentActivityId, fieldId: f.id, instanceId: currentInstanceId });
|
||||
uploadedFiles.push(fileMeta);
|
||||
} else {
|
||||
uploadedFiles.push(file);
|
||||
}
|
||||
}
|
||||
payload[f.id] = uploadedFiles;
|
||||
} else if ((f.data_type === 'image' || f.data_type === 'file') && val instanceof File) {
|
||||
const fileMeta = await client.uploadFile(val, { activityId: currentActivityId, fieldId: f.id, instanceId: currentInstanceId });
|
||||
payload[f.id] = [fileMeta];
|
||||
} else if ((f.data_type === 'image' || f.data_type === 'file') && val && typeof val === 'object') {
|
||||
payload[f.id] = [val];
|
||||
} else if (f.data_type.startsWith('grid') || f.data_type === 'smart_grid') {
|
||||
const gridRows = Array.isArray(val) ? val : [];
|
||||
const getFormattedGridVal = (colKey: string, rawVal: unknown, colDef?: FormScreenField) => {
|
||||
@ -860,6 +860,9 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
||||
f.id === 'total_kgs';
|
||||
if (isTotalField) return false;
|
||||
}
|
||||
if (HIDDEN_FORM_FIELDS.includes(f.id) || HIDDEN_FORM_FIELDS.includes(f.name)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
@ -1,12 +1,17 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { BASE_URL, APP_ID } from '../../../api/config';
|
||||
|
||||
export function ImagePreview({ file }: { file: File }) {
|
||||
export function ImagePreview({ file }: { file: File | any }) {
|
||||
const [url, setUrl] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const objectUrl = URL.createObjectURL(file);
|
||||
setUrl(objectUrl);
|
||||
return () => URL.revokeObjectURL(objectUrl);
|
||||
if (file instanceof File) {
|
||||
const objectUrl = URL.createObjectURL(file);
|
||||
setUrl(objectUrl);
|
||||
return () => URL.revokeObjectURL(objectUrl);
|
||||
} else if (file && file.uuid) {
|
||||
setUrl(`${BASE_URL}/app/${APP_ID}/view/files/${file.uuid}/preview`);
|
||||
}
|
||||
}, [file]);
|
||||
|
||||
if (!url) return null;
|
||||
@ -23,10 +28,10 @@ export function FileInput({
|
||||
label: string;
|
||||
type: 'image' | 'file' | string;
|
||||
required?: boolean;
|
||||
value: File[] | undefined | null | unknown;
|
||||
onChange: (files: File[]) => void;
|
||||
value: File[] | any[] | undefined | null | unknown;
|
||||
onChange: (files: (File | any)[]) => void;
|
||||
}) {
|
||||
const files = Array.isArray(value) ? value : (value instanceof File ? [value] : []);
|
||||
const files = Array.isArray(value) ? value : (value ? [value] : []);
|
||||
|
||||
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
if (e.target.files) {
|
||||
@ -68,7 +73,7 @@ export function FileInput({
|
||||
<ImagePreview file={file} />
|
||||
) : (
|
||||
<div className="w-full h-full flex items-center justify-center p-2 text-xs text-center break-all overflow-hidden text-muted">
|
||||
{file.name}
|
||||
{file.name || file.original_name || 'File'}
|
||||
</div>
|
||||
)}
|
||||
<button
|
||||
|
||||
Loading…
Reference in New Issue
Block a user