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,20 +578,6 @@ export default function OrdersScreen() {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<View style={styles.refreshRow}>
<TouchableOpacity
style={styles.refreshBtn}
onPress={onRefresh}
disabled={refreshing}
>
<Ionicons
name="refresh-outline"
size={16}
color={refreshing ? colors.textMuted : colors.accent}
/>
<Text style={styles.refreshBtnText}>Actualiser</Text>
</TouchableOpacity>
</View>
<FlatList <FlatList
data={commands} data={commands}
keyExtractor={(item) => item.id.toString()} keyExtractor={(item) => item.id.toString()}
@@ -604,7 +589,23 @@ export default function OrdersScreen() {
tintColor={colors.accent} tintColor={colors.accent}
/> />
} }
contentContainerStyle={{ padding: spacing.l, paddingTop: 0 }} contentContainerStyle={{ padding: spacing.l }}
ListHeaderComponent={
<View style={styles.refreshRow}>
<TouchableOpacity
style={styles.refreshBtn}
onPress={onRefresh}
disabled={refreshing}
>
<Ionicons
name="refresh-outline"
size={16}
color={refreshing ? colors.textMuted : colors.accent}
/>
<Text style={styles.refreshBtnText}>Actualiser</Text>
</TouchableOpacity>
</View>
}
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",
);
} }
} }