feat: add CSV export for approved orders && add non-delivery reason modal for livreurs
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
RefreshControl,
|
||||
ScrollView,
|
||||
TextInput,
|
||||
Share,
|
||||
} from "react-native";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
@@ -25,6 +26,7 @@ import {
|
||||
deleteCommand,
|
||||
deleteCommandItem,
|
||||
proposeAddressChangeAdmin,
|
||||
exportApprovedCommandsCSV,
|
||||
} from "../../api/api_admin";
|
||||
import type { CommandResponse } from "../../api/types";
|
||||
import type { AdminStackParamList } from "../../navigation/types";
|
||||
@@ -73,6 +75,8 @@ export default function OrdersScreen() {
|
||||
clientInfo: null,
|
||||
});
|
||||
|
||||
const [exporting, setExporting] = useState(false);
|
||||
|
||||
const loadData = useCallback(async () => {
|
||||
try {
|
||||
const result = await getAllCommands(undefined);
|
||||
@@ -83,6 +87,18 @@ export default function OrdersScreen() {
|
||||
setLoading(false);
|
||||
}, []);
|
||||
|
||||
const handleExportCSV = async () => {
|
||||
setExporting(true);
|
||||
try {
|
||||
const csv = await exportApprovedCommandsCSV();
|
||||
await Share.share({ message: csv, title: "Commandes approuvées" });
|
||||
} catch {
|
||||
showError("Erreur lors de l'export CSV");
|
||||
} finally {
|
||||
setExporting(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
loadData();
|
||||
}, [loadData]);
|
||||
@@ -238,8 +254,10 @@ export default function OrdersScreen() {
|
||||
StyleSheet.create({
|
||||
container: { flex: 1, backgroundColor: colors.bgPrimary },
|
||||
refreshRow: {
|
||||
flexDirection: "row",
|
||||
gap: spacing.s,
|
||||
paddingBottom: spacing.m,
|
||||
alignItems: "flex-start",
|
||||
alignItems: "center",
|
||||
},
|
||||
refreshBtn: {
|
||||
flexDirection: "row",
|
||||
@@ -604,6 +622,20 @@ export default function OrdersScreen() {
|
||||
/>
|
||||
<Text style={styles.refreshBtnText}>Actualiser</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity
|
||||
style={styles.refreshBtn}
|
||||
onPress={handleExportCSV}
|
||||
disabled={exporting}
|
||||
>
|
||||
<Ionicons
|
||||
name="download-outline"
|
||||
size={16}
|
||||
color={exporting ? colors.textMuted : colors.accent}
|
||||
/>
|
||||
<Text style={styles.refreshBtnText}>
|
||||
{exporting ? "Export..." : "Export CSV"}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
}
|
||||
ListEmptyComponent={
|
||||
|
||||
Reference in New Issue
Block a user