chore: build
This commit is contained in:
+2
-26
@@ -457,31 +457,6 @@ 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 (
|
||||
commandId: number,
|
||||
): Promise<TrackingResponse> => {
|
||||
@@ -989,6 +964,7 @@ export const toggle2FA = async (
|
||||
|
||||
export type RewardCategoryConfig = {
|
||||
category: string;
|
||||
type: "free_product" | "half_price_product";
|
||||
all_products: boolean;
|
||||
product_ids: number[];
|
||||
product_names: string[];
|
||||
@@ -1000,6 +976,7 @@ export type RewardItemConfig = {
|
||||
product_name: string;
|
||||
quantity: number;
|
||||
price: number;
|
||||
type: "free_product" | "half_price_product";
|
||||
};
|
||||
|
||||
export type PointsPoolInfo = {
|
||||
@@ -1015,7 +992,6 @@ export type PointsPoolInfo = {
|
||||
|
||||
export type PointsRewardConfig = {
|
||||
threshold: number;
|
||||
type: string;
|
||||
description: string;
|
||||
reward_items: RewardItemConfig[];
|
||||
};
|
||||
|
||||
@@ -146,7 +146,7 @@ export default function OrderHistoryScreen() {
|
||||
if (res.success) {
|
||||
const text =
|
||||
res.product_added && res.product_name
|
||||
? `🎁 ${res.product_name} ajouté à votre panier ! Commandez au moins un produit pour en profiter.`
|
||||
? `${res.product_name} ajouté à votre panier ! Commandez au moins un produit pour en profiter.`
|
||||
: res.description || "Récompense réclamée !";
|
||||
setClaimFeedback({ pool: poolKey, type: "success", text });
|
||||
getMyPointsRewards().then((r) => {
|
||||
@@ -882,16 +882,34 @@ export default function OrderHistoryScreen() {
|
||||
: `Encore ${remaining} pts pour une récompense`}
|
||||
</Text>
|
||||
{feedback && (
|
||||
<Text
|
||||
style={
|
||||
feedback.type ===
|
||||
"success"
|
||||
? styles.feedbackSuccess
|
||||
: styles.feedbackError
|
||||
}
|
||||
<View
|
||||
style={{
|
||||
flexDirection:
|
||||
"row",
|
||||
alignItems:
|
||||
"center",
|
||||
gap: 4,
|
||||
}}
|
||||
>
|
||||
{feedback.text}
|
||||
</Text>
|
||||
{feedback.type ===
|
||||
"success" && (
|
||||
<Ionicons
|
||||
name="gift-outline"
|
||||
size={12}
|
||||
color="#10b981"
|
||||
/>
|
||||
)}
|
||||
<Text
|
||||
style={
|
||||
feedback.type ===
|
||||
"success"
|
||||
? styles.feedbackSuccess
|
||||
: styles.feedbackError
|
||||
}
|
||||
>
|
||||
{feedback.text}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
{pool.rewards_available > 0 && (
|
||||
<TouchableOpacity
|
||||
@@ -1132,11 +1150,18 @@ export default function OrderHistoryScreen() {
|
||||
</Text>
|
||||
)}
|
||||
</View>
|
||||
{item.price > 0 && (
|
||||
{item.type ===
|
||||
"half_price_product" ? (
|
||||
<Text
|
||||
style={styles.pickerItemPrice}
|
||||
>
|
||||
{item.price}€
|
||||
-50% · {item.price}€
|
||||
</Text>
|
||||
) : (
|
||||
<Text
|
||||
style={styles.pickerItemPrice}
|
||||
>
|
||||
Offert
|
||||
</Text>
|
||||
)}
|
||||
<Ionicons
|
||||
|
||||
@@ -17,7 +17,6 @@ import {
|
||||
confirmReception,
|
||||
cancelCommand,
|
||||
respondToAddressProposal,
|
||||
updateOwnCommandAddress,
|
||||
formatOrderDate,
|
||||
formatPrice,
|
||||
calculateOrderTotal,
|
||||
@@ -71,11 +70,6 @@ export default function OrderTrackingScreen() {
|
||||
const [cancellingId, setCancellingId] = useState<number | null>(null);
|
||||
const [cancelReason, setCancelReason] = useState("");
|
||||
const [cancelLoading, setCancelLoading] = useState(false);
|
||||
const [editingAddressId, setEditingAddressId] = useState<number | null>(
|
||||
null,
|
||||
);
|
||||
const [newAddress, setNewAddress] = useState("");
|
||||
const [editAddressLoading, setEditAddressLoading] = useState(false);
|
||||
const [penaltyWarning, setPenaltyWarning] =
|
||||
useState<CancelCommandResponse | null>(null);
|
||||
const [penaltyOrderId, setPenaltyOrderId] = useState<number | null>(null);
|
||||
@@ -193,25 +187,6 @@ 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(
|
||||
() =>
|
||||
StyleSheet.create({
|
||||
@@ -432,12 +407,6 @@ export default function OrderTrackingScreen() {
|
||||
"assigned",
|
||||
"en_route",
|
||||
].includes(order.status);
|
||||
// Corrigeable uniquement avant la prise en charge par
|
||||
// un livreur (cf. UpdateOwnCommandAddress backend).
|
||||
const canEditAddress = [
|
||||
"pending",
|
||||
"assigned",
|
||||
].includes(order.status);
|
||||
|
||||
return (
|
||||
<TouchableOpacity
|
||||
@@ -667,23 +636,6 @@ export default function OrderTrackingScreen() {
|
||||
size="sm"
|
||||
/>
|
||||
)}
|
||||
{canEditAddress && (
|
||||
<Button
|
||||
title="Modifier l'adresse"
|
||||
onPress={() => {
|
||||
setNewAddress(
|
||||
order.delivery_address ||
|
||||
order.adresse ||
|
||||
"",
|
||||
);
|
||||
setEditingAddressId(
|
||||
order.id,
|
||||
);
|
||||
}}
|
||||
variant="outline"
|
||||
size="sm"
|
||||
/>
|
||||
)}
|
||||
{canCancel && (
|
||||
<Button
|
||||
title="Annuler"
|
||||
@@ -815,51 +767,6 @@ export default function OrderTrackingScreen() {
|
||||
</View>
|
||||
</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
|
||||
visible={penaltyWarning !== null}
|
||||
onClose={() => {
|
||||
|
||||
Reference in New Issue
Block a user