Ongoing adaptation to new backend structure

This commit is contained in:
Jose
2026-01-25 23:43:25 +01:00
parent 5f5d54d642
commit 59efb7d81f
31 changed files with 505 additions and 514 deletions

View File

@@ -49,7 +49,7 @@ const GastoCard = ({ gasto, isNew = false, onCreate, onUpdate, onDelete, onCance
supplier: gasto.supplier || '',
invoice: gasto.invoice || '',
type: gasto.type ?? 0,
created_at: gasto.created_at?.slice(0, 16) || (isNew ? getNowAsLocalDatetime() : ''),
createdAt: gasto.createdAt?.slice(0, 16) || (isNew ? getNowAsLocalDatetime() : ''),
});
useEffect(() => {
@@ -60,7 +60,7 @@ const GastoCard = ({ gasto, isNew = false, onCreate, onUpdate, onDelete, onCance
supplier: gasto.supplier || '',
invoice: gasto.invoice || '',
type: gasto.type ?? 0,
created_at: gasto.created_at?.slice(0, 16) || (isNew ? getNowAsLocalDatetime() : ''),
createdAt: gasto.createdAt?.slice(0, 16) || (isNew ? getNowAsLocalDatetime() : ''),
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -68,7 +68,7 @@ const GastoCard = ({ gasto, isNew = false, onCreate, onUpdate, onDelete, onCance
const handleChange = (field, value) => setFormData(prev => ({ ...prev, [field]: value }));
const handleDelete = () => typeof onDelete === 'function' && onDelete(gasto.expense_id);
const handleDelete = () => typeof onDelete === 'function' && onDelete(gasto.expenseId);
const handleCancel = () => {
if (onClearError) onClearError();
@@ -80,7 +80,7 @@ const GastoCard = ({ gasto, isNew = false, onCreate, onUpdate, onDelete, onCance
if (onClearError) onClearError();
const newExpense = { ...gasto, ...formData };
if (createMode && typeof onCreate === 'function') return onCreate(newExpense);
if (typeof onUpdate === 'function') return onUpdate(newExpense, gasto.expense_id);
if (typeof onUpdate === 'function') return onUpdate(newExpense, gasto.expenseId);
};
return (
@@ -102,13 +102,13 @@ const GastoCard = ({ gasto, isNew = false, onCreate, onUpdate, onDelete, onCance
<small>
{editMode ? (
<SpanishDateTimePicker
selected={new Date(formData.created_at)}
selected={new Date(formData.createdAt)}
onChange={(date) =>
handleChange('created_at', date.toISOString().slice(0, 16))
handleChange('createdAt', date.toISOString().slice(0, 16))
}
/>
) : (
DateParser.isoToStringWithTime(formData.created_at)
DateParser.isoToStringWithTime(formData.createdAt)
)}
</small>
</div>

View File

@@ -104,7 +104,7 @@ export const GastosPDF = ({ gastos }) => (
{ borderBottomRightRadius: idx === gastos.length - 1 ? 10 : 0 },
]}
>
<Text style={[styles.cell, { flex: 2 }]}>{parseDate(gasto.created_at)}</Text>
<Text style={[styles.cell, { flex: 2 }]}>{parseDate(gasto.createdAt)}</Text>
<Text style={[styles.cell, { flex: 4 }]}>{gasto.concept}</Text>
<Text style={[styles.cell, { flex: 2 }]}>{gasto.amount.toFixed(2)} </Text>
<Text style={[styles.cell, { flex: 3 }]}>{gasto.supplier}</Text>