chore: add new address
This commit is contained in:
@@ -362,6 +362,24 @@ export const confirmReception = async (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const respondToAddressProposal = async (
|
||||||
|
commandId: number,
|
||||||
|
accepted: boolean,
|
||||||
|
): Promise<{ success: boolean; message: string }> => {
|
||||||
|
try {
|
||||||
|
const { data } = await apiClient.post(
|
||||||
|
`${V1}/commands/${commandId}/address/respond`,
|
||||||
|
{ accepted },
|
||||||
|
);
|
||||||
|
return { success: true, message: data.message || "Réponse enregistrée" };
|
||||||
|
} catch (error: any) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: error.response?.data?.error || "Erreur lors de la réponse",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// ============================================
|
// ============================================
|
||||||
// TRACKING
|
// TRACKING
|
||||||
// ============================================
|
// ============================================
|
||||||
|
|||||||
@@ -256,6 +256,10 @@ export interface OrderDetail {
|
|||||||
// Métadonnées
|
// Métadonnées
|
||||||
payment_method?: string;
|
payment_method?: string;
|
||||||
notes?: string;
|
notes?: string;
|
||||||
|
|
||||||
|
// Proposition de modification d'adresse
|
||||||
|
proposed_address?: string | null;
|
||||||
|
address_proposal_status?: "none" | "pending" | "accepted" | "rejected";
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
getOrderETA,
|
getOrderETA,
|
||||||
confirmReception,
|
confirmReception,
|
||||||
cancelCommand,
|
cancelCommand,
|
||||||
|
respondToAddressProposal,
|
||||||
formatOrderDate,
|
formatOrderDate,
|
||||||
formatPrice,
|
formatPrice,
|
||||||
calculateOrderTotal,
|
calculateOrderTotal,
|
||||||
@@ -267,6 +268,29 @@ export default function OrderTrackingScreen() {
|
|||||||
gap: spacing.s,
|
gap: spacing.s,
|
||||||
marginTop: spacing.l,
|
marginTop: spacing.l,
|
||||||
},
|
},
|
||||||
|
proposalBox: {
|
||||||
|
backgroundColor: colors.warning + "18",
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: colors.warning,
|
||||||
|
borderRadius: borderRadius.md,
|
||||||
|
padding: spacing.m,
|
||||||
|
marginTop: spacing.m,
|
||||||
|
},
|
||||||
|
proposalTitle: {
|
||||||
|
color: colors.warning,
|
||||||
|
fontSize: fontSize.sm,
|
||||||
|
fontWeight: fontWeight.semibold,
|
||||||
|
marginBottom: spacing.xs,
|
||||||
|
},
|
||||||
|
proposalAddress: {
|
||||||
|
color: colors.textWhite,
|
||||||
|
fontSize: fontSize.md,
|
||||||
|
marginBottom: spacing.m,
|
||||||
|
},
|
||||||
|
proposalActions: {
|
||||||
|
flexDirection: "row",
|
||||||
|
gap: spacing.s,
|
||||||
|
},
|
||||||
modalBody: { gap: spacing.m },
|
modalBody: { gap: spacing.m },
|
||||||
modalText: {
|
modalText: {
|
||||||
color: colors.textPrimary,
|
color: colors.textPrimary,
|
||||||
@@ -360,9 +384,7 @@ export default function OrderTrackingScreen() {
|
|||||||
const progress = STATUS_PROGRESS[order.status] || 0;
|
const progress = STATUS_PROGRESS[order.status] || 0;
|
||||||
const track = tracking[order.id];
|
const track = tracking[order.id];
|
||||||
const eta = etas[order.id];
|
const eta = etas[order.id];
|
||||||
const canConfirm = ["livre", "arrived"].includes(
|
const canConfirm = order.status === "livre";
|
||||||
order.status,
|
|
||||||
);
|
|
||||||
const canCancel = [
|
const canCancel = [
|
||||||
"pending",
|
"pending",
|
||||||
"assigned",
|
"assigned",
|
||||||
@@ -431,6 +453,46 @@ export default function OrderTrackingScreen() {
|
|||||||
color={colors.textMuted}
|
color={colors.textMuted}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
{order.address_proposal_status === "pending" && order.proposed_address && (
|
||||||
|
<View style={styles.proposalBox}>
|
||||||
|
<Text style={styles.proposalTitle}>
|
||||||
|
📍 Nouvelle adresse proposée
|
||||||
|
</Text>
|
||||||
|
<Text style={styles.proposalAddress}>
|
||||||
|
{order.proposed_address}
|
||||||
|
</Text>
|
||||||
|
<View style={styles.proposalActions}>
|
||||||
|
<Button
|
||||||
|
title="Accepter"
|
||||||
|
variant="success"
|
||||||
|
size="sm"
|
||||||
|
onPress={async () => {
|
||||||
|
const res = await respondToAddressProposal(order.id, true);
|
||||||
|
if (res.success) {
|
||||||
|
showToast("Adresse acceptée", "success");
|
||||||
|
fetchOrders();
|
||||||
|
} else {
|
||||||
|
showToast(res.message, "error");
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
title="Refuser"
|
||||||
|
variant="danger"
|
||||||
|
size="sm"
|
||||||
|
onPress={async () => {
|
||||||
|
const res = await respondToAddressProposal(order.id, false);
|
||||||
|
if (res.success) {
|
||||||
|
showToast("Adresse refusée", "info");
|
||||||
|
fetchOrders();
|
||||||
|
} else {
|
||||||
|
showToast(res.message, "error");
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
{expanded && (
|
{expanded && (
|
||||||
<View style={styles.expandedSection}>
|
<View style={styles.expandedSection}>
|
||||||
{track?.livreur_username && (
|
{track?.livreur_username && (
|
||||||
|
|||||||
Reference in New Issue
Block a user