Added useEffect to fetch and log current user and token in QRScannerScreen.
This commit is contained in:
@@ -9,6 +9,7 @@ import { scanQRCode, getQRTips } from '../api/qrCodeAPI';
|
|||||||
import SettingsScreen from './SettingsScreen';
|
import SettingsScreen from './SettingsScreen';
|
||||||
import NetInfo from '@react-native-community/netinfo';
|
import NetInfo from '@react-native-community/netinfo';
|
||||||
import { useFocusEffect } from '@react-navigation/native';
|
import { useFocusEffect } from '@react-navigation/native';
|
||||||
|
import { getCurrentUser, fetchAuthSession } from 'aws-amplify/auth';
|
||||||
|
|
||||||
const { width: screenWidth, height: screenHeight } = Dimensions.get('window');
|
const { width: screenWidth, height: screenHeight } = Dimensions.get('window');
|
||||||
|
|
||||||
@@ -28,6 +29,25 @@ const QRScannerScreen: React.FC<{ clearScanData: () => void }> = ({ clearScanDat
|
|||||||
const { hasPermission, requestPermission } = useCameraPermission();
|
const { hasPermission, requestPermission } = useCameraPermission();
|
||||||
const device = useCameraDevice('back');
|
const device = useCameraDevice('back');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchAuthData = async () => {
|
||||||
|
try {
|
||||||
|
const currentUser = await getCurrentUser();
|
||||||
|
console.log('Current user:', currentUser);
|
||||||
|
|
||||||
|
const { tokens } = await fetchAuthSession();
|
||||||
|
const test = await fetchAuthSession();
|
||||||
|
console.log('Tokens:', tokens);
|
||||||
|
console.log("AWS access token: ", tokens.accessToken.toString());
|
||||||
|
console.log("Test data: ", test);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching auth data:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchAuthData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
const fetchTips = async () => {
|
const fetchTips = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await getQRTips();
|
const response = await getQRTips();
|
||||||
@@ -83,7 +103,6 @@ const QRScannerScreen: React.FC<{ clearScanData: () => void }> = ({ clearScanDat
|
|||||||
};
|
};
|
||||||
|
|
||||||
const clearSelectedQrCodeData = () => {
|
const clearSelectedQrCodeData = () => {
|
||||||
console.log("!!!!!clearSelectedQrCodeData");
|
|
||||||
setQRCodeId(null);
|
setQRCodeId(null);
|
||||||
hideScannedDataBox();
|
hideScannedDataBox();
|
||||||
setScanned(false); // Reset the scanned state so the camera can scan again
|
setScanned(false); // Reset the scanned state so the camera can scan again
|
||||||
@@ -169,6 +188,7 @@ const QRScannerScreen: React.FC<{ clearScanData: () => void }> = ({ clearScanDat
|
|||||||
if (!device) {
|
if (!device) {
|
||||||
return <Text>Loading camera...</Text>;
|
return <Text>Loading camera...</Text>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
{/* Banner for network connectivity */}
|
{/* Banner for network connectivity */}
|
||||||
|
|||||||
Reference in New Issue
Block a user