mirror of
https://github.com/mudabbir-ahmad/Project-MAD-crudler.git
synced 2026-10-07 20:40:20 +00:00
Fixed UserView to be a proper refactor of module view
This commit is contained in:
1 parent
de180ff4e2
commit
3b5285b553
1 file changed
+41
-20
@@ -1,9 +1,9 @@
|
|||||||
import { 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 Icons from "../../UI/Icons";
|
import { Button, ButtonTray } from "../../UI/Button";
|
||||||
import { ListItem } from "../../UI/List";
|
import Icons from "../../UI/Icons.js";
|
||||||
|
|
||||||
const UserItem = ({ user, onSelect }) => {
|
const UserView = ({ user, onDelete, onModify }) => {
|
||||||
// Initialisation -------------
|
// Initialisation -------------
|
||||||
|
|
||||||
const fullName = `${user.UserFirstname} ${user.UserLastname}`;
|
const fullName = `${user.UserFirstname} ${user.UserLastname}`;
|
||||||
@@ -11,38 +11,59 @@ const UserItem = ({ user, onSelect }) => {
|
|||||||
// State ----------------------
|
// State ----------------------
|
||||||
// Handlers -------------------
|
// Handlers -------------------
|
||||||
|
|
||||||
const handleSelect = () => onSelect(user);
|
const handleDelete = () => onDelete(user);
|
||||||
|
|
||||||
|
const requestDelete = () => {
|
||||||
|
Alert.alert(
|
||||||
|
'Delete Warning',
|
||||||
|
`Are you sure you want to delete user ${fullName}?`,
|
||||||
|
[
|
||||||
|
{ text: 'Cancel' },
|
||||||
|
{ text: 'Delete', onPress: handleDelete }
|
||||||
|
]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// View -----------------------
|
// View -----------------------
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ListItem onPress={handleSelect}>
|
<View style={styles.container}>
|
||||||
<FullWidthImage
|
<FullWidthImage source={{ uri: user.UserImageURL }} style={styles.image} />
|
||||||
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}>View {fullName}</Text>
|
||||||
<Text style={styles.text}>{user.UserEmail}</Text>
|
<Text style={styles.text}>{user.UserEmail}</Text>
|
||||||
|
<Text style={styles.text}>Level {user.UserLevel}</Text>
|
||||||
<Text style={styles.text}>
|
<Text style={styles.text}>
|
||||||
{user.UserUsertypeName || 'Unknown Type'}
|
{user.UserUsertypeName || 'Unknown Type'} <Text style={styles.dimText}>(User Type)</Text>
|
||||||
<Text style={styles.dimText}> (Level {user.UserLevel})</Text>
|
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<Icons.Forward />
|
<ButtonTray>
|
||||||
</ListItem>
|
<Button
|
||||||
|
icon={<Icons.Edit />}
|
||||||
|
label={"Modify"}
|
||||||
|
onClick={onModify}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
icon={<Icons.Delete />}
|
||||||
|
label={"Delete"}
|
||||||
|
onClick={requestDelete}
|
||||||
|
/>
|
||||||
|
</ButtonTray>
|
||||||
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
image: {
|
container: {
|
||||||
borderRadius: 3,
|
gap: 15,
|
||||||
},
|
},
|
||||||
infoTray: {
|
infoTray: {
|
||||||
gap: 5,
|
gap: 5,
|
||||||
flex: 1,
|
},
|
||||||
|
image: {
|
||||||
|
borderRadius: 3,
|
||||||
},
|
},
|
||||||
text: {
|
text: {
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
@@ -53,7 +74,7 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
dimText: {
|
dimText: {
|
||||||
color: "grey",
|
color: "grey",
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default UserItem;
|
export default UserView;
|
||||||
Reference in new issue
Block a user