This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
"expo": {
|
"expo": {
|
||||||
"name": "Milieu Nantais",
|
"name": "Milieu Nantais",
|
||||||
"slug": "frontend-client",
|
"slug": "frontend-client",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"orientation": "portrait",
|
"orientation": "portrait",
|
||||||
"icon": "./assets/icon.png",
|
"icon": "./assets/icon.png",
|
||||||
"userInterfaceStyle": "dark",
|
"userInterfaceStyle": "dark",
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
-----BEGIN CERTIFICATE-----
|
||||||
MIIC9zCCAd+gAwIBAgIJOs/S1ceI7Zq6MA0GCSqGSIb3DQEBCwUAMCUxIzAhBgNV
|
MIIC9zCCAd+gAwIBAgIJdh2LLVj8WJMXMA0GCSqGSIb3DQEBCwUAMCUxIzAhBgNV
|
||||||
BAMTGk1pbGlldSBOYW50YWlzIC8gVWJlciBTdHVwMB4XDTI2MDcxMTIwNDI1MloX
|
BAMTGk1pbGlldSBOYW50YWlzIC8gVWJlciBTdHVwMB4XDTI2MDgxNjEyMTA0OVoX
|
||||||
DTM2MDcxMTIwNDI1MlowJTEjMCEGA1UEAxMaTWlsaWV1IE5hbnRhaXMgLyBVYmVy
|
DTM2MDgxNjEyMTA0OVowJTEjMCEGA1UEAxMaTWlsaWV1IE5hbnRhaXMgLyBVYmVy
|
||||||
IFN0dXAwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQClkcj0h9gBuq9z
|
IFN0dXAwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCsUjXhTk71qOWK
|
||||||
FVT1UwhBto2sTZglO3iwsgyPWx7I7twyY+kUU57rgHzI7YGieX599xM4oGjau8r7
|
XB+9jJ9FiP6+FXrPM9fj9a/75XjTNtIfS55m35rlkz4cfZvtjW1XziyMe+86/wGM
|
||||||
PjPK1160djTuRa9bWXnYBnotaU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t7Y+e6HnOLeYNEepn
|
||||||
K0K3rYeXVYMDeJ9y2742D+MEg0Zse7xmNcde2z5aUuFlK7ORBs03FohD2U5zUqUg
|
5v8qfwOa0H3e6o2T71uCepvVLCbmIngnpF5APkDNUbGnJFpoyxrrleNboQ8CZYY4
|
||||||
jaia/wN4lIMCdJJmoPRUydbLJ8yVns9whFxXU1eGqaFf27jBdI/nPMVmO1YPsxnk
|
uEsrPBZSRlhWLMLsJQOgLiRlnAYgqxS9C3DlxpZbsvA9eIDJuPquzUOuNX1KTMQl
|
||||||
VvOiP6n1T+aZ7qaeOY9hsSmJ9FBeh3pOtRrdxmA8wBxD3zAORfLl89mjsw==
|
My9rR/pXYvwd7xuOD+crkGRL6bLW9HRq9FWKT6JWEkNSagmyGxcPv/ilgQ==
|
||||||
-----END CERTIFICATE-----
|
-----END CERTIFICATE-----
|
||||||
|
|||||||
@@ -457,6 +457,31 @@ export const respondToAddressProposal = async (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Le client corrige lui-même l'adresse de sa commande (refusé si déjà en
|
||||||
|
// livraison ou terminée, cf. UpdateOwnCommandAddress côté backend).
|
||||||
|
export const updateOwnCommandAddress = async (
|
||||||
|
commandId: number,
|
||||||
|
deliveryAddress: string,
|
||||||
|
): Promise<{ success: boolean; message: string }> => {
|
||||||
|
try {
|
||||||
|
const { data } = await apiClient.put(
|
||||||
|
`${V1}/commands/${commandId}/address`,
|
||||||
|
{ delivery_address: deliveryAddress },
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: data.message || "Adresse mise à jour",
|
||||||
|
};
|
||||||
|
} catch (error: any) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message:
|
||||||
|
error.response?.data?.error ||
|
||||||
|
"Erreur lors de la mise à jour de l'adresse",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const getOrderTracking = async (
|
export const getOrderTracking = async (
|
||||||
commandId: number,
|
commandId: number,
|
||||||
): Promise<TrackingResponse> => {
|
): Promise<TrackingResponse> => {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
confirmReception,
|
confirmReception,
|
||||||
cancelCommand,
|
cancelCommand,
|
||||||
respondToAddressProposal,
|
respondToAddressProposal,
|
||||||
|
updateOwnCommandAddress,
|
||||||
formatOrderDate,
|
formatOrderDate,
|
||||||
formatPrice,
|
formatPrice,
|
||||||
calculateOrderTotal,
|
calculateOrderTotal,
|
||||||
@@ -70,6 +71,11 @@ export default function OrderTrackingScreen() {
|
|||||||
const [cancellingId, setCancellingId] = useState<number | null>(null);
|
const [cancellingId, setCancellingId] = useState<number | null>(null);
|
||||||
const [cancelReason, setCancelReason] = useState("");
|
const [cancelReason, setCancelReason] = useState("");
|
||||||
const [cancelLoading, setCancelLoading] = useState(false);
|
const [cancelLoading, setCancelLoading] = useState(false);
|
||||||
|
const [editingAddressId, setEditingAddressId] = useState<number | null>(
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
const [newAddress, setNewAddress] = useState("");
|
||||||
|
const [editAddressLoading, setEditAddressLoading] = useState(false);
|
||||||
const [penaltyWarning, setPenaltyWarning] =
|
const [penaltyWarning, setPenaltyWarning] =
|
||||||
useState<CancelCommandResponse | null>(null);
|
useState<CancelCommandResponse | null>(null);
|
||||||
const [penaltyOrderId, setPenaltyOrderId] = useState<number | null>(null);
|
const [penaltyOrderId, setPenaltyOrderId] = useState<number | null>(null);
|
||||||
@@ -187,6 +193,25 @@ export default function OrderTrackingScreen() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleUpdateAddress = async (orderId: number) => {
|
||||||
|
setEditAddressLoading(true);
|
||||||
|
try {
|
||||||
|
const res = await updateOwnCommandAddress(orderId, newAddress);
|
||||||
|
if (res.success) {
|
||||||
|
showToast(res.message || "Adresse mise à jour", "success");
|
||||||
|
setEditingAddressId(null);
|
||||||
|
setNewAddress("");
|
||||||
|
fetchOrders();
|
||||||
|
} else {
|
||||||
|
showToast(res.message || "Erreur", "error");
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
showToast("Erreur mise à jour adresse", "error");
|
||||||
|
} finally {
|
||||||
|
setEditAddressLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const styles = useMemo(
|
const styles = useMemo(
|
||||||
() =>
|
() =>
|
||||||
StyleSheet.create({
|
StyleSheet.create({
|
||||||
@@ -407,6 +432,12 @@ export default function OrderTrackingScreen() {
|
|||||||
"assigned",
|
"assigned",
|
||||||
"en_route",
|
"en_route",
|
||||||
].includes(order.status);
|
].includes(order.status);
|
||||||
|
// Corrigeable uniquement avant la prise en charge par
|
||||||
|
// un livreur (cf. UpdateOwnCommandAddress backend).
|
||||||
|
const canEditAddress = [
|
||||||
|
"pending",
|
||||||
|
"assigned",
|
||||||
|
].includes(order.status);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
@@ -636,6 +667,23 @@ export default function OrderTrackingScreen() {
|
|||||||
size="sm"
|
size="sm"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{canEditAddress && (
|
||||||
|
<Button
|
||||||
|
title="Modifier l'adresse"
|
||||||
|
onPress={() => {
|
||||||
|
setNewAddress(
|
||||||
|
order.delivery_address ||
|
||||||
|
order.adresse ||
|
||||||
|
"",
|
||||||
|
);
|
||||||
|
setEditingAddressId(
|
||||||
|
order.id,
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{canCancel && (
|
{canCancel && (
|
||||||
<Button
|
<Button
|
||||||
title="Annuler"
|
title="Annuler"
|
||||||
@@ -767,6 +815,51 @@ export default function OrderTrackingScreen() {
|
|||||||
</View>
|
</View>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
visible={editingAddressId !== null}
|
||||||
|
onClose={() => {
|
||||||
|
setEditingAddressId(null);
|
||||||
|
setNewAddress("");
|
||||||
|
}}
|
||||||
|
title="Modifier l'adresse"
|
||||||
|
icon="location-outline"
|
||||||
|
>
|
||||||
|
<View style={styles.modalBody}>
|
||||||
|
<Text style={styles.modalText}>
|
||||||
|
Nouvelle adresse de livraison :
|
||||||
|
</Text>
|
||||||
|
<RNTextInput
|
||||||
|
style={styles.cancelInput}
|
||||||
|
placeholder="Ex: 24 Rue Docteur Brindeau, 44000 Nantes"
|
||||||
|
placeholderTextColor={colors.textMuted}
|
||||||
|
value={newAddress}
|
||||||
|
onChangeText={setNewAddress}
|
||||||
|
multiline
|
||||||
|
/>
|
||||||
|
<View style={styles.modalActions}>
|
||||||
|
<Button
|
||||||
|
title="Retour"
|
||||||
|
onPress={() => {
|
||||||
|
setEditingAddressId(null);
|
||||||
|
setNewAddress("");
|
||||||
|
}}
|
||||||
|
variant="outline"
|
||||||
|
size="md"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
title="Enregistrer"
|
||||||
|
onPress={() =>
|
||||||
|
editingAddressId &&
|
||||||
|
handleUpdateAddress(editingAddressId)
|
||||||
|
}
|
||||||
|
loading={editAddressLoading}
|
||||||
|
variant="success"
|
||||||
|
size="md"
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
visible={penaltyWarning !== null}
|
visible={penaltyWarning !== null}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user