chore: fix userscreen & change pass
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
||||
createClientByAdmin,
|
||||
createUserByAdmin,
|
||||
creditClientReferral,
|
||||
getSettings,
|
||||
} from "../../api/api_admin";
|
||||
import type { ClientResponse } from "../../api/types";
|
||||
import LoadingSpinner from "../../components/ui/LoadingSpinner";
|
||||
@@ -126,6 +127,10 @@ export default function UsersScreen() {
|
||||
const [clients, setClients] = useState<ClientResponse[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [refreshing, setRefreshing] = useState(false);
|
||||
const [poolNames, setPoolNames] = useState<string[]>([]);
|
||||
const [poolKeys, setPoolKeys] = useState<string[]>([]);
|
||||
const [pointsEnabled, setPointsEnabled] = useState(true);
|
||||
const [amendeEnabled, setAmendeEnabled] = useState(true);
|
||||
const [filter, setFilter] = useState<RoleFilter>("all");
|
||||
const [search, setSearch] = useState("");
|
||||
|
||||
@@ -174,12 +179,20 @@ export default function UsersScreen() {
|
||||
// --------------------------------------------------
|
||||
const loadData = useCallback(async () => {
|
||||
try {
|
||||
const [usersData, clientsData] = await Promise.all([
|
||||
const [usersData, clientsData, settingsRes] = await Promise.all([
|
||||
getAllUsers(),
|
||||
getAllClients(),
|
||||
getSettings(),
|
||||
]);
|
||||
setUsers(usersData);
|
||||
setClients(clientsData);
|
||||
if (settingsRes.success && settingsRes.settings) {
|
||||
const pools = settingsRes.settings.points_pools ?? [];
|
||||
setPoolNames(pools.map((p) => p.name));
|
||||
setPoolKeys(pools.map((p) => p.key));
|
||||
setPointsEnabled(settingsRes.settings.points_enabled ?? true);
|
||||
setAmendeEnabled(settingsRes.settings.show_amende_score ?? true);
|
||||
}
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
@@ -778,39 +791,36 @@ export default function UsersScreen() {
|
||||
</Text>
|
||||
<Text style={styles.statLabel}>Cmd</Text>
|
||||
</View>
|
||||
<View style={styles.stat}>
|
||||
<Text
|
||||
style={[
|
||||
styles.statValue,
|
||||
{ color: colors.success },
|
||||
]}
|
||||
>
|
||||
{item.clientData.point}
|
||||
</Text>
|
||||
<Text style={styles.statLabel}>Points</Text>
|
||||
</View>
|
||||
<View style={styles.stat}>
|
||||
<Text
|
||||
style={[
|
||||
styles.statValue,
|
||||
{ color: colors.info },
|
||||
]}
|
||||
>
|
||||
{item.clientData.points_zipette}
|
||||
</Text>
|
||||
<Text style={styles.statLabel}>Zipette</Text>
|
||||
</View>
|
||||
<View style={styles.stat}>
|
||||
<Text
|
||||
style={[
|
||||
styles.statValue,
|
||||
{ color: colors.warning },
|
||||
]}
|
||||
>
|
||||
{item.clientData.amende}
|
||||
</Text>
|
||||
<Text style={styles.statLabel}>Amendes</Text>
|
||||
</View>
|
||||
{pointsEnabled && poolNames.map((name, i) => {
|
||||
let value: number;
|
||||
let color: string;
|
||||
if (i === 0) { value = item.clientData!.point; color = colors.success; }
|
||||
else if (i === 1) { value = item.clientData!.points_zipette; color = colors.info; }
|
||||
else {
|
||||
const key = poolKeys[i] ?? "";
|
||||
value = item.clientData!.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>
|
||||
);
|
||||
})}
|
||||
{amendeEnabled && (
|
||||
<View style={styles.stat}>
|
||||
<Text
|
||||
style={[
|
||||
styles.statValue,
|
||||
{ color: colors.warning },
|
||||
]}
|
||||
>
|
||||
{item.clientData.amende}
|
||||
</Text>
|
||||
<Text style={styles.statLabel}>Amendes</Text>
|
||||
</View>
|
||||
)}
|
||||
<View style={styles.stat}>
|
||||
<Text
|
||||
style={[
|
||||
|
||||
Reference in New Issue
Block a user