chore: update

This commit is contained in:
2026-03-14 12:22:38 +01:00
parent 0523ed6356
commit 9d52f3193a
4 changed files with 58 additions and 74 deletions
@@ -22,6 +22,8 @@ export default function UsersScreen() {
show_amende_score: true,
points_enabled: true,
points_separated: true,
pool_names: [],
pool_keys: [],
});
const [penaltyModal, setPenaltyModal] = useState<{
visible: boolean;
@@ -70,29 +72,17 @@ export default function UsersScreen() {
);
};
const handleResetPoints = (username: string) => {
const handleResetPool = (username: string, poolIdx: number) => {
const poolNames = appSettings.pool_names;
const poolName = poolIdx >= 0 && poolIdx < poolNames.length
? poolNames[poolIdx]
: "tous les points";
showConfirm(
"Reset points",
`Réinitialiser les points de ${username} ?`,
`Reset ${poolName}`,
`Réinitialiser les points "${poolName}" de ${username} ?`,
async () => {
try {
await resetClientPoints(username);
await loadData();
} catch (e: any) {
showError("Erreur", e.message);
}
},
"Reset",
);
};
const handleResetZipette = (username: string) => {
showConfirm(
"Reset points zipette",
`Réinitialiser les points zipette de ${username} ?`,
async () => {
try {
await resetClientPoints(username, true);
await resetClientPoints(username, poolIdx);
await loadData();
} catch (e: any) {
showError("Erreur", e.message);
@@ -146,31 +136,23 @@ export default function UsersScreen() {
{item.prenom} {item.nom} - {item.telephone}
</Text>
<View style={styles.statsRow}>
{appSettings.points_enabled && (
appSettings.points_separated ? (
<>
<View style={styles.stat}>
<Text style={[styles.statValue, { color: colors.success }]}>
{item.point}
</Text>
<Text style={styles.statLabel}>Points</Text>
</View>
<View style={styles.stat}>
<Text style={[styles.statValue, { color: colors.info }]}>
{item.points_zipette}
</Text>
<Text style={styles.statLabel}>Zipette</Text>
</View>
</>
) : (
<View style={styles.stat}>
<Text style={[styles.statValue, { color: colors.success }]}>
{item.point}
</Text>
<Text style={styles.statLabel}>Points</Text>
{appSettings.points_enabled && appSettings.pool_names.map((name, i) => {
let value: number;
let color: string;
if (i === 0) { value = item.point; color = colors.success; }
else if (i === 1) { value = item.points_zipette; color = colors.info; }
else {
const key = appSettings.pool_keys[i] ?? "";
value = item.points_extra?.[key] ?? 0;
color = colors.warning;
}
return (
<View key={i} style={styles.stat}>
<Text style={[styles.statValue, { color }]}>{value}</Text>
<Text style={styles.statLabel}>{name}</Text>
</View>
)
)}
);
})}
{appSettings.show_amende_score && (
<View style={styles.stat}>
<Text style={[styles.statValue, { color: colors.warning }]}>
@@ -195,22 +177,15 @@ export default function UsersScreen() {
variant="outline"
/>
)}
{appSettings.points_enabled && (
<>
<Button
title="Reset points"
onPress={() => handleResetPoints(item.username)}
size="sm"
variant="outline"
/>
<Button
title="Reset zipette"
onPress={() => handleResetZipette(item.username)}
size="sm"
variant="outline"
/>
</>
)}
{appSettings.points_enabled && appSettings.pool_names.map((name, i) => (
<Button
key={i}
title={`Reset ${name}`}
onPress={() => handleResetPool(item.username, i)}
size="sm"
variant="outline"
/>
))}
</View>
</Card>
);