added error message for select store
This commit is contained in:
parent
096dc32d6a
commit
e962291b80
@ -73,6 +73,7 @@ export function LogVisitForm({ client, onSuccess, onCancel, onActivityChange }:
|
|||||||
|
|
||||||
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 [storeError, setStoreError] = useState<string | null>(null);
|
||||||
|
|
||||||
// 1. Fetch form schema from API (/app/434/view/form-screens) & Mobile Pipeline prefill
|
// 1. Fetch form schema from API (/app/434/view/form-screens) & Mobile Pipeline prefill
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -173,6 +174,7 @@ export function LogVisitForm({ client, onSuccess, onCancel, onActivityChange }:
|
|||||||
if (fetchingStoresRef.current) return;
|
if (fetchingStoresRef.current) return;
|
||||||
fetchingStoresRef.current = true;
|
fetchingStoresRef.current = true;
|
||||||
setFetchingStores(true);
|
setFetchingStores(true);
|
||||||
|
setStoreError(null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const formDataToSend = cleanFormData(formDataOverride || valuesRef.current);
|
const formDataToSend = cleanFormData(formDataOverride || valuesRef.current);
|
||||||
@ -222,8 +224,14 @@ export function LogVisitForm({ client, onSuccess, onCancel, onActivityChange }:
|
|||||||
});
|
});
|
||||||
|
|
||||||
setStoreOptions(opts);
|
setStoreOptions(opts);
|
||||||
} catch (e) {
|
} catch (e: any) {
|
||||||
console.error('Failed to load select_store options:', e);
|
console.error('Failed to load select_store options:', e);
|
||||||
|
const msg = e?.message || e?.data?.message || String(e);
|
||||||
|
if (msg.toLowerCase().includes('route_code')) {
|
||||||
|
setStoreError('Please punch-in in Daily Logs');
|
||||||
|
} else {
|
||||||
|
setStoreError('Failed to load stores');
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
setFetchingStores(false);
|
setFetchingStores(false);
|
||||||
fetchingStoresRef.current = false;
|
fetchingStoresRef.current = false;
|
||||||
@ -448,7 +456,7 @@ export function LogVisitForm({ client, onSuccess, onCancel, onActivityChange }:
|
|||||||
|
|
||||||
if (type === 'wf_lookup' || lowerId === 'select_store' || lowerName.includes('select store')) {
|
if (type === 'wf_lookup' || lowerId === 'select_store' || lowerName.includes('select store')) {
|
||||||
return (
|
return (
|
||||||
<div key={fieldId} className="relative">
|
<div key={fieldId} className="flex flex-col gap-1 relative">
|
||||||
<Select
|
<Select
|
||||||
label={f.name}
|
label={f.name}
|
||||||
required={f.mandatory}
|
required={f.mandatory}
|
||||||
@ -463,6 +471,11 @@ export function LogVisitForm({ client, onSuccess, onCancel, onActivityChange }:
|
|||||||
<Spinner size={16} />
|
<Spinner size={16} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{storeError && (
|
||||||
|
<div className="text-sm text-ruby-600 mt-1">
|
||||||
|
{storeError}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user