Commit c5884469 by tungnq

TODO: Đã bổ sung chỉnh sửa lại filter cho cố vấn học tập

parent ffbf4592
import React, {useMemo, useState} from 'react'; import React, {useMemo, useState} from 'react';
import {Text, View, StyleSheet} from 'react-native';
import ListStudentView from './view'; import ListStudentView from './view';
const ListStudent = props => { const ListStudent = props => {
...@@ -7,12 +6,6 @@ const ListStudent = props => { ...@@ -7,12 +6,6 @@ const ListStudent = props => {
const handleSearchChange = text => { const handleSearchChange = text => {
setSearchText(text); setSearchText(text);
}; };
const filter = useMemo(() => {
if (!searchText.trim()) return dataListStudent;
return dataListStudent.filter(item =>
item.name.toLowerCase().includes(searchText.toLowerCase()),
);
}, [dataListStudent, searchText]);
const [dataListStudent, setDataListStudent] = useState([ const [dataListStudent, setDataListStudent] = useState([
{ {
...@@ -286,6 +279,12 @@ const ListStudent = props => { ...@@ -286,6 +279,12 @@ const ListStudent = props => {
tele_phone: '0978899221', tele_phone: '0978899221',
}, },
]); ]);
const filterData = dataListStudent.filter(item =>{
const matchSearch = item.name.toLowerCase().includes(searchText.toLowerCase());
return matchSearch;
})
const getStatusColor = status => { const getStatusColor = status => {
const statusColor = { const statusColor = {
'Đang học': '#4CAF50', 'Đang học': '#4CAF50',
...@@ -311,7 +310,7 @@ const ListStudent = props => { ...@@ -311,7 +310,7 @@ const ListStudent = props => {
<ListStudentView <ListStudentView
searchText={searchText} searchText={searchText}
onSearchChange={handleSearchChange} onSearchChange={handleSearchChange}
filter={dataListStudent} dataListStudent={filterData}
statusStats={statusStats} statusStats={statusStats}
/> />
); );
......
...@@ -68,8 +68,8 @@ const styles = StyleSheet.create({ ...@@ -68,8 +68,8 @@ const styles = StyleSheet.create({
}, },
studentCard: { studentCard: {
backgroundColor: R.colors.white, backgroundColor: R.colors.white,
marginVertical: 10,
borderRadius: 15, borderRadius: 15,
marginBottom: 15,
marginHorizontal: 15, marginHorizontal: 15,
padding: 15, padding: 15,
...@@ -98,6 +98,8 @@ const styles = StyleSheet.create({ ...@@ -98,6 +98,8 @@ const styles = StyleSheet.create({
height: 15, height: 15,
marginHorizontal: 5, marginHorizontal: 5,
}, },
containerList: {
},
studentInfo: { studentInfo: {
flex: 1, flex: 1,
flexDirection: 'row', flexDirection: 'row',
......
...@@ -15,8 +15,7 @@ import R from '../../../assets/R'; ...@@ -15,8 +15,7 @@ import R from '../../../assets/R';
import * as SCREENNAME from '../../../routers/ScreenNames'; import * as SCREENNAME from '../../../routers/ScreenNames';
import {useNavigation} from '@react-navigation/native'; import {useNavigation} from '@react-navigation/native';
const ListStudentView = props => { const ListStudentView = props => {
const {searchText, onSearchChange, filter, statusStats} = props; const {searchText, onSearchChange, dataListStudent, statusStats} = props;
console.log(props);
const navigate = useNavigation(); const navigate = useNavigation();
const renderSearchBox = () => { const renderSearchBox = () => {
return ( return (
...@@ -76,7 +75,6 @@ const ListStudentView = props => { ...@@ -76,7 +75,6 @@ const ListStudentView = props => {
}}> }}>
<View style={styles.studentCardContent}> <View style={styles.studentCardContent}>
<View style={styles.studentInfo}> <View style={styles.studentInfo}>
{/*Tên sinh viên*/}
<View style={styles.leftSection}> <View style={styles.leftSection}>
<Text style={styles.studentName}>{item.name}</Text> <Text style={styles.studentName}>{item.name}</Text>
{isLeftIcon && ( {isLeftIcon && (
...@@ -95,9 +93,7 @@ const ListStudentView = props => { ...@@ -95,9 +93,7 @@ const ListStudentView = props => {
)} )}
</View> </View>
<View style={styles.rightSection}> <View style={styles.rightSection}>
{/*Mã sinh viên*/}
<Text style={styles.studentName}>MSV: {item.code_student}</Text> <Text style={styles.studentName}>MSV: {item.code_student}</Text>
{/*Trạng thái*/}
<View <View
style={[ style={[
styles.statusIndicator, styles.statusIndicator,
...@@ -122,7 +118,6 @@ const ListStudentView = props => { ...@@ -122,7 +118,6 @@ const ListStudentView = props => {
</Text> </Text>
</View> </View>
<View style={styles.rightSection}> <View style={styles.rightSection}>
{/*Mã sinh viên*/}
<Text <Text
style={[ style={[
styles.studentName, styles.studentName,
...@@ -146,21 +141,33 @@ const ListStudentView = props => { ...@@ -146,21 +141,33 @@ const ListStudentView = props => {
return statusColors[status] || '#9E9E9E'; return statusColors[status] || '#9E9E9E';
}; };
const renderListStudent = () => {
return ( return (
<View style={styles.container}>
<Header title={'Danh sách sinh viên lớp ATTT2024.1'} isBack />
<View style={styles.body}>
{renderSearchBox()}
{renderListStatus()}
<FlatList <FlatList
data={filter || []} data={dataListStudent || []}
renderItem={renderStudentItem} renderItem={renderStudentItem}
vertical vertical
keyExtractor={(item, index) => `${index}`} keyExtractor={(item, index) => `${index}`}
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
contentContainerStyle={{paddingTop: 5}} containerStyle={styles.containerList}
/> />
);
};
const renderBody = () => {
return (
<View style={styles.body}>
{renderSearchBox()}
{renderListStatus()}
{renderListStudent()}
</View> </View>
);
};
return (
<View style={styles.container}>
<Header title={'Danh sách sinh viên lớp ATTT2024.1'} isBack />
{renderBody()}
</View> </View>
); );
}; };
......
...@@ -19,8 +19,7 @@ const styles = StyleSheet.create({ ...@@ -19,8 +19,7 @@ const styles = StyleSheet.create({
borderColor: R.colors.grayBorderInputTextHeader, borderColor: R.colors.grayBorderInputTextHeader,
borderRadius: 10, borderRadius: 10,
padding: 5, padding: 5,
marginTop: 15, marginVertical:10,
marginBottom: 15,
marginHorizontal: 15, marginHorizontal: 15,
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
...@@ -55,7 +54,6 @@ const styles = StyleSheet.create({ ...@@ -55,7 +54,6 @@ const styles = StyleSheet.create({
}, },
containerCard: { containerCard: {
padding: 10, padding: 10,
marginBottom: 15,
borderRadius: 10, borderRadius: 10,
backgroundColor: R.colors.white, backgroundColor: R.colors.white,
shadowColor: R.colors.black, shadowColor: R.colors.black,
...@@ -64,7 +62,7 @@ const styles = StyleSheet.create({ ...@@ -64,7 +62,7 @@ const styles = StyleSheet.create({
shadowRadius: 1, shadowRadius: 1,
elevation: Platform.OS === 'ios' ? 1 : 2, elevation: Platform.OS === 'ios' ? 1 : 2,
marginHorizontal: 15, marginHorizontal: 15,
marginVertical: 15, marginVertical: 10,
}, },
containerEmpty: { containerEmpty: {
alignItems: 'center', alignItems: 'center',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment