fix:local storage field storing
This commit is contained in:
parent
061bf9bbc5
commit
465d202458
@ -382,6 +382,17 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
||||
finalValues[actionField.id] = clickedActionRef.current;
|
||||
}
|
||||
|
||||
for (const f of fields) {
|
||||
if (f.mandatory && f.data_type === 'grid') {
|
||||
const val = finalValues[f.id];
|
||||
if (!Array.isArray(val) || val.length === 0) {
|
||||
setSubmitError(`Please add at least one item to ${f.name}`);
|
||||
setSubmitting(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const f of fields) {
|
||||
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')));
|
||||
@ -639,11 +650,13 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
||||
if (type.startsWith('grid')) {
|
||||
return (
|
||||
<SmartGridField
|
||||
key={f.id}
|
||||
label={f.name}
|
||||
columns={f.columns || []}
|
||||
value={(val as Record<string, unknown>[]) || []}
|
||||
onChange={(newVal) => handleFieldChange(f.id, newVal)}
|
||||
isActivityPotentialMining={currentActivityId === ORDER_BOOKING.activities.POTENTIAL_MINING.uid}
|
||||
required={f.mandatory}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@ -11,12 +11,14 @@ export function SmartGridField({
|
||||
value = [],
|
||||
onChange,
|
||||
isActivityPotentialMining = false,
|
||||
required = false,
|
||||
}: {
|
||||
label: string;
|
||||
columns: FormScreenField[];
|
||||
value: Record<string, unknown>[];
|
||||
onChange: (val: Record<string, unknown>[]) => void;
|
||||
isActivityPotentialMining?: boolean;
|
||||
required?: boolean;
|
||||
}) {
|
||||
const isPotentialMining = isActivityPotentialMining;
|
||||
const formRef = useRef<HTMLDivElement>(null);
|
||||
@ -261,7 +263,10 @@ export function SmartGridField({
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-2 font-sans border border-slate-200 rounded-2xl p-4 bg-card shadow-sm mt-2">
|
||||
<span className="text-sm font-semibold text-strong mb-2">{label}</span>
|
||||
<span className="text-sm font-semibold text-strong mb-2">
|
||||
{label}
|
||||
{required && <span className="text-ruby-600"> *</span>}
|
||||
</span>
|
||||
|
||||
{value.length === 0 ? (
|
||||
<span className="text-sm text-faint italic">No rows added.</span>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user