Restructure with Turborepo
Run Tests on Branches / Backend Tests (push) Successful in 3m38s
Run Tests on Branches / Frontend Tests (push) Successful in 3m28s

This commit is contained in:
Antoni Nuñez Romeu
2026-07-06 15:51:53 +02:00
parent f66cafbbc3
commit 190b3d163d
277 changed files with 53253 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
import React, { useState } from 'react';
import { View, StyleSheet } from 'react-native';
import { useRouter } from 'expo-router';
import { BarcodeScanner } from '../components/BarcodeScanner';
import { searchMedicines } from '../services/medicines';
export default function ScannerScreen() {
const router = useRouter();
const [isSearching, setIsSearching] = useState(false);
const handleBarcodeScanned = async (barcode: string) => {
setIsSearching(true);
try {
const results = await searchMedicines(barcode);
if (results.length > 0) {
router.push(`/medicine/${results[0].nregistro}`);
} else {
router.push(`/medicine/${barcode}`);
}
} catch (error) {
console.error('Error searching medicine:', error);
router.push(`/medicine/${barcode}`);
} finally {
setIsSearching(false);
}
};
const handleClose = () => {
router.back();
};
return (
<View style={styles.container}>
<BarcodeScanner
onBarcodeScanned={handleBarcodeScanned}
onClose={handleClose}
/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});