mirror of
https://github.com/mudabbir-ahmad/Project-MAD-crudler.git
synced 2026-10-07 20:40:20 +00:00
Reformated code to match prettier formating
This commit is contained in:
1 parent
8929043086
commit
3035ddd5b1
7 files changed
+41
-40
No files matched your search
@@ -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,
|
||||||
|
|||||||
@@ -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}>
|
||||||
|
|||||||
@@ -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}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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 -------------------
|
||||||
|
|||||||
@@ -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 (
|
||||||
|
|||||||
Reference in new issue
Block a user