chore: update
This commit is contained in:
@@ -74,13 +74,14 @@ export const resetClientPenalties = async (clientUsername: string) => {
|
|||||||
return { success: true, message: data.message };
|
return { success: true, message: data.message };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// pool: 0 = pool principal (point), 1 = pool secondaire (point_zipette), -1 = tous
|
||||||
export const resetClientPoints = async (
|
export const resetClientPoints = async (
|
||||||
clientUsername: string,
|
clientUsername: string,
|
||||||
resetCancellationsPoints: boolean = false,
|
pool: number = -1,
|
||||||
) => {
|
) => {
|
||||||
const { data } = await apiClient.post(
|
const { data } = await apiClient.post(
|
||||||
`${API}/client/${clientUsername}/point/reset`,
|
`${API}/client/${clientUsername}/point/reset`,
|
||||||
{ reset_cancellations_points: resetCancellationsPoints },
|
{ pool },
|
||||||
);
|
);
|
||||||
return { success: true, message: data.message };
|
return { success: true, message: data.message };
|
||||||
};
|
};
|
||||||
@@ -349,6 +350,8 @@ export interface PublicSettings {
|
|||||||
show_amende_score: boolean;
|
show_amende_score: boolean;
|
||||||
points_enabled: boolean;
|
points_enabled: boolean;
|
||||||
points_separated: boolean;
|
points_separated: boolean;
|
||||||
|
pool_names: string[];
|
||||||
|
pool_keys: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const registerCabinePushToken = async (
|
export const registerCabinePushToken = async (
|
||||||
@@ -399,6 +402,8 @@ export const getPublicSettings = async (): Promise<PublicSettings> => {
|
|||||||
show_amende_score: data.show_amende_score ?? true,
|
show_amende_score: data.show_amende_score ?? true,
|
||||||
points_enabled: data.points_enabled ?? true,
|
points_enabled: data.points_enabled ?? true,
|
||||||
points_separated: data.points_separated ?? true,
|
points_separated: data.points_separated ?? true,
|
||||||
|
pool_names: data.pool_names ?? [],
|
||||||
|
pool_keys: data.pool_keys ?? [],
|
||||||
};
|
};
|
||||||
} catch {
|
} catch {
|
||||||
return {
|
return {
|
||||||
@@ -406,6 +411,8 @@ export const getPublicSettings = async (): Promise<PublicSettings> => {
|
|||||||
show_amende_score: true,
|
show_amende_score: true,
|
||||||
points_enabled: true,
|
points_enabled: true,
|
||||||
points_separated: true,
|
points_separated: true,
|
||||||
|
pool_names: [],
|
||||||
|
pool_keys: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export interface ClientResponse {
|
|||||||
command: number;
|
command: number;
|
||||||
point: number;
|
point: number;
|
||||||
points_zipette: number;
|
points_zipette: number;
|
||||||
|
points_extra: Record<string, number>;
|
||||||
amende: number;
|
amende: number;
|
||||||
cancellations_count: number;
|
cancellations_count: number;
|
||||||
last_penalty_reason?: string;
|
last_penalty_reason?: string;
|
||||||
|
|||||||
@@ -965,7 +965,10 @@ export default function SettingsScreen() {
|
|||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* Gestion des types de points */}
|
{/* Gestion des types de points */}
|
||||||
<View style={{ paddingHorizontal: spacing.l, paddingBottom: spacing.m, borderTopWidth: 1, borderTopColor: colors.border, paddingTop: spacing.m }}>
|
<View
|
||||||
|
pointerEvents={settings.points_enabled ? "auto" : "none"}
|
||||||
|
style={{ paddingHorizontal: spacing.l, paddingBottom: spacing.m, borderTopWidth: 1, borderTopColor: colors.border, paddingTop: spacing.m, opacity: settings.points_enabled ? 1 : 0.4 }}
|
||||||
|
>
|
||||||
<Text style={[s.rowLabel, { marginBottom: spacing.s }]}>Types de points</Text>
|
<Text style={[s.rowLabel, { marginBottom: spacing.s }]}>Types de points</Text>
|
||||||
<Text style={[s.rowDesc, { marginBottom: spacing.m }]}>
|
<Text style={[s.rowDesc, { marginBottom: spacing.m }]}>
|
||||||
Créez vos propres types de points. Le 1er type → colonne principale, le 2e → colonne secondaire.
|
Créez vos propres types de points. Le 1er type → colonne principale, le 2e → colonne secondaire.
|
||||||
@@ -988,17 +991,15 @@ export default function SettingsScreen() {
|
|||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{pools.length < 2 && (
|
<TouchableOpacity
|
||||||
<TouchableOpacity
|
onPress={addPool}
|
||||||
onPress={addPool}
|
style={{ flexDirection: "row", alignItems: "center", gap: spacing.xs, marginTop: spacing.xs }}
|
||||||
style={{ flexDirection: "row", alignItems: "center", gap: spacing.xs, marginTop: spacing.xs }}
|
>
|
||||||
>
|
<Ionicons name="add-circle-outline" size={18} color={colors.accent} />
|
||||||
<Ionicons name="add-circle-outline" size={18} color={colors.accent} />
|
<Text style={{ fontSize: fontSize.sm, color: colors.accent, fontWeight: "600" }}>
|
||||||
<Text style={{ fontSize: fontSize.sm, color: colors.accent, fontWeight: "600" }}>
|
Ajouter un type
|
||||||
Ajouter un type
|
</Text>
|
||||||
</Text>
|
</TouchableOpacity>
|
||||||
</TouchableOpacity>
|
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ export default function UsersScreen() {
|
|||||||
show_amende_score: true,
|
show_amende_score: true,
|
||||||
points_enabled: true,
|
points_enabled: true,
|
||||||
points_separated: true,
|
points_separated: true,
|
||||||
|
pool_names: [],
|
||||||
|
pool_keys: [],
|
||||||
});
|
});
|
||||||
const [penaltyModal, setPenaltyModal] = useState<{
|
const [penaltyModal, setPenaltyModal] = useState<{
|
||||||
visible: boolean;
|
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(
|
showConfirm(
|
||||||
"Reset points",
|
`Reset ${poolName}`,
|
||||||
`Réinitialiser les points de ${username} ?`,
|
`Réinitialiser les points "${poolName}" de ${username} ?`,
|
||||||
async () => {
|
async () => {
|
||||||
try {
|
try {
|
||||||
await resetClientPoints(username);
|
await resetClientPoints(username, poolIdx);
|
||||||
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 loadData();
|
await loadData();
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
showError("Erreur", e.message);
|
showError("Erreur", e.message);
|
||||||
@@ -146,31 +136,23 @@ export default function UsersScreen() {
|
|||||||
{item.prenom} {item.nom} - {item.telephone}
|
{item.prenom} {item.nom} - {item.telephone}
|
||||||
</Text>
|
</Text>
|
||||||
<View style={styles.statsRow}>
|
<View style={styles.statsRow}>
|
||||||
{appSettings.points_enabled && (
|
{appSettings.points_enabled && appSettings.pool_names.map((name, i) => {
|
||||||
appSettings.points_separated ? (
|
let value: number;
|
||||||
<>
|
let color: string;
|
||||||
<View style={styles.stat}>
|
if (i === 0) { value = item.point; color = colors.success; }
|
||||||
<Text style={[styles.statValue, { color: colors.success }]}>
|
else if (i === 1) { value = item.points_zipette; color = colors.info; }
|
||||||
{item.point}
|
else {
|
||||||
</Text>
|
const key = appSettings.pool_keys[i] ?? "";
|
||||||
<Text style={styles.statLabel}>Points</Text>
|
value = item.points_extra?.[key] ?? 0;
|
||||||
</View>
|
color = colors.warning;
|
||||||
<View style={styles.stat}>
|
}
|
||||||
<Text style={[styles.statValue, { color: colors.info }]}>
|
return (
|
||||||
{item.points_zipette}
|
<View key={i} style={styles.stat}>
|
||||||
</Text>
|
<Text style={[styles.statValue, { color }]}>{value}</Text>
|
||||||
<Text style={styles.statLabel}>Zipette</Text>
|
<Text style={styles.statLabel}>{name}</Text>
|
||||||
</View>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<View style={styles.stat}>
|
|
||||||
<Text style={[styles.statValue, { color: colors.success }]}>
|
|
||||||
{item.point}
|
|
||||||
</Text>
|
|
||||||
<Text style={styles.statLabel}>Points</Text>
|
|
||||||
</View>
|
</View>
|
||||||
)
|
);
|
||||||
)}
|
})}
|
||||||
{appSettings.show_amende_score && (
|
{appSettings.show_amende_score && (
|
||||||
<View style={styles.stat}>
|
<View style={styles.stat}>
|
||||||
<Text style={[styles.statValue, { color: colors.warning }]}>
|
<Text style={[styles.statValue, { color: colors.warning }]}>
|
||||||
@@ -195,22 +177,15 @@ export default function UsersScreen() {
|
|||||||
variant="outline"
|
variant="outline"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{appSettings.points_enabled && (
|
{appSettings.points_enabled && appSettings.pool_names.map((name, i) => (
|
||||||
<>
|
<Button
|
||||||
<Button
|
key={i}
|
||||||
title="Reset points"
|
title={`Reset ${name}`}
|
||||||
onPress={() => handleResetPoints(item.username)}
|
onPress={() => handleResetPool(item.username, i)}
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
/>
|
/>
|
||||||
<Button
|
))}
|
||||||
title="Reset zipette"
|
|
||||||
onPress={() => handleResetZipette(item.username)}
|
|
||||||
size="sm"
|
|
||||||
variant="outline"
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user