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
7 files changed
+41 -40

No files matched your search

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