changed the image retriving fix
This commit is contained in:
parent
2740961b7d
commit
3a9df191b6
16
fix_lower.cjs
Normal file
16
fix_lower.cjs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const files = [
|
||||||
|
'f:/WorkPlace/dev/krishnasales_mobile/src/components/forms/fields/SmartGridField.tsx',
|
||||||
|
'f:/WorkPlace/dev/krishnasales_mobile/src/components/forms/DynamicForm.tsx'
|
||||||
|
];
|
||||||
|
files.forEach(file => {
|
||||||
|
let content = fs.readFileSync(file, 'utf8');
|
||||||
|
content = content.replace(/col\.name\.toLowerCase/g, "(col.name || '').toLowerCase");
|
||||||
|
content = content.replace(/col\.id\.toLowerCase/g, "(col.id || '').toLowerCase");
|
||||||
|
content = content.replace(/c\.name\.toLowerCase/g, "(c.name || '').toLowerCase");
|
||||||
|
content = content.replace(/f\.id\.toLowerCase/g, "(f.id || '').toLowerCase");
|
||||||
|
content = content.replace(/f\.name\.toLowerCase/g, "(f.name || '').toLowerCase");
|
||||||
|
content = content.replace(/col\.mapped_workflow_field\?\.toLowerCase/g, "(col.mapped_workflow_field || '').toLowerCase");
|
||||||
|
fs.writeFileSync(file, content, 'utf8');
|
||||||
|
console.log('Fixed', file);
|
||||||
|
});
|
||||||
@ -211,7 +211,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
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) {
|
||||||
next[targetCol.id] = rawRow[key];
|
next[targetCol.id] = rawRow[key];
|
||||||
@ -238,7 +238,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
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 (fieldId.startsWith('route_name') && targetCol) {
|
if (fieldId.startsWith('route_name') && targetCol) {
|
||||||
@ -266,7 +266,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
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, '')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
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 =>
|
||||||
@ -339,7 +339,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 && !HIDDEN_FORM_FIELDS.includes(f.id));
|
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);
|
||||||
|
|
||||||
const handleSubmit = async (e: React.FormEvent) => {
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
@ -355,7 +355,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
|
|
||||||
for (const f of fields) {
|
for (const f of fields) {
|
||||||
let 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')));
|
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) {
|
if (isNotesOrRemarks && val == null) {
|
||||||
val = '';
|
val = '';
|
||||||
}
|
}
|
||||||
@ -531,7 +531,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
|||||||
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';
|
||||||
|
|
||||||
if (isPlaceOrder && isOrderId) {
|
if (isPlaceOrder && isOrderId) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -70,7 +70,7 @@ export function SmartGridField({
|
|||||||
if (option && option._raw) {
|
if (option && option._raw) {
|
||||||
const getBaseId = (id: string) => id.replace(/_\d+$/, '');
|
const getBaseId = (id: string) => id.replace(/_\d+$/, '');
|
||||||
for (const key of Object.keys(option._raw)) {
|
for (const key of Object.keys(option._raw)) {
|
||||||
const targetCol = columns.find(c => c.id === key || c.mapped_workflow_field === key || getBaseId(c.id) === key || c.name.toLowerCase().replace(/\s+/g, '') === key.toLowerCase().replace(/_/g, ''));
|
const targetCol = columns.find(c => c.id === key || c.mapped_workflow_field === key || getBaseId(c.id) === key || (c.name || '').toLowerCase().replace(/\s+/g, '') === key.toLowerCase().replace(/_/g, ''));
|
||||||
if (targetCol && targetCol.id !== fieldId) {
|
if (targetCol && targetCol.id !== fieldId) {
|
||||||
row[targetCol.id] = option._raw[key];
|
row[targetCol.id] = option._raw[key];
|
||||||
} else if (!targetCol && key !== fieldId) {
|
} else if (!targetCol && key !== fieldId) {
|
||||||
@ -83,7 +83,7 @@ export function SmartGridField({
|
|||||||
// Auto-calculate row_kgs if sku and bags are present
|
// Auto-calculate row_kgs if sku and bags are present
|
||||||
const getBaseId = (id: string) => id.replace(/_\d+$/, '');
|
const getBaseId = (id: string) => id.replace(/_\d+$/, '');
|
||||||
const getVal = (key: string) => {
|
const getVal = (key: string) => {
|
||||||
const c = columns.find(c => c.id === key || c.mapped_workflow_field === key || getBaseId(c.id) === key || c.name.toLowerCase().replace(/\s+/g, '') === key.toLowerCase().replace(/_/g, ''));
|
const c = columns.find(c => c.id === key || c.mapped_workflow_field === key || getBaseId(c.id) === key || (c.name || '').toLowerCase().replace(/\s+/g, '') === key.toLowerCase().replace(/_/g, ''));
|
||||||
return c ? row[c.id] : row[key];
|
return c ? row[c.id] : row[key];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -111,13 +111,13 @@ export function SmartGridField({
|
|||||||
|
|
||||||
for (const col of visibleColumns) {
|
for (const col of visibleColumns) {
|
||||||
if (isPotentialMining) {
|
if (isPotentialMining) {
|
||||||
const isReasonOrRemark = col.id.toLowerCase().includes('reason') || col.name.toLowerCase().includes('reason') || col.id.toLowerCase().includes('remark') || col.name.toLowerCase().includes('remark');
|
const isReasonOrRemark = (col.id || '').toLowerCase().includes('reason') || (col.name || '').toLowerCase().includes('reason') || (col.id || '').toLowerCase().includes('remark') || (col.name || '').toLowerCase().includes('remark');
|
||||||
if (!isReasonOrRemark) continue;
|
if (!isReasonOrRemark) continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isCategory = col.id === 'product_category' || col.name === 'Product Category' || col.mapped_workflow_field === 'product_category' || getBaseId(col.id) === 'product_category';
|
const isCategory = col.id === 'product_category' || col.name === 'Product Category' || col.mapped_workflow_field === 'product_category' || getBaseId(col.id) === 'product_category';
|
||||||
const isProductName = col.id === 'product_name' || col.name === 'Product Name' || col.mapped_workflow_field === 'product_name' || getBaseId(col.id) === 'product_name';
|
const isProductName = col.id === 'product_name' || col.name === 'Product Name' || col.mapped_workflow_field === 'product_name' || getBaseId(col.id) === 'product_name';
|
||||||
const isBags = col.id === 'bags' || col.name === 'Bags' || col.mapped_workflow_field === 'bags' || getBaseId(col.id) === 'bags' || col.id.toLowerCase().includes('quantity') || col.name.toLowerCase().includes('quantity') || col.mapped_workflow_field?.toLowerCase().includes('quantity');
|
const isBags = col.id === 'bags' || col.name === 'Bags' || col.mapped_workflow_field === 'bags' || getBaseId(col.id) === 'bags' || (col.id || '').toLowerCase().includes('quantity') || (col.name || '').toLowerCase().includes('quantity') || (col.mapped_workflow_field || '').toLowerCase().includes('quantity');
|
||||||
|
|
||||||
let isRequired = col.mandatory || (isCatSelected && (isProductName || isBags));
|
let isRequired = col.mandatory || (isCatSelected && (isProductName || isBags));
|
||||||
if (isOrderDetails && (isCategory || isProductName || isBags)) {
|
if (isOrderDetails && (isCategory || isProductName || isBags)) {
|
||||||
@ -155,7 +155,7 @@ export function SmartGridField({
|
|||||||
const next = [...value];
|
const next = [...value];
|
||||||
const existingRow = { ...next[foundIdx] };
|
const existingRow = { ...next[foundIdx] };
|
||||||
|
|
||||||
const bagsCol = columns.find(c => c.id === 'bags' || getBaseId(c.id) === 'bags' || c.mapped_workflow_field === 'bags' || c.name.toLowerCase() === 'bags');
|
const bagsCol = columns.find(c => c.id === 'bags' || getBaseId(c.id) === 'bags' || c.mapped_workflow_field === 'bags' || (c.name || '').toLowerCase() === 'bags');
|
||||||
const rowKgsCol = columns.find(c => c.id === 'row_kgs' || getBaseId(c.id) === 'row_kgs' || c.mapped_workflow_field === 'row_kgs' || getBaseId(c.id) === 'rowkgs');
|
const rowKgsCol = columns.find(c => c.id === 'row_kgs' || getBaseId(c.id) === 'row_kgs' || c.mapped_workflow_field === 'row_kgs' || getBaseId(c.id) === 'rowkgs');
|
||||||
const skuCol = columns.find(c => c.id === 'sku' || getBaseId(c.id) === 'sku' || c.mapped_workflow_field === 'sku');
|
const skuCol = columns.find(c => c.id === 'sku' || getBaseId(c.id) === 'sku' || c.mapped_workflow_field === 'sku');
|
||||||
|
|
||||||
@ -194,14 +194,14 @@ export function SmartGridField({
|
|||||||
const getBaseId = (id: string) => id.replace(/_\d+$/, '');
|
const getBaseId = (id: string) => id.replace(/_\d+$/, '');
|
||||||
|
|
||||||
if (isPotentialMining) {
|
if (isPotentialMining) {
|
||||||
const isReasonOrRemark = col.id.toLowerCase().includes('reason') || col.name.toLowerCase().includes('reason') || col.id.toLowerCase().includes('remark') || col.name.toLowerCase().includes('remark');
|
const isReasonOrRemark = (col.id || '').toLowerCase().includes('reason') || (col.name || '').toLowerCase().includes('reason') || (col.id || '').toLowerCase().includes('remark') || (col.name || '').toLowerCase().includes('remark');
|
||||||
if (!isReasonOrRemark) return null;
|
if (!isReasonOrRemark) return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const catColId = columns.find(c => c.id === 'product_category' || c.name === 'Product Category' || c.mapped_workflow_field === 'product_category' || getBaseId(c.id) === 'product_category')?.id;
|
const catColId = columns.find(c => c.id === 'product_category' || c.name === 'Product Category' || c.mapped_workflow_field === 'product_category' || getBaseId(c.id) === 'product_category')?.id;
|
||||||
const isCatSelected = catColId ? !!newRow[catColId] : false;
|
const isCatSelected = catColId ? !!newRow[catColId] : false;
|
||||||
const isProductName = col.id === 'product_name' || col.name === 'Product Name' || col.mapped_workflow_field === 'product_name' || getBaseId(col.id) === 'product_name';
|
const isProductName = col.id === 'product_name' || col.name === 'Product Name' || col.mapped_workflow_field === 'product_name' || getBaseId(col.id) === 'product_name';
|
||||||
const isBags = col.id === 'bags' || col.name === 'Bags' || col.mapped_workflow_field === 'bags' || getBaseId(col.id) === 'bags' || col.id.toLowerCase().includes('quantity') || col.name.toLowerCase().includes('quantity') || col.mapped_workflow_field?.toLowerCase().includes('quantity');
|
const isBags = col.id === 'bags' || col.name === 'Bags' || col.mapped_workflow_field === 'bags' || getBaseId(col.id) === 'bags' || (col.id || '').toLowerCase().includes('quantity') || (col.name || '').toLowerCase().includes('quantity') || (col.mapped_workflow_field || '').toLowerCase().includes('quantity');
|
||||||
const isRequired = col.mandatory || (isCatSelected && (isProductName || isBags));
|
const isRequired = col.mandatory || (isCatSelected && (isProductName || isBags));
|
||||||
|
|
||||||
if (col.data_type === 'select' || col.data_type === 'multiselect') {
|
if (col.data_type === 'select' || col.data_type === 'multiselect') {
|
||||||
@ -275,10 +275,10 @@ export function SmartGridField({
|
|||||||
let reasonStr = '';
|
let reasonStr = '';
|
||||||
|
|
||||||
visibleColumns.forEach(col => {
|
visibleColumns.forEach(col => {
|
||||||
const isName = col.id.toLowerCase().includes('name') || col.name.toLowerCase().includes('name') || (col.id.toLowerCase().includes('category') && productName === 'Unknown Product');
|
const isName = (col.id || '').toLowerCase().includes('name') || (col.name || '').toLowerCase().includes('name') || ((col.id || '').toLowerCase().includes('category') && productName === 'Unknown Product');
|
||||||
const isBags = col.id.toLowerCase().includes('bags') || col.name.toLowerCase().includes('bags') || col.id.toLowerCase().includes('quantity');
|
const isBags = (col.id || '').toLowerCase().includes('bags') || (col.name || '').toLowerCase().includes('bags') || (col.id || '').toLowerCase().includes('quantity');
|
||||||
const isDiff = col.id.toLowerCase().includes('diff') || col.name.toLowerCase().includes('diff');
|
const isDiff = (col.id || '').toLowerCase().includes('diff') || (col.name || '').toLowerCase().includes('diff');
|
||||||
const isReason = col.id.toLowerCase().includes('reason') || col.name.toLowerCase().includes('reason');
|
const isReason = (col.id || '').toLowerCase().includes('reason') || (col.name || '').toLowerCase().includes('reason');
|
||||||
|
|
||||||
const val = row[col.id];
|
const val = row[col.id];
|
||||||
let displayVal = String(val ?? '-');
|
let displayVal = String(val ?? '-');
|
||||||
@ -288,7 +288,7 @@ export function SmartGridField({
|
|||||||
if (opt) displayVal = opt.label;
|
if (opt) displayVal = opt.label;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isName && (productName === 'Unknown Product' || col.id.toLowerCase().includes('name'))) {
|
if (isName && (productName === 'Unknown Product' || (col.id || '').toLowerCase().includes('name'))) {
|
||||||
productName = displayVal;
|
productName = displayVal;
|
||||||
}
|
}
|
||||||
if (isBags) {
|
if (isBags) {
|
||||||
|
|||||||
@ -163,7 +163,7 @@ export function NearestStoresMap() {
|
|||||||
<Marker
|
<Marker
|
||||||
position={userLocation}
|
position={userLocation}
|
||||||
icon={{
|
icon={{
|
||||||
url: 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png'
|
url: 'https://maps.google.com/mapfiles/ms/icons/blue-dot.png'
|
||||||
}}
|
}}
|
||||||
title="You are here"
|
title="You are here"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -27,10 +27,10 @@ export function CallsPage() {
|
|||||||
setMiningLoading(true);
|
setMiningLoading(true);
|
||||||
setMiningPrefill(undefined);
|
setMiningPrefill(undefined);
|
||||||
try {
|
try {
|
||||||
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;
|
const storeCode = selectedRow?.select_store_row?.store_code_2 || selectedRow?.select_store_row?.store_code || 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.", selectedRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
|
|||||||
@ -29,10 +29,10 @@ export function OrdersPage() {
|
|||||||
setMiningLoading(true);
|
setMiningLoading(true);
|
||||||
setMiningPrefill(undefined);
|
setMiningPrefill(undefined);
|
||||||
try {
|
try {
|
||||||
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;
|
const storeCode = selectedRow?.select_store_row?.store_code_2 || selectedRow?.select_store_row?.store_code || 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.", selectedRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user