maxdate update student and teacher

This commit is contained in:
Menaka 2024-09-03 15:37:55 +05:30
parent 7dba6d1555
commit bda8fc8bf1
4 changed files with 22 additions and 6 deletions

View File

@ -226,13 +226,16 @@ class StudentCreate extends React.Component<any, any>{
showDatePicker = () => this.setState({ isDatePickerVisible: true });
hideDatePicker = () => this.setState({ isDatePickerVisible: false });
handleConfirm = (date: any, setFieldValue: any) => {
handleConfirm = async (date: any, setFieldValue: any) => {
await this.hideDatePicker();
setFieldValue('date_of_birth', date.toISOString().split('T')[0]);
this.hideDatePicker();
};
render() {
var date = new Date();
date.setDate(date.getDate() - 1);
return (<View style={[AppStyles.containerWoPadding, {}]}>
<Text style={BaseStyles.topHeader}>Add Student</Text>
@ -368,6 +371,7 @@ class StudentCreate extends React.Component<any, any>{
mode="date"
onConfirm={(date) => this.handleConfirm(date, setFieldValue)}
onCancel={this.hideDatePicker}
maximumDate={date}
/>
<View style={[styles.container]}>

View File

@ -216,9 +216,9 @@ class StudentUpdate extends React.Component<any, any>{
showDatePicker = () => this.setState({ isDatePickerVisible: true });
hideDatePicker = () => this.setState({ isDatePickerVisible: false });
handleConfirm = (date: any, setFieldValue: any) => {
handleConfirm = async (date: any, setFieldValue: any) => {
await this.hideDatePicker();
setFieldValue('date_of_birth', date.toISOString().split('T')[0]);
this.hideDatePicker();
};
render() {
@ -234,6 +234,9 @@ class StudentUpdate extends React.Component<any, any>{
}
}
var date = new Date();
date.setDate(date.getDate() - 1);
return (<View style={[AppStyles.containerWoPadding, {}]}>
<Text style={BaseStyles.topHeader}>Update Student</Text>
@ -373,6 +376,8 @@ class StudentUpdate extends React.Component<any, any>{
mode="date"
onConfirm={(date) => this.handleConfirm(date, setFieldValue)}
onCancel={this.hideDatePicker}
date={values.date_of_birth ? new Date(values.date_of_birth) : new Date()}
maximumDate={date}
/>
<View style={[styles.container]}>

View File

@ -91,6 +91,8 @@ class TeacherCreate extends React.Component<any, any>{
};
render() {
var date = new Date();
date.setDate(date.getDate() - 1);
return (<View style={[AppStyles.containerWoPadding, {}]}>
@ -155,6 +157,7 @@ class TeacherCreate extends React.Component<any, any>{
mode="date"
onConfirm={(date) => this.handleConfirm(date, setFieldValue)}
onCancel={this.hideDatePicker}
maximumDate={date}
/>
<View style={[styles.container]}>

View File

@ -112,9 +112,11 @@ class TeacherUpdate extends React.Component<any, any>{
phoneNumber = this.props.route.params.data.phone_number
emailId = this.props.route.params.data.email_id
imageInput = this.props.route.params.data.image,
date_of_birth = this.props.route.params.data.date_of_birth
date_of_birth = this.props.info.data.date_of_birth
}
}
var date = new Date();
date.setDate(date.getDate() - 1);
return (<View style={[AppStyles.containerWoPadding, {}]}>
@ -133,7 +135,7 @@ class TeacherUpdate extends React.Component<any, any>{
phone_number: phoneNumber,
email_id: emailId,
image:imageInput,
date_of_birth: ''
date_of_birth: date_of_birth
}}
onSubmit={(values, actions) => this.onTeacherUpdate(values, actions)}
>
@ -181,6 +183,8 @@ class TeacherUpdate extends React.Component<any, any>{
mode="date"
onConfirm={(date) => this.handleConfirm(date, setFieldValue)}
onCancel={this.hideDatePicker}
date={values.date_of_birth ? new Date(values.date_of_birth) : new Date()}
maximumDate={date}
/>
<View style={[styles.container]}>