Refactor MachineCard component and update API endpoints

This commit is contained in:
2026-08-03 10:58:16 +02:00
parent e49d6f0e5b
commit ccbc8d62c5
4 changed files with 12 additions and 43 deletions

View File

@@ -65,7 +65,7 @@ export default function MachineScreen() {
const onScan = async (data: string) => {
console.log('Scanned data:', data);
try {
const response = await api.post('/machine-attendance/scan', { uuid: data });
const response = await api.post('/machine-attendance/in', { uuid: data });
if (response.data?.success) {
console.log('Scan data sent successfully:', response.data);
fetchAttendances();
@@ -84,28 +84,6 @@ export default function MachineScreen() {
}
};
const handleExitPress = (item: MachineAttendanceItem) => {
alert.showConfirm(
'Conferma Uscita',
`Vuoi davvero registrare l'uscita da ${item.name}?`,
[
{ text: 'Annulla', onPress: () => {}, style: 'cancel' },
{ text: 'Conferma', style: 'default', onPress: async () => {
try {
const response = await api.post('/machine-attendance/out', { uuid: item.machine_uuid });
if (response.data?.success) {
fetchAttendances();
} else {
alert.showAlert('error', 'Errore', response.data?.message || 'Impossibile registrare l\'uscita.');
}
} catch (error) {
alert.showAlert('error', 'Errore', 'Impossibile registrare l\'uscita. Riprova più tardi.');
}
}}
]
);
};
if (isLoading && !refreshing) {
return <LoadingScreen />;
}
@@ -192,7 +170,7 @@ export default function MachineScreen() {
) : (
<View>
{attendances.map((item, index) => (
<MachineCard key={index} item={item} onExitPress={handleExitPress} />
<MachineCard key={index} item={item} />
))}
</View>
)}