diff --git a/src/components/entity/users/UserForm.js b/src/components/entity/users/UserForm.js
index 37cd4f6..6c760d0 100644
--- a/src/components/entity/users/UserForm.js
+++ b/src/components/entity/users/UserForm.js
@@ -19,7 +19,7 @@ const UserForm = ({originalUser, onSubmit, onCancel}) => {
// Initialisation -------------
defaultUser.UserID = Math.floor(100000 + Math.random() * 900000);
- defaultUser.UserImageURL = 'https://images.freeimages.com/images/small-preview/cf5/cellphone-1313194.jpg';
+ defaultUser.UserImageURL = 'https://images.generated.photos/tZmcC6WnzFmgAwRMsBnGYcmaj_NSktxhYzBfTqej_Lo/rs:fit:256:256/czM6Ly9pY29uczgu/Z3Bob3Rvcy1wcm9k/LnBob3Rvcy92M18w/MDE3MjYzLmpwZw.jpg';
const userTypesEndpoint = 'https://softwarehub.uk/unibase/api/usertypes';
const yearsEndpoint = 'https://softwarehub.uk/unibase/api/years';
diff --git a/src/components/entity/users/UserView.js b/src/components/entity/users/UserView.js
index 832ad6e..2b0d671 100644
--- a/src/components/entity/users/UserView.js
+++ b/src/components/entity/users/UserView.js
@@ -2,12 +2,17 @@ import {Alert, StyleSheet, Text, View} from "react-native";
import FullWidthImage from "react-native-fullwidth-image";
import {Button, ButtonTray} from "../../UI/Button";
import Icons from "../../UI/Icons.js";
+import useLoad from "../../API/useLoad";
const UserView = ({user, onDelete, onModify}) => {
// Initialisation -------------
const fullName = `${user.UserFirstname} ${user.UserLastname}`;
+ const userTypesEndpoint = 'https://softwarehub.uk/unibase/api/usertypes';
+ const yearsEndpoint = 'https://softwarehub.uk/unibase/api/years';
+
+
const levels = [
{value: 3, label: '3 (Foundation)'},
{value: 4, label: '4 (First Year)'},
@@ -17,6 +22,10 @@ const UserView = ({user, onDelete, onModify}) => {
];
// State ----------------------
+
+ const [userTypes] = useLoad(userTypesEndpoint);
+ const [years] = useLoad(yearsEndpoint);
+
// Handlers -------------------
const handleDelete = () => onDelete(user);
@@ -34,6 +43,21 @@ const UserView = ({user, onDelete, onModify}) => {
const userLevelLabel = levels.find(level => level.value === user.UserLevel)?.label || 'Unknown Level';
+ const getUserType = (usertypeID) => {
+ if (!usertypeID) return "Unknown";
+ const usertype = userTypes.find(type => type.UsertypeID === usertypeID);
+ return usertype ? usertype.UsertypeName : usertypeID;
+ };
+
+ const getYear = (yearID) => {
+ if (!yearID) return "Unknown";
+ const year = years.find(y => y.YearID === yearID);
+ return year ? year.YearName : yearID;
+ };
+
+ const yearName = getYear(user.UserYearID);
+ const userTypeName = getUserType(user.UserUsertypeID);
+
// View -----------------------
return (
@@ -45,8 +69,9 @@ const UserView = ({user, onDelete, onModify}) => {
{user.UserEmail}
Level {userLevelLabel}
- {user.UserUsertypeName || 'Unknown Type'} (User Type)
+ {user.UserUsertypeName || userTypeName} (User Type)
+ Cohort {yearName}