Reformated code to match prettier formating

This commit is contained in:
bobbert committed 2025-12-07 18:59:27 +00:00
1 parent 8929043086
commit 3035ddd5b1
8 files changed
+42 -41

No files matched your search

+10 -10
View File
@@ -1,5 +1,5 @@
import { Text } from "react-native"; import {Text} from "react-native";
import { useState } from "react"; import {useState} from "react";
import Icons from "../../UI/Icons"; import Icons from "../../UI/Icons";
import Form from "../../UI/Form"; import Form from "../../UI/Form";
import useLoad from "../../API/useLoad"; import useLoad from "../../API/useLoad";
@@ -15,7 +15,7 @@ const defaultUser = {
UserImageURL: null, UserImageURL: null,
}; };
const UserForm = ({ originalUser, onSubmit, onCancel }) => { const UserForm = ({originalUser, onSubmit, onCancel}) => {
// Initialisation ------------- // Initialisation -------------
defaultUser.UserID = Math.floor(100000 + Math.random() * 900000); defaultUser.UserID = Math.floor(100000 + Math.random() * 900000);
@@ -25,11 +25,11 @@ const UserForm = ({ originalUser, onSubmit, onCancel }) => {
const yearsEndpoint = 'https://softwarehub.uk/unibase/api/years'; const yearsEndpoint = 'https://softwarehub.uk/unibase/api/years';
const levels = [ const levels = [
{ value: 3, label: '3 (Foundation)' }, {value: 3, label: '3 (Foundation)'},
{ value: 4, label: '4 (First Year)' }, {value: 4, label: '4 (First Year)'},
{ value: 5, label: '5 (Second Year)' }, {value: 5, label: '5 (Second Year)'},
{ value: 6, label: '6 (Third Year)' }, {value: 6, label: '6 (Third Year)'},
{ value: 7, label: '7 (Masters)' }, {value: 7, label: '7 (Masters)'},
]; ];
// State ---------------------- // State ----------------------
@@ -42,7 +42,7 @@ const UserForm = ({ originalUser, onSubmit, onCancel }) => {
// Handlers ------------------- // Handlers -------------------
const handleChange = (field, value) => { const handleChange = (field, value) => {
setUser({ ...user, [field]: value }); setUser({...user, [field]: value});
}; };
const handleSubmit = () => onSubmit(user); const handleSubmit = () => onSubmit(user);
@@ -50,7 +50,7 @@ const UserForm = ({ originalUser, onSubmit, onCancel }) => {
// View ----------------------- // View -----------------------
const submitLabel = originalUser ? 'Modify' : 'Add'; const submitLabel = originalUser ? 'Modify' : 'Add';
const submitIcon = originalUser ? <Icons.Edit /> : <Icons.Add />; const submitIcon = originalUser ? <Icons.Edit/> : <Icons.Add/>;
const usertypeOptions = userTypes.map((usertype) => ({ const usertypeOptions = userTypes.map((usertype) => ({
value: usertype.UsertypeID, value: usertype.UsertypeID,
+3 -2
View File
@@ -1,7 +1,7 @@
import { StyleSheet, Text, View, Pressable } from "react-native"; import {StyleSheet, Text, View, Pressable} from "react-native";
import useLoad from "../../API/useLoad"; import useLoad from "../../API/useLoad";
const UserItem = ({ user, onSelect }) => { const UserItem = ({user, onSelect}) => {
// Initialisation ------------- // Initialisation -------------
const usertypesEndpoint = 'https://softwarehub.uk/unibase/api/usertypes'; const usertypesEndpoint = 'https://softwarehub.uk/unibase/api/usertypes';
@@ -17,6 +17,7 @@ const UserItem = ({ user, onSelect }) => {
// State ---------------------- // State ----------------------
// Handlers ------------------- // Handlers -------------------
// View ----------------------- // View -----------------------
return ( return (
<Pressable key={user.UserID} onPress={() => onSelect(user)}> <Pressable key={user.UserID} onPress={() => onSelect(user)}>
<View style={styles.userItem}> <View style={styles.userItem}>
+13 -13
View File
@@ -1,19 +1,19 @@
import { Alert, StyleSheet, Text, View } from "react-native"; import {Alert, StyleSheet, Text, View} from "react-native";
import FullWidthImage from "react-native-fullwidth-image"; import FullWidthImage from "react-native-fullwidth-image";
import { Button, ButtonTray } from "../../UI/Button"; import {Button, ButtonTray} from "../../UI/Button";
import Icons from "../../UI/Icons.js"; import Icons from "../../UI/Icons.js";
const UserView = ({ user, onDelete, onModify }) => { const UserView = ({user, onDelete, onModify}) => {
// Initialisation ------------- // Initialisation -------------
const fullName = `${user.UserFirstname} ${user.UserLastname}`; const fullName = `${user.UserFirstname} ${user.UserLastname}`;
const levels = [ const levels = [
{ value: 3, label: '3 (Foundation)' }, {value: 3, label: '3 (Foundation)'},
{ value: 4, label: '4 (First Year)' }, {value: 4, label: '4 (First Year)'},
{ value: 5, label: '5 (Second Year)' }, {value: 5, label: '5 (Second Year)'},
{ value: 6, label: '6 (Third Year)' }, {value: 6, label: '6 (Third Year)'},
{ value: 7, label: '7 (Masters)' }, {value: 7, label: '7 (Masters)'},
]; ];
// State ---------------------- // State ----------------------
@@ -26,8 +26,8 @@ const UserView = ({ user, onDelete, onModify }) => {
'Delete Warning', 'Delete Warning',
`Are you sure you want to delete user ${fullName}?`, `Are you sure you want to delete user ${fullName}?`,
[ [
{ text: 'Cancel' }, {text: 'Cancel'},
{ text: 'Delete', onPress: handleDelete } {text: 'Delete', onPress: handleDelete}
] ]
); );
}; };
@@ -38,7 +38,7 @@ const UserView = ({ user, onDelete, onModify }) => {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<FullWidthImage source={{ uri: user.UserImageURL }} style={styles.image} /> <FullWidthImage source={{uri: user.UserImageURL}} style={styles.image}/>
<View style={styles.infoTray}> <View style={styles.infoTray}>
<Text style={styles.boldText}>{fullName}</Text> <Text style={styles.boldText}>{fullName}</Text>
@@ -51,12 +51,12 @@ const UserView = ({ user, onDelete, onModify }) => {
<ButtonTray> <ButtonTray>
<Button <Button
icon={<Icons.Edit />} icon={<Icons.Edit/>}
label={"Modify"} label={"Modify"}
onClick={onModify} onClick={onModify}
/> />
<Button <Button
icon={<Icons.Delete />} icon={<Icons.Delete/>}
label={"Delete"} label={"Delete"}
onClick={requestDelete} onClick={requestDelete}
/> />
+1 -1
View File
@@ -11,7 +11,7 @@ const ModuleListScreen = ({navigation}) => {
// Initialisation ------------- // Initialisation -------------
// let modules = initialModules; // let modules = initialModules;
LogBox.ignoreLogs(['Non-serializable values were found in the navigation state']); LogBox.ignoreLogs(['Non-serializable values were found in the navigation state']);
const modulesEndpoint = 'https://softwarehub.uk/unibase/api/modules'; const modulesEndpoint = 'https://softwarehub.uk/unibase/api/modules';
// State ---------------------- // State ----------------------
+1 -1
View File
@@ -11,7 +11,7 @@ export const ModuleViewScreen = ({navigation, route}) => {
// State ---------------------- // State ----------------------
// Handlers ------------------- // Handlers -------------------
const goToModifyScreen = () => navigation.replace("ModuleModifyScreen", { module, onModify }); const goToModifyScreen = () => navigation.replace("ModuleModifyScreen", {module, onModify});
// View ----------------------- // View -----------------------
return (<Screen> return (<Screen>
+8 -8
View File
@@ -1,11 +1,11 @@
import { LogBox, Text } from "react-native"; import {LogBox, Text} from "react-native";
import Screen from "../layout/Screen"; import Screen from "../layout/Screen";
import UserList from "../entity/users/UserList"; import UserList from "../entity/users/UserList";
import { Button, ButtonTray } from "../UI/Button"; import {Button, ButtonTray} from "../UI/Button";
import Icons from "../UI/Icons"; import Icons from "../UI/Icons";
import useLoad from "../API/useLoad"; import useLoad from "../API/useLoad";
const UserListScreen = ({ navigation }) => { const UserListScreen = ({navigation}) => {
// Initialisation ------------- // Initialisation -------------
LogBox.ignoreLogs(['Non-serializable values were found in the navigation state']); LogBox.ignoreLogs(['Non-serializable values were found in the navigation state']);
@@ -36,14 +36,14 @@ const UserListScreen = ({ navigation }) => {
const onModify = (user) => { const onModify = (user) => {
handleModify(user); handleModify(user);
navigation.replace('UserViewScreen', { user, onDelete, onModify }); navigation.replace('UserViewScreen', {user, onDelete, onModify});
}; };
const goToViewScreen = (user) => const goToViewScreen = (user) =>
navigation.navigate('UserViewScreen', { user, onDelete, onModify }); navigation.navigate('UserViewScreen', {user, onDelete, onModify});
const goToAddScreen = () => const goToAddScreen = () =>
navigation.navigate('UserAddScreen', { onAdd }); navigation.navigate('UserAddScreen', {onAdd});
const handleSwitchToModules = () => { const handleSwitchToModules = () => {
navigation.navigate("ModuleListScreen"); navigation.navigate("ModuleListScreen");
@@ -53,12 +53,12 @@ const UserListScreen = ({ navigation }) => {
return ( return (
<Screen> <Screen>
<ButtonTray> <ButtonTray>
<Button label='Add' icon={<Icons.Add />} onClick={goToAddScreen} /> <Button label='Add' icon={<Icons.Add/>} onClick={goToAddScreen}/>
</ButtonTray> </ButtonTray>
{isLoading && <Text>Loading Records...</Text>} {isLoading && <Text>Loading Records...</Text>}
<UserList users={users} onSelect={goToViewScreen} /> <UserList users={users} onSelect={goToViewScreen}/>
</Screen> </Screen>
); );
}; };
+2 -2
View File
@@ -1,9 +1,9 @@
import Screen from "../layout/Screen"; import Screen from "../layout/Screen";
import UserForm from "../entity/users/UserForm"; import UserForm from "../entity/users/UserForm";
const UserModifyScreen = ({ navigation, route }) => { const UserModifyScreen = ({navigation, route}) => {
// Initialisation ------------- // Initialisation -------------
const { user, onModify } = route.params; const {user, onModify} = route.params;
// State ---------------------- // State ----------------------
// Handlers ------------------- // Handlers -------------------
+4 -4
View File
@@ -1,15 +1,15 @@
import { StyleSheet } from "react-native"; import {StyleSheet} from "react-native";
import Screen from "../layout/Screen"; import Screen from "../layout/Screen";
import UserView from "../entity/users/UserView"; import UserView from "../entity/users/UserView";
const UserViewScreen = ({ navigation, route }) => { const UserViewScreen = ({navigation, route}) => {
// Initialisation ------------- // Initialisation -------------
const { user, onDelete, onModify } = route.params; const {user, onDelete, onModify} = route.params;
// State ---------------------- // State ----------------------
// Handlers ------------------- // Handlers -------------------
const goToModifyScreen = () => navigation.replace("UserModifyScreen", { user, onModify }); const goToModifyScreen = () => navigation.replace("UserModifyScreen", {user, onModify});
// View ----------------------- // View -----------------------
return ( return (