From 987cd4489f9247cf6201a2f65836bc9db46204ce Mon Sep 17 00:00:00 2001 From: sangeetha Date: Tue, 2 Jul 2024 12:52:15 +0530 Subject: [PATCH] remove sign to auth fix invalid token --- src/containers/ExpoBare/ExpoBare.tsx | 2 +- src/reducers/license.reducer.tsx | 1 - src/screens/Settings.tsx | 14 +++++- src/screens/Teacher/TeacherAttendance.tsx | 3 +- src/screens/school/schoolUpdate.tsx | 60 +++++++++++++++-------- 5 files changed, 55 insertions(+), 25 deletions(-) diff --git a/src/containers/ExpoBare/ExpoBare.tsx b/src/containers/ExpoBare/ExpoBare.tsx index 76cd961..b400998 100644 --- a/src/containers/ExpoBare/ExpoBare.tsx +++ b/src/containers/ExpoBare/ExpoBare.tsx @@ -71,6 +71,7 @@ class ExpoBare extends React.Component { await AsyncStorage.removeItem('userInfo') await AsyncStorage.removeItem('profileInfo') // this.props.navigation.navigate('signin') + this.navigationRef.current.navigate('auth'); } } } @@ -246,7 +247,6 @@ class ExpoBare extends React.Component { const currentScreen = this.getActiveRouteName(currentState) const prevScreen = this.getActiveRouteName(prevState) if (prevScreen !== currentScreen) { - console.log(currentScreen) Analytics.logEvent(currentScreen) } }; diff --git a/src/reducers/license.reducer.tsx b/src/reducers/license.reducer.tsx index a0dc609..02e7d8b 100644 --- a/src/reducers/license.reducer.tsx +++ b/src/reducers/license.reducer.tsx @@ -18,7 +18,6 @@ const defaultState = { export const license = (state = defaultState, action: any) => { const response = action.data -console.log(action.type) switch (action.type) { case GET_LICENSE_VALIDATE: case GET_MENU_LIST: diff --git a/src/screens/Settings.tsx b/src/screens/Settings.tsx index b1a96b8..01bd4b0 100644 --- a/src/screens/Settings.tsx +++ b/src/screens/Settings.tsx @@ -8,6 +8,7 @@ import { connect } from "react-redux" import { ActionCreators } from "@actions" //NOSONAR import PropTypes from 'prop-types' import { CommonActions } from "@react-navigation/native" +import { common } from '@constants/Constants' //NOSONAR class Settings extends React.Component{ static propTypes = {}; @@ -22,7 +23,8 @@ class Settings extends React.Component{ this.token = await AsyncStorage.getItem('token') if (!this.token) { - this.props.navigation.navigate('signin') + //this.props.navigation.navigate('signin') + this.props.navigation.navigate('auth') } await Analytics.setCurrentScreen('SettingsScreen') @@ -37,7 +39,11 @@ class Settings extends React.Component{ if (this.props.info.hasOwnProperty('status')) { if (this.props.info.status && !this.props.isLoggedIn) { this.logoutUser() + }else if(this.props.info.hasOwnProperty('message') && this.props.info.message === common.invalidToken){ + this.logoutUser() } + }else if(this.props.info.hasOwnProperty('message') && this.props.info.message === common.invalidToken){ + this.logoutUser() } } @@ -61,7 +67,8 @@ class Settings extends React.Component{ await AsyncStorage.removeItem('token') await AsyncStorage.removeItem('userInfo') await AsyncStorage.removeItem('profileInfo') - this.props.initLogin() + this.props.initLogin({}) + this.props.initUserProfile({}) this.props.navigation.dispatch( CommonActions.reset({ index: 0, @@ -134,6 +141,9 @@ const mapDispatchToProps = (dispatch: any) => ({ initLogin: (user: any) => { dispatch(ActionCreators.initLoginAction({})) }, + initUserProfile: (user: any) => { + dispatch(ActionCreators.initUserProfile(user)) + }, }) Settings.propTypes = { diff --git a/src/screens/Teacher/TeacherAttendance.tsx b/src/screens/Teacher/TeacherAttendance.tsx index 6721645..e4818be 100644 --- a/src/screens/Teacher/TeacherAttendance.tsx +++ b/src/screens/Teacher/TeacherAttendance.tsx @@ -50,7 +50,8 @@ class TeacherAttendance extends React.Component{ this.getMyCurrentLocation() } else { - this.props.navigation.navigate('signin') + //this.props.navigation.navigate('signin') + this.props.navigation.navigate('auth') } } diff --git a/src/screens/school/schoolUpdate.tsx b/src/screens/school/schoolUpdate.tsx index 1315c3d..bc5beef 100644 --- a/src/screens/school/schoolUpdate.tsx +++ b/src/screens/school/schoolUpdate.tsx @@ -316,21 +316,29 @@ class SchoolUpdate extends React.Component{ return [] } - handleConfirm = (selectedDate:any,setFieldValue: any, startTimeValue: any) => { - this.setState({ startTimeShown: false }) - let startTime: any = startTimeValue - if (selectedDate) { - startTime = moment(selectedDate).format("hh:mm A") - } - this.setState({ start_time: { value: this.state.start_time.value } }) - setFieldValue('start_time', startTime) - - }; - - hideDatePicker = () => { - this.setState({ startTimeShown: false }) - }; - + handleConfirm = (selectedDate:any,setFieldValue: any, timeValue: any, key:any) => { + if(key == 'start_time'){ + let startTime: any = timeValue + if (selectedDate) { + startTime = moment(selectedDate).format("hh:mm A") + } + this.setState({ start_time: { value: this.state.start_time.value },startTimeShown: false }) + setFieldValue('start_time', startTime) + }else{ + let time: any = timeValue + if (selectedDate) { + time = moment(selectedDate).format("hh:mm A") + } + this.setState({ end_time: { value: this.state.end_time.value },endTimeShown: false }) + setFieldValue('end_time', time) + } + + }; + + hideDatePicker = () => { + this.setState({ startTimeShown: false, endTimeShown:false}) + }; + render() { let schoolInfo: any = {} @@ -340,8 +348,6 @@ class SchoolUpdate extends React.Component{ schoolInfo = this.props.info.data } } - console.log("SCL") - console.log(schoolInfo) return ( Update School Details @@ -461,7 +467,7 @@ class SchoolUpdate extends React.Component{ {this.state.startTimeShown && this.handleConfirm(date,setFieldValue,values.start_time)} + onConfirm={(date)=>this.handleConfirm(date,setFieldValue,values.start_time, 'start_time')} onCancel={this.hideDatePicker} date={this.state.start_time.value} /> @@ -474,8 +480,22 @@ class SchoolUpdate extends React.Component{ - {this.state.endTimeShown && } + {this.state.endTimeShown && + // + this.handleConfirm(date,setFieldValue,values.end_time, 'end_time')} + onCancel={this.hideDatePicker} + date={this.state.end_time.value} + /> + } {(errors.start_time && touched.start_time) && {errors.start_time}}