chore: fix bug

This commit is contained in:
2026-03-17 10:38:44 +01:00
parent af74b39b22
commit c52cc280ac
2 changed files with 29 additions and 21 deletions
@@ -238,8 +238,7 @@ export default function OrdersScreen() {
StyleSheet.create({ StyleSheet.create({
container: { flex: 1, backgroundColor: colors.bgPrimary }, container: { flex: 1, backgroundColor: colors.bgPrimary },
refreshRow: { refreshRow: {
paddingHorizontal: spacing.l, paddingBottom: spacing.m,
paddingBottom: spacing.s,
alignItems: "flex-start", alignItems: "flex-start",
}, },
refreshBtn: { refreshBtn: {
@@ -579,6 +578,19 @@ export default function OrdersScreen() {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<FlatList
data={commands}
keyExtractor={(item) => item.id.toString()}
renderItem={renderOrder}
refreshControl={
<RefreshControl
refreshing={refreshing}
onRefresh={onRefresh}
tintColor={colors.accent}
/>
}
contentContainerStyle={{ padding: spacing.l }}
ListHeaderComponent={
<View style={styles.refreshRow}> <View style={styles.refreshRow}>
<TouchableOpacity <TouchableOpacity
style={styles.refreshBtn} style={styles.refreshBtn}
@@ -593,18 +605,7 @@ export default function OrdersScreen() {
<Text style={styles.refreshBtnText}>Actualiser</Text> <Text style={styles.refreshBtnText}>Actualiser</Text>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<FlatList
data={commands}
keyExtractor={(item) => item.id.toString()}
renderItem={renderOrder}
refreshControl={
<RefreshControl
refreshing={refreshing}
onRefresh={onRefresh}
tintColor={colors.accent}
/>
} }
contentContainerStyle={{ padding: spacing.l, paddingTop: 0 }}
ListEmptyComponent={ ListEmptyComponent={
<Text style={styles.empty}>Aucune commande</Text> <Text style={styles.empty}>Aucune commande</Text>
} }
+11 -4
View File
@@ -19,7 +19,9 @@ function handleRegistrationError(errorMessage: string) {
Alert.alert("Push Notification Error", errorMessage); Alert.alert("Push Notification Error", errorMessage);
} }
export async function registerForPushNotifications(): Promise<string | undefined> { export async function registerForPushNotifications(): Promise<
string | undefined
> {
if (Platform.OS === "android") { if (Platform.OS === "android") {
await Notifications.setNotificationChannelAsync("default", { await Notifications.setNotificationChannelAsync("default", {
name: "default", name: "default",
@@ -36,14 +38,17 @@ export async function registerForPushNotifications(): Promise<string | undefined
} }
if (Device.isDevice) { if (Device.isDevice) {
const { status: existingStatus } = await Notifications.getPermissionsAsync(); const { status: existingStatus } =
await Notifications.getPermissionsAsync();
let finalStatus = existingStatus; let finalStatus = existingStatus;
if (existingStatus !== "granted") { if (existingStatus !== "granted") {
const { status } = await Notifications.requestPermissionsAsync(); const { status } = await Notifications.requestPermissionsAsync();
finalStatus = status; finalStatus = status;
} }
if (finalStatus !== "granted") { if (finalStatus !== "granted") {
handleRegistrationError("Permission not granted to get push token for push notification!"); handleRegistrationError(
"Permission not granted to get push token for push notification!",
);
return; return;
} }
const projectId = const projectId =
@@ -64,6 +69,8 @@ export async function registerForPushNotifications(): Promise<string | undefined
handleRegistrationError(`${e}`); handleRegistrationError(`${e}`);
} }
} else { } else {
handleRegistrationError("Must use physical device for push notifications"); handleRegistrationError(
"Must use physical device for push notifications",
);
} }
} }