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