chore: add point pool

This commit is contained in:
2026-03-14 00:23:02 +01:00
parent f7be7ea5aa
commit 0523ed6356
10 changed files with 441 additions and 399 deletions
+2 -1
View File
@@ -634,6 +634,7 @@ export const getCommandItemsWithDetails = async (commandId: number) => {
export const formatOrderDate = (dateString: string): string => {
try {
const date = new Date(dateString);
if (isNaN(date.getTime())) return "";
return date.toLocaleDateString("fr-FR", {
day: "2-digit",
month: "long",
@@ -642,7 +643,7 @@ export const formatOrderDate = (dateString: string): string => {
minute: "2-digit",
});
} catch {
return dateString;
return "";
}
};
@@ -129,11 +129,12 @@ export default function OrderTrackingScreen() {
try {
const res = await confirmReception(orderId);
if (res.success) {
const cat = res.category || '';
let catLabel = '';
if (cat === 'total') catLabel = ' (Total)';
else if (cat.includes('zipette')) catLabel = ' (Zipette&Co)';
else if (cat.includes('weed') || cat.includes('hash')) catLabel = ' (Weed&Hash)';
const cat = res.category || "";
let catLabel = "";
if (cat === "total") catLabel = " (Total)";
else if (cat.includes("zipette")) catLabel = " (Zipette&Co)";
else if (cat.includes("weed") || cat.includes("hash"))
catLabel = " (Weed&Hash)";
showToast(
`Livraison confirmee ! +${res.points_earned || 0} points${catLabel}`,
"success",
@@ -456,46 +457,71 @@ export default function OrderTrackingScreen() {
color={colors.textMuted}
/>
</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");
}
}}
/>
{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>
</View>
)}
)}
{expanded && (
<View style={styles.expandedSection}>
{track?.livreur_username && (
@@ -511,23 +537,26 @@ export default function OrderTrackingScreen() {
</Text>
</View>
)}
{eta?.eta_minutes != null &&
eta.eta_minutes > 0 && (
<View style={styles.trackRow}>
<Ionicons
name="timer-outline"
size={16}
color={colors.warning}
/>
<Text
style={styles.trackText}
>
Temps de livraison
estimé : ~
{eta.eta_minutes} min
</Text>
</View>
)}
{(order.status === "en_route" ||
order.status === "arrived") && (
<View style={styles.trackRow}>
<Ionicons
name="timer-outline"
size={16}
color={colors.warning}
/>
<Text style={styles.trackText}>
Temps de livraison estimé :
~
{eta?.eta_minutes != null &&
eta.eta_minutes > 0 &&
eta.eta_minutes < 5
? eta.eta_minutes
: 5}{" "}
min
</Text>
</View>
)}
{track?.current_step && (
<View style={styles.trackRow}>
<Ionicons