updated user item to show user type name, added levels to userform so that it shows which level the user is in rather than just the id

This commit is contained in:
bobbert committed 2025-12-07 18:48:43 +00:00
1 parent a64793ffb5
commit ffc227fc88
2 files changed
+36 -8

No files matched your search

+16 -5
View File
@@ -1,16 +1,27 @@
import { StyleSheet, Text, View, Pressable } from "react-native";
import useLoad from "../../API/useLoad";
const UserItem = ({ user, onSelect }) => {
// Initialisation -------------
// State ----------------------
// Handlers -------------------
// View -----------------------
// Initialisation -------------
const usertypesEndpoint = 'https://softwarehub.uk/unibase/api/usertypes';
const [usertypes] = useLoad(usertypesEndpoint);
const getUserTypeName = (usertypeID) => {
const usertype = usertypes.find(type => type.UsertypeID === usertypeID);
return usertype ? usertype.UsertypeName : "Unknown";
};
const usertypeName = getUserTypeName(user.UserUsertypeID);
// State ----------------------
// Handlers -------------------
// View -----------------------
return (
<Pressable key={user.UserID} onPress={() => onSelect(user)}>
<View style={styles.userItem}>
<Text style={styles.text}>
{user.UserFirstname} {user.UserLastname}
{user.UserFirstname} {user.UserLastname} ({usertypeName})
</Text>
</View>
</Pressable>