diff --git a/app/(protected)/_layout.tsx b/app/(protected)/_layout.tsx
index e9f9f6b..8feb106 100644
--- a/app/(protected)/_layout.tsx
+++ b/app/(protected)/_layout.tsx
@@ -80,7 +80,7 @@ export default function ProtectedLayout() {
options={{
title: 'Macchine',
tabBarIcon: ({ color, size }) => ,
- href: authState.user?.isAdmin ? undefined : null,
+ href: !authState.user?.isAdmin ? undefined : null,
}}
/>
{
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 ;
}
@@ -192,7 +170,7 @@ export default function MachineScreen() {
) : (
{attendances.map((item, index) => (
-
+
))}
)}
diff --git a/app/(protected)/permits/index.tsx b/app/(protected)/permits/index.tsx
index 8898b65..ebf6e24 100644
--- a/app/(protected)/permits/index.tsx
+++ b/app/(protected)/permits/index.tsx
@@ -99,13 +99,13 @@ export default function PermitsScreen() {
const deletePermitRequest = async (id: number, itemRef?: React.ElementRef | null) => {
try {
itemRef?.close();
- const res = await api.get(`/request/delete-request?id=${id}`);
- if (res.data.code === 200) {
+ const res = await api.post('/request/delete', { id });
+ if (res.data?.success) {
// Optimistic update
setPermits(prevPermits => prevPermits.filter(p => p.id !== id));
alert.showAlert('success', 'Richiesta eliminata', 'La richiesta è stata eliminata con successo.');
} else {
- alert.showAlert('error', 'Errore', 'Impossibile eliminare la richiesta.');
+ alert.showAlert('error', 'Errore', res.data?.message || 'Impossibile eliminare la richiesta.');
}
// Refresh
fetchPermits();
diff --git a/components/MachineCard.tsx b/components/MachineCard.tsx
index 0029307..6239b23 100644
--- a/components/MachineCard.tsx
+++ b/components/MachineCard.tsx
@@ -1,14 +1,13 @@
-import { AlertTriangle, Car, KeySquare } from 'lucide-react-native';
+import { Car } from 'lucide-react-native';
import React from 'react';
-import { Text, View, TouchableOpacity } from 'react-native';
+import { Text, View } from 'react-native';
import { MachineAttendanceItem } from '@/types/types';
interface MachineCardProps {
item: MachineAttendanceItem;
- onExitPress: (item: MachineAttendanceItem) => void;
}
-export default function MachineCard({ item, onExitPress }: MachineCardProps) {
+export default function MachineCard({ item }: MachineCardProps) {
return (
@@ -34,23 +33,15 @@ export default function MachineCard({ item, onExitPress }: MachineCardProps) {
+ {/* The exit is registered automatically at check-in; older records
+ created before that change may still have no exit */}
{item.out ? (
Uscita: {item.out}
- ) : (
-
- onExitPress(item)}
- className="bg-red-50 px-4 py-2 rounded-full border border-red-200 flex-row items-center shadow-sm active:bg-red-100"
- >
-
- Registra Uscita
-
-
- )}
+ ) : null}
);