Commit f5753f42 by tungnq

TODO: Bổ sung chức năng lưu và xử lý dữ liệu cho màn hình đăng ký bù lịch dạy;…

TODO: Bổ sung chức năng lưu và xử lý dữ liệu cho màn hình đăng ký bù lịch dạy; cải thiện giao diện và hiển thị thông tin phản hồi.
parent 1a4526ca
...@@ -3,7 +3,34 @@ import {Text, View, StyleSheet} from 'react-native'; ...@@ -3,7 +3,34 @@ import {Text, View, StyleSheet} from 'react-native';
import CompensateRegisterView from './view'; import CompensateRegisterView from './view';
const CompensateRegister = props => { const CompensateRegister = props => {
const initFormData ={
numberOfPeriods: '',
makeUpDay: '',
note: '',
}
const [isShow, setShowSchedule] = useState(false); const [isShow, setShowSchedule] = useState(false);
const [isSaving, setIsSaving] = useState(false);
const [formData, setFormData] = useState(initFormData);
const handleSave = async ()=>{
//1. Validate ở đây
//2.
try {
//Gọi api ở đây
console.log('Lưu thành công:',formData);
setFormData({...initFormData});
} catch (error) {
console.log('Xảy ra lỗi',error);
}finally{
setIsSaving(false);
}
}
const onChange = key => value => {
setFormData(prev => ({ ...prev, [key]: value }));
};
const [scheduleData, setScheduleData] = useState([ const [scheduleData, setScheduleData] = useState([
{ {
...@@ -676,12 +703,21 @@ const CompensateRegister = props => { ...@@ -676,12 +703,21 @@ const CompensateRegister = props => {
}); });
}; };
const handleToggle = () => {
setShowSchedule(prev => !prev);
};
return ( return (
<CompensateRegisterView <CompensateRegisterView
isShow={isShow} isShow={isShow}
isSaving={isSaving}
formData={formData}
handleToggle={handleToggle}
setShowSchedule={setShowSchedule} setShowSchedule={setShowSchedule}
scheduleData={scheduleData} scheduleData={scheduleData}
onCheckboxChange={handleCheckboxChange} onCheckboxChange={handleCheckboxChange}
onSave={handleSave}
onChange={onChange}
/> />
); );
}; };
......
import React from 'react'; import React from 'react';
import { import {Text, View, ScrollView} from 'react-native';
Text,
View,
TouchableOpacity,
StyleSheet,
ScrollView,
} from 'react-native';
import styles from './style'; import styles from './style';
import Header from '../../../components/Header/Header'; import Header from '../../../components/Header/Header';
import TextField from '../../../components/Input/TextField'; import TextField from '../../../components/Input/TextField';
...@@ -15,7 +9,17 @@ import TextMulti from '../../../components/Input/TextMulti'; ...@@ -15,7 +9,17 @@ import TextMulti from '../../../components/Input/TextMulti';
import Button from '../../../components/Button'; import Button from '../../../components/Button';
import CheckBox from '../../../components/CheckBox'; import CheckBox from '../../../components/CheckBox';
const CompensateRegisterView = props => { const CompensateRegisterView = props => {
const {isShow, setShowSchedule, scheduleData, onCheckboxChange} = props; const {
isShow,
scheduleData,
onCheckboxChange,
handleToggle,
onSave,
onChange,
formData,
} = props;
console.log(props?.formData);
const getCheckColor = item => { const getCheckColor = item => {
if (item?.breakTime === item?.totalSession && item?.percent === '100%') { if (item?.breakTime === item?.totalSession && item?.percent === '100%') {
...@@ -24,9 +28,6 @@ const CompensateRegisterView = props => { ...@@ -24,9 +28,6 @@ const CompensateRegisterView = props => {
return R.colors.red; return R.colors.red;
}; };
const handleToggleSchedule = () => {
setShowSchedule(prevState => !prevState);
};
//Header Lịch học //Header Lịch học
const renderHeaderSchedule = () => { const renderHeaderSchedule = () => {
return ( return (
...@@ -46,77 +47,9 @@ const CompensateRegisterView = props => { ...@@ -46,77 +47,9 @@ const CompensateRegisterView = props => {
); );
}; };
//Render một dòng của bảng lịch const renderForm = () => {
const renderRow = (dayData, index) => {
return (
<View key={index} style={styles.dataRow}>
<View style={styles.dateBody}>
<Text
style={[
styles.dateText,
{textAlign: 'center', paddingHorizontal: 2},
]}>
{dayData.date}
</Text>
</View>
{dayData.periods.map((period, periodIndex) => (
<View key={periodIndex} style={styles.periodBody}>
<View
style={[
styles.periodCell,
period.available && styles.availableCell,
]}>
<CheckBox
checked={period.available}
value={period.available}
onValueChange={value =>
onCheckboxChange(index, periodIndex, value)
}
size={20}
labelStyle={styles.label}
checkedColor={R.colors.main}
tickColor={R.colors.white}
/>
<View style={{flexDirection: 'row'}}>
<Text
style={[
styles.percentText,
period.available && styles.availableText,
{color: getCheckColor(period)},
]}>
{period.percent}
</Text>
<Text
style={[
styles.codeText,
{color: getCheckColor(period), marginLeft: 3},
period.available && styles.availableText,
]}>
({period.breakTime}/{period.totalSession})
</Text>
</View>
</View>
</View>
))}
</View>
);
};
const renderSchedule = item => {
if (!isShow) return null;
return ( return (
<View style={styles.tableContainer}> <View>
{renderHeaderSchedule()}
{scheduleData.map((dayData, index) => renderRow(dayData, index))}
</View>
);
};
return (
<View style={styles.container}>
<Header title={'Đăng kí báo bù'} isBack />
<ScrollView showsVerticalScrollIndicator={false}>
<View style={styles.body}>
<View style={styles.containerInput}> <View style={styles.containerInput}>
<TextField <TextField
title={'Học kì'} title={'Học kì'}
...@@ -124,6 +57,7 @@ const CompensateRegisterView = props => { ...@@ -124,6 +57,7 @@ const CompensateRegisterView = props => {
fontSize={R.sizes.sm} fontSize={R.sizes.sm}
backgroundColor={R.colors.gray} backgroundColor={R.colors.gray}
required required
editable={false}
fontSizeTitle={R.sizes.sm} fontSizeTitle={R.sizes.sm}
containerBackgroundColor={R.colors.white} containerBackgroundColor={R.colors.white}
width={'48%'} width={'48%'}
...@@ -133,6 +67,7 @@ const CompensateRegisterView = props => { ...@@ -133,6 +67,7 @@ const CompensateRegisterView = props => {
title={'Năm học'} title={'Năm học'}
color={R.colors.black} color={R.colors.black}
fontSize={R.sizes.sm} fontSize={R.sizes.sm}
editable={false}
backgroundColor={R.colors.gray} backgroundColor={R.colors.gray}
required required
fontSizeTitle={R.sizes.sm} fontSizeTitle={R.sizes.sm}
...@@ -144,6 +79,7 @@ const CompensateRegisterView = props => { ...@@ -144,6 +79,7 @@ const CompensateRegisterView = props => {
<TextField <TextField
title={'Mã CBGV'} title={'Mã CBGV'}
color={R.colors.black} color={R.colors.black}
editable={false}
fontSize={R.sizes.sm} fontSize={R.sizes.sm}
required required
backgroundColor={R.colors.gray} backgroundColor={R.colors.gray}
...@@ -154,9 +90,7 @@ const CompensateRegisterView = props => { ...@@ -154,9 +90,7 @@ const CompensateRegisterView = props => {
</View> </View>
<View style={styles.containerDropDown}> <View style={styles.containerDropDown}>
<View style={{flexDirection: 'row'}}> <View style={{flexDirection: 'row'}}>
<Text style={[styles.txtSubtitle, {marginBottom: 5}]}> <Text style={[styles.txtSubtitle, {marginBottom: 5}]}>Mã lp </Text>
Mã lp{' '}
</Text>
<Text style={{color: R.colors.red}}>*</Text> <Text style={{color: R.colors.red}}>*</Text>
</View> </View>
<Dropdown title={'Giảng viên thay thế'} /> <Dropdown title={'Giảng viên thay thế'} />
...@@ -173,6 +107,8 @@ const CompensateRegisterView = props => { ...@@ -173,6 +107,8 @@ const CompensateRegisterView = props => {
<View style={styles.containerInput}> <View style={styles.containerInput}>
<TextField <TextField
title={'Số tiết đã nghỉ'} title={'Số tiết đã nghỉ'}
value={formData.numberOfPeriods}
onChangeText={onChange('numberOfPeriods')}
color={R.colors.black} color={R.colors.black}
fontSize={R.sizes.sm} fontSize={R.sizes.sm}
backgroundColor={R.colors.white} backgroundColor={R.colors.white}
...@@ -184,6 +120,8 @@ const CompensateRegisterView = props => { ...@@ -184,6 +120,8 @@ const CompensateRegisterView = props => {
<TextField <TextField
title={'Ngày học bù'} title={'Ngày học bù'}
color={R.colors.black} color={R.colors.black}
value={formData.makeUpDay}
onChangeText={onChange('makeUpDay')}
fontSize={R.sizes.sm} fontSize={R.sizes.sm}
backgroundColor={R.colors.white} backgroundColor={R.colors.white}
required required
...@@ -195,6 +133,8 @@ const CompensateRegisterView = props => { ...@@ -195,6 +133,8 @@ const CompensateRegisterView = props => {
<TextMulti <TextMulti
title={'Ghi chú'} title={'Ghi chú'}
color={R.colors.black} color={R.colors.black}
value={formData.note}
onChangeText={onChange('note')}
fontSize={R.sizes.sm} fontSize={R.sizes.sm}
titleFontSize={R.sizes.sm} titleFontSize={R.sizes.sm}
containerMarginBottom={15} containerMarginBottom={15}
...@@ -204,7 +144,7 @@ const CompensateRegisterView = props => { ...@@ -204,7 +144,7 @@ const CompensateRegisterView = props => {
<Button <Button
title={isShow ? 'Đóng' : 'Xem lịch rảnh SV'} title={isShow ? 'Đóng' : 'Xem lịch rảnh SV'}
textColor={R.colors.white} textColor={R.colors.white}
onPress={handleToggleSchedule} onPress={handleToggle}
backgroundColor={R.colors.blue} backgroundColor={R.colors.blue}
fontSize={R.sizes.sm} fontSize={R.sizes.sm}
fontFamily={R.fonts.fontMedium} fontFamily={R.fonts.fontMedium}
...@@ -212,24 +152,110 @@ const CompensateRegisterView = props => { ...@@ -212,24 +152,110 @@ const CompensateRegisterView = props => {
containerStyle={{paddingHorizontal: 15, borderRadius: 10}} containerStyle={{paddingHorizontal: 15, borderRadius: 10}}
/> />
</View> </View>
</View>
);
};
<ScrollView showsHorizontalScrollIndicator={false} horizontal> const renderRow = (dayData, index) => {
{renderSchedule()} return (
</ScrollView> <View key={index} style={styles.dataRow}>
<View style={styles.dateBody}>
<Text
style={[
styles.dateText,
{textAlign: 'center', paddingHorizontal: 2},
]}>
{dayData.date}
</Text>
</View>
{dayData.periods.map((period, periodIndex) => (
<View key={periodIndex} style={styles.periodBody}>
<View
style={[
styles.periodCell,
period.available && styles.availableCell,
]}>
<CheckBox
checked={period.available}
value={period.available}
onValueChange={value =>
onCheckboxChange(index, periodIndex, value)
}
size={20}
labelStyle={styles.label}
checkedColor={R.colors.main}
tickColor={R.colors.white}
/>
<View style={{flexDirection: 'row'}}>
<Text
style={[
styles.percentText,
period.available && styles.availableText,
{color: getCheckColor(period)},
]}>
{period.percent}
</Text>
<Text
style={[
styles.codeText,
{color: getCheckColor(period), marginLeft: 3},
period.available && styles.availableText,
]}>
({period.breakTime}/{period.totalSession})
</Text>
</View>
</View>
</View>
))}
</View>
);
};
const renderSchedule = item => {
if (!isShow) return null;
return (
<View style={styles.tableContainer}>
{renderHeaderSchedule()}
{scheduleData.map((dayData, index) => renderRow(dayData, index))}
</View>
);
};
const renderButton = () => {
return (
<View style={styles.btnRegister2}> <View style={styles.btnRegister2}>
<Button <Button
title={'Đăng kí dạy bù'} title={'Đăng kí dạy bù'}
backgroundColor={R.colors.blue} backgroundColor={R.colors.blue}
textColor={R.colors.white} textColor={R.colors.white}
onPress={() => {}} onPress={() => onSave(formData)}
fontSize={R.sizes.sm} fontSize={R.sizes.sm}
fontFamily={R.fonts.fontMedium} fontFamily={R.fonts.fontMedium}
height={35} height={35}
containerStyle={{paddingHorizontal: 15, borderRadius: 10}} containerStyle={{paddingHorizontal: 15, borderRadius: 10}}
/> />
</View> </View>
);
};
const renderBody = () => {
return (
<ScrollView showsVerticalScrollIndicator={false}>
<View style={styles.body}>
{renderForm()}
<ScrollView showsHorizontalScrollIndicator={false} horizontal>
{renderSchedule()}
</ScrollView>
{renderButton()}
</View> </View>
</ScrollView> </ScrollView>
);
};
return (
<View style={styles.container}>
<Header title={'Đăng kí báo bù'} isBack />
{renderBody()}
</View> </View>
); );
}; };
......
...@@ -2,8 +2,6 @@ import React from 'react'; ...@@ -2,8 +2,6 @@ import React from 'react';
import { import {
Text, Text,
View, View,
TouchableOpacity,
StyleSheet,
FlatList, FlatList,
ScrollView, ScrollView,
} from 'react-native'; } from 'react-native';
...@@ -12,7 +10,6 @@ import Header from '../../../components/Header/Header'; ...@@ -12,7 +10,6 @@ import Header from '../../../components/Header/Header';
import R from '../../../assets/R'; import R from '../../../assets/R';
const DetailFeedBackView = props => { const DetailFeedBackView = props => {
const {teacher, dataListQuestion} = props; const {teacher, dataListQuestion} = props;
console.log(props);
const renderTableRow = (item, index) => { const renderTableRow = (item, index) => {
return ( return (
...@@ -60,10 +57,9 @@ const DetailFeedBackView = props => { ...@@ -60,10 +57,9 @@ const DetailFeedBackView = props => {
); );
}; };
const renderBodyHeader = () => {
return ( return (
<View style={styles.container}> <View>
<Header title={'Đánh giá giảng dạy'} isBack />
<View style={styles.body}>
<Text style={styles.textSubTitle}> <Text style={styles.textSubTitle}>
Feedback ca sinh viên lp {teacher.class} môn {teacher.subject} đối Feedback ca sinh viên lp {teacher.class} môn {teacher.subject} đối
vi ging viên {teacher.teacher}. vi ging viên {teacher.teacher}.
...@@ -78,7 +74,12 @@ const DetailFeedBackView = props => { ...@@ -78,7 +74,12 @@ const DetailFeedBackView = props => {
vertical vertical
/> />
</View> </View>
</View>
);
};
const renderTable = () => {
return (
<ScrollView <ScrollView
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
style={styles.tableContainer}> style={styles.tableContainer}>
...@@ -110,6 +111,15 @@ const DetailFeedBackView = props => { ...@@ -110,6 +111,15 @@ const DetailFeedBackView = props => {
renderTableRow(item, index), renderTableRow(item, index),
)} )}
</ScrollView> </ScrollView>
);
};
return (
<View style={styles.container}>
<Header title={'Đánh giá giảng dạy'} isBack />
<View style={styles.body}>
{renderBodyHeader()}
{renderTable()}
</View> </View>
</View> </View>
); );
......
import React, {useState} from 'react'; import React, {useState} from 'react';
import {Text, View, StyleSheet} from 'react-native';
import FeedBackView from './view'; import FeedBackView from './view';
const FeedBack = props => { const FeedBack = props => {
......
...@@ -61,6 +61,16 @@ const styles = StyleSheet.create({ ...@@ -61,6 +61,16 @@ const styles = StyleSheet.create({
justifyContent: 'center', justifyContent: 'center',
}, },
btnRight: {}, btnRight: {},
containerEmpty: {
alignItems: 'center',
justifyContent: 'center',
},
textEmpty: {
color: R.colors.red,
fontSize: R.fontsize.fontSizeContent,
fontWeight: '600',
fontFamily: R.fonts.fontMedium,
}
}); });
export default styles; export default styles;
...@@ -15,6 +15,15 @@ import * as ScreenName from '../../routers/ScreenNames'; ...@@ -15,6 +15,15 @@ import * as ScreenName from '../../routers/ScreenNames';
const FeedBackView = props => { const FeedBackView = props => {
const {dataList, setDataList} = props; const {dataList, setDataList} = props;
const navigation = useNavigation(); const navigation = useNavigation();
const renderCard = () => {
return (
<View style={styles.card}>
<TouchableOpacity style={styles.btnCard}>
<Text style={[styles.text, {fontFamily: R.fonts.fontMedium, fontWeight: '600'}]}>Hc k 2, Năm 2025</Text>
</TouchableOpacity>
</View>
);
};
const renderItem = ({item}) => { const renderItem = ({item}) => {
return ( return (
<TouchableOpacity <TouchableOpacity
...@@ -58,16 +67,9 @@ const FeedBackView = props => { ...@@ -58,16 +67,9 @@ const FeedBackView = props => {
</TouchableOpacity> </TouchableOpacity>
); );
}; };
return (
<View style={styles.container}>
<Header title={'Đánh giá giảng dạy'} isBack />
<View style={styles.body}>
<View style={styles.card}>
<TouchableOpacity style={styles.btnCard}>
<Text style={styles.text}>Hc k 2, Năm 2025</Text>
</TouchableOpacity>
</View>
const renderList = () => {
return (
<FlatList <FlatList
data={dataList || []} data={dataList || []}
renderItem={renderItem} renderItem={renderItem}
...@@ -75,7 +77,33 @@ const FeedBackView = props => { ...@@ -75,7 +77,33 @@ const FeedBackView = props => {
vertical vertical
keyExtractor={(item, index) => `${index}`} keyExtractor={(item, index) => `${index}`}
/> />
);
};
const renderItemEmpty = () => {
return (
<View style={styles.containerEmpty}>
<Image source={R.images.icNoData} maxWidth={50} maxHeight={50} />
<Text style={styles.textEmpty}>Không có d liu</Text>
</View>
);
};
const renderBody = () => {
return (
<View style={styles.body}>
{renderCard()}
<View style={{flex: 1, justifyContent: 'center'}}>
{dataList.length === 0 ? renderItemEmpty() : renderList()}
</View>
</View> </View>
);
};
return (
<View style={styles.container}>
<Header title={'Đánh giá giảng dạy'} isBack />
{renderBody()}
</View> </View>
); );
}; };
......
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