chore: fix
This commit is contained in:
@@ -3,7 +3,8 @@ import { View, Text, StyleSheet, FlatList, RefreshControl } from "react-native";
|
||||
import { spacing, fontSize } from "../../theme";
|
||||
import { useTheme } from "../../context/ThemeContext";
|
||||
import { getAllClients } from "../../api/api_admin";
|
||||
import { applyClientPenalty, resetClientPenalties, resetClientPoints } from "../../api/api_cabine";
|
||||
import { applyClientPenalty, resetClientPenalties, resetClientPoints, getPublicSettings } from "../../api/api_cabine";
|
||||
import type { PublicSettings } from "../../api/api_cabine";
|
||||
import type { ClientResponse } from "../../api/types";
|
||||
import LoadingSpinner from "../../components/ui/LoadingSpinner";
|
||||
import Card from "../../components/ui/Card";
|
||||
@@ -16,6 +17,10 @@ export default function UsersScreen() {
|
||||
const [clients, setClients] = useState<ClientResponse[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [refreshing, setRefreshing] = useState(false);
|
||||
const [appSettings, setAppSettings] = useState<PublicSettings>({
|
||||
penalties_enabled: true,
|
||||
points_enabled: true,
|
||||
});
|
||||
const [penaltyModal, setPenaltyModal] = useState<{
|
||||
visible: boolean;
|
||||
username: string;
|
||||
@@ -25,7 +30,12 @@ export default function UsersScreen() {
|
||||
|
||||
const loadData = useCallback(async () => {
|
||||
try {
|
||||
setClients(await getAllClients());
|
||||
const [clientsData, settings] = await Promise.all([
|
||||
getAllClients(),
|
||||
getPublicSettings(),
|
||||
]);
|
||||
setClients(clientsData);
|
||||
setAppSettings(settings);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
@@ -35,6 +45,7 @@ export default function UsersScreen() {
|
||||
useEffect(() => {
|
||||
loadData();
|
||||
}, [loadData]);
|
||||
|
||||
const onRefresh = async () => {
|
||||
setRefreshing(true);
|
||||
await loadData();
|
||||
@@ -115,6 +126,7 @@ export default function UsersScreen() {
|
||||
flexDirection: "row",
|
||||
gap: spacing.s,
|
||||
marginTop: spacing.m,
|
||||
flexWrap: "wrap",
|
||||
},
|
||||
empty: {
|
||||
color: colors.textMuted,
|
||||
@@ -132,24 +144,30 @@ export default function UsersScreen() {
|
||||
{item.prenom} {item.nom} - {item.telephone}
|
||||
</Text>
|
||||
<View style={styles.statsRow}>
|
||||
<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.warning }]}>
|
||||
{item.amende}
|
||||
</Text>
|
||||
<Text style={styles.statLabel}>Amendes</Text>
|
||||
</View>
|
||||
{appSettings.points_enabled && (
|
||||
<>
|
||||
<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>
|
||||
</>
|
||||
)}
|
||||
{appSettings.penalties_enabled && (
|
||||
<View style={styles.stat}>
|
||||
<Text style={[styles.statValue, { color: colors.warning }]}>
|
||||
{item.amende}
|
||||
</Text>
|
||||
<Text style={styles.statLabel}>Amendes</Text>
|
||||
</View>
|
||||
)}
|
||||
<View style={styles.stat}>
|
||||
<Text style={[styles.statValue, { color: colors.danger }]}>
|
||||
{item.cancellations_count}
|
||||
@@ -158,24 +176,30 @@ export default function UsersScreen() {
|
||||
</View>
|
||||
</View>
|
||||
<View style={styles.actions}>
|
||||
<Button
|
||||
title="Reset pénalités"
|
||||
onPress={() => handleReset(item.username)}
|
||||
size="sm"
|
||||
variant="outline"
|
||||
/>
|
||||
<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.penalties_enabled && (
|
||||
<Button
|
||||
title="Reset pénalités"
|
||||
onPress={() => handleReset(item.username)}
|
||||
size="sm"
|
||||
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"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
</Card>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user