diff --git a/android/build.gradle b/android/build.gradle index 6534e681ff9860149bd7e010bf642d8c26d09e6c..dbc395c6eb17fc39f06bd30e13e1fb32a9c11245 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -6,6 +6,7 @@ buildscript { minSdkVersion = 21 compileSdkVersion = 30 targetSdkVersion = 30 + googlePlayServicesAuthVersion="17.0.0" } repositories { google() @@ -13,6 +14,7 @@ buildscript { } dependencies { classpath('com.android.tools.build:gradle:4.2.0') + classpath 'com.google.gms:google-services:4.3.10' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/android/settings.gradle b/android/settings.gradle index a5d32f96c7b306363bdc105f5965b3404216f24e..dbddb3d88214326cf3d9c68db142a23c21a85e21 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,4 +1,5 @@ rootProject.name = 'Agile' +include ':react-native-google_signin',':app' include ':react-native-onesignal' project(':react-native-onesignal').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-onesignal/android') include ':react-native-svg' diff --git a/package-lock.json b/package-lock.json index 89a8187f2f9e5c8f38d3b6d7ccd5bb142fb71995..8c25fa6c065b029e52320e9054f35913ae8ce7ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3160,6 +3160,11 @@ "integrity": "sha512-W/J0fNYVO01tioHjvYWQ9m6RgndVtbElzYozBq1ZPrHO/iCzlqoySHl4gO/fpCl9QEFjvJfjPgtPMTMlsoq5DQ==", "dev": true }, + "@react-native-community/google-signin": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@react-native-community/google-signin/-/google-signin-5.0.0.tgz", + "integrity": "sha512-MvFHImmtlmE1kJZgZ9XaULm/OBuQ/AQWOCPr3NzYTUv2cCqyGwfFrealo5PS/fuL/InCGcfqK1k/1dZ+67Hjmg==" + }, "@react-native-community/masked-view": { "version": "0.1.11", "resolved": "https://registry.npmjs.org/@react-native-community/masked-view/-/masked-view-0.1.11.tgz", diff --git a/package.json b/package.json index cbdf82c7cc14332186459fe25c9a678ed63f15f4..af27832edb362420bbf9529d6c6ac4551aeabe40 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "dependencies": { "@react-native-community/async-storage": "^1.12.1", "@react-native-community/datetimepicker": "^5.1.0", + "@react-native-community/google-signin": "^5.0.0", "@react-native-community/masked-view": "^0.1.10", "@react-native-community/netinfo": "^5.9.10", "@ubaids/react-native-material-textfield": "^0.16.3", diff --git a/src/CommonComponents/EmployeeInfo.js b/src/CommonComponents/EmployeeInfo.js index 27695aa2cecfae54d4bf9b7c3442ab3edeb23d55..d03abcbc92c698bddcc3c79334a96ee1f14972c5 100644 --- a/src/CommonComponents/EmployeeInfo.js +++ b/src/CommonComponents/EmployeeInfo.js @@ -297,7 +297,7 @@ export default class EmployeeInfo extends Component { <View style={{ paddingLeft: 20 ,flexDirection:'row'}}> <TouchableOpacity onPress={() => this.props.navigation.navigate('ManageProjects', { empId: this.props.navigation.state.params.empId, emp_role: this.props.navigation.state.params.role })}> {/* <ImageBackground style={{ width: wp('40%'), height: hp('22%'), margin: 10, backgroundColor:'#DCD9D9'}} > */} - <ImageBackground style={{ width: wp('40%'), height: hp('22%'), margin: 10, backgroundColor:'#DCD9D9'}} > + <ImageBackground style={{ width: wp('40%'), height: hp('17%'), margin: 10, backgroundColor:'#DCD9D9'}} > <Text style={{justifyContent:'center',fontWeight: 'bold', textAlign:'center',alignContent:'center',alignItems:'center',paddingTop: 50,}}>Epics</Text> <Text style={{ paddingLeft: '85%',fontWeight: 'bold', fontSize: 15 }}>{this.state.IdeaCount}</Text> @@ -307,7 +307,7 @@ export default class EmployeeInfo extends Component { </View> <View style={{ paddingRight: 40 }}> <TouchableOpacity onPress={() => this.props.navigation.navigate('EmployeeManageTask', { empId: this.props.navigation.state.params.empId, emp_role: this.props.navigation.state.params.role })}> - <ImageBackground style={{ width: wp('40%'), height: hp('22%'), margin: 10, backgroundColor:'#DCD9D9'}} > + <ImageBackground style={{ width: wp('40%'), height: hp('17%'), margin: 10, backgroundColor:'#DCD9D9'}} > <Text style={{justifyContent:'center',fontWeight: 'bold', textAlign:'center',alignContent:'center',alignItems:'center',paddingTop: 50,}}>Sprint</Text> {/* <ImageBackground source={require('../Images/maintask.png')} style={{ width: wp('40%'), height: hp('22%'), margin: 10, }} > */} @@ -321,12 +321,12 @@ export default class EmployeeInfo extends Component { </View> </View> - <View style={{ paddingTop: 20 }}> + <View style={{ paddingTop: 10 }}> <View style={{ height: hp('18%') }}> <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}> <View style={{ paddingLeft: 20 }}> <TouchableOpacity onPress={() => this.UserCheck()}> - <ImageBackground style={{ width: wp('40%'), height: hp('22%'), margin: 10, backgroundColor:'#DCD9D9'}} > + <ImageBackground style={{ width: wp('40%'), height: hp('17%'), margin: 10, backgroundColor:'#DCD9D9'}} > <Text style={{justifyContent:'center',fontWeight: 'bold', textAlign:'center',alignContent:'center',alignItems:'center',paddingTop: 50,}}>User Story</Text> {/* <ImageBackground source={require('../Images/subtask.png')} style={{ width: wp('40%'), height: hp('22%'), margin: 10, }} > */} @@ -337,7 +337,7 @@ export default class EmployeeInfo extends Component { </View> <View style={{ paddingRight: 40 }}> <TouchableOpacity onPress={() => this.props.navigation.navigate('RoadBlockInfo', { empId: this.props.navigation.state.params.empId, emp_role: this.props.navigation.state.params.role })}> - <ImageBackground style={{ width: wp('40%'), height: hp('22%'), margin: 10, backgroundColor:'#DCD9D9'}} > + <ImageBackground style={{ width: wp('40%'), height: hp('17%'), margin: 10, backgroundColor:'#DCD9D9'}} > {/* <ImageBackground source={require('../Images/roadblocks.png')} style={{ width: wp('40%'), height: hp('22%'), margin: 10, }} > */} <Text style={{justifyContent:'center',fontWeight: 'bold', textAlign:'center',alignContent:'center',alignItems:'center',paddingTop: 50,}}>RoadBlock</Text> @@ -353,13 +353,13 @@ export default class EmployeeInfo extends Component { </View> - <View style={{ paddingTop: 20 }}> + <View style={{ paddingTop: 10 }}> <View style={{ height: hp('18%') }}> <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}> <View style={{ paddingLeft: 20 ,flexDirection:'row'}}> <TouchableOpacity onPress={() => this.props.navigation.navigate('KudosPoints', { empId: this.props.navigation.state.params.empId, emp_role: this.props.navigation.state.params.role })}> {/* <ImageBackground style={{ width: wp('40%'), height: hp('22%'), margin: 10, backgroundColor:'#DCD9D9'}} > */} - <ImageBackground style={{ width: wp('40%'), height: hp('22%'), margin: 10, backgroundColor:'#DCD9D9'}} > + <ImageBackground style={{ width: wp('40%'), height: hp('17%'), margin: 10, backgroundColor:'#DCD9D9'}} > <Text style={{justifyContent:'center',fontWeight: 'bold', textAlign:'center',alignContent:'center',alignItems:'center',paddingTop: 50,}}>Kudos Points</Text> <Text style={{ paddingLeft: '85%',fontWeight: 'bold', fontSize: 15 }}>{this.state.IdeaCount}</Text> diff --git a/src/CommonComponents/ReportBug.js b/src/CommonComponents/ReportBug.js index 5b867c5c00c2379bd4ea878e32d869219d5a8283..aaf41449664e354aae55237cf1a42a52373dd1fb 100644 --- a/src/CommonComponents/ReportBug.js +++ b/src/CommonComponents/ReportBug.js @@ -202,12 +202,12 @@ export default class ReportBug extends Component { } else if (bug_one_sen.length === 0) { log("Warn", "Bug should not be empty"); - // alert("Enter Bug Report"); + alert("Enter Bug Report"); } else if (steps_for_bug.length === 0) { log("Warn", "Steps should not be empty"); - // alert("Enter Steps of Bugs"); + alert("Enter Steps of Bugs"); } // else if (mobile.length === 0) { @@ -261,8 +261,8 @@ export default class ReportBug extends Component { justifyContent: 'space-between', }}> <Left> - <Icon name="menu" size={25} style={{ color: '#fff' }} onPress={() => - this.props.navigation.toggleDrawer()} /> + <Icon size={25} name="arrow-left" style={{ color: '#fff' }} onPress={() => + this.props.navigation.goBack(null)} /> </Left> <Body> <Title style={{ color: '#fff', fontWeight: '600' }}>Report Support</Title> diff --git a/src/LaunchScreens/Login.js b/src/LaunchScreens/Login.js index 4708090814825a3c6545749b78eff5f4aaa6b059..447024764a47cfe0b6af82925f9368bdc29f576f 100644 --- a/src/LaunchScreens/Login.js +++ b/src/LaunchScreens/Login.js @@ -16,7 +16,6 @@ import NetInfo from '@react-native-community/netinfo'; import Snackbar from 'react-native-snackbar'; import jwt_decode from "jwt-decode"; - import { BallIndicator, BarIndicator, @@ -30,6 +29,18 @@ import { import UserDatabase from '../OfflineDB/UserDatabase'; const db = new UserDatabase(); import RadioButtonRN from 'radio-buttons-react-native'; + +import { + GoogleSignin, + GoogleSigninButton, + statusCodes, +} from '@react-native-community/google-signin'; +GoogleSignin.configure({ + webClientId: '60924326009-0tek064dualdlt2t0remkrlh49mtqlt4.apps.googleusercontent.com', + offlineAccess: true, // if you want to access Google API on behalf +}); + + export default class Login extends Component { constructor(props) { @@ -42,7 +53,9 @@ export default class Login extends Component { showPass: true, press: false, usertype: '', - action: '' + action: '', + userGoogleInfo: {}, + loaded: false }; } @@ -59,8 +72,42 @@ export default class Login extends Component { componentDidMount() { // db.initDB(); log("Debug", "Login Screen is Loaded"); + console.log("User Details") + this.signOut(); } + signOut = async () => { + try { + await GoogleSignin.signOut(); + this.setState({ user: null }); // Remember to remove the user from your app's state as well + } catch (error) { + console.error(error); + } + }; + signIn = async () => { + try { + console.log("asdsad"); + await GoogleSignin.hasPlayServices(); + const userInfo = await GoogleSignin.signIn(); + this.setState({ + userGoogleInfo: userInfo, + loaded: true + }) + this.onSignIn2(this.state.userGoogleInfo) + console.log("data getted"+this.state.userGoogleInfo); + } catch (error) { + if (error.code === statusCodes.SIGN_IN_CANCELLED) { + console.log("e 1"); + } else if (error.code === statusCodes.IN_PROGRESS) { + console.log("e 2"); + } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) { + console.log("e 3"); + } else { + console.log(error.message); + } + } + }; + //Checking for Validation isValid() { @@ -104,30 +151,152 @@ export default class Login extends Component { // alert("Relogin Again") // } // else{ - AsyncStorage.getItem("userToken", (err, res) => { - const empId = res; - AsyncStorage.getItem("userId", (err, res) => { - const userId = res; - log("Info", " addSubTask() is used to add sub task"); + AsyncStorage.getItem("userToken", (err, res) => { + const empId = res; + AsyncStorage.getItem("userId", (err, res) => { + const userId = res; + log("Info", " addSubTask() is used to add sub task"); // alert("deviceid" + userId) if (userId === null) { alert("Your Device Id is not detected. \n Please relaunch app and Try again...") this.setState({ - + username: '', password: '' - }) - - + }) + + } - else{ + else { this.onSignIn() } }) }) - } + } + + //User or Admin Login + onSignIn2(userGoogleInfo) { + // alert(JSON.stringify(userGoogleInfo)) + // alert(API) + log("Info", "onSignIn1() is used for login purpose and based on usertype data is authorizised"); + + + // console.log(username + "" + password); + fetch(API + 'sso_authentication.php', { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + username: userGoogleInfo.user.email, + name: userGoogleInfo.user.name, + action: 'sso_sign_in', + // crop: cropcode, + // utype: usertype, + }) + }).then((response) => response.json()) + .then((responseJson) => { + console.log(JSON.stringify(responseJson)); + // alert(JSON.stringify(responseJson)) + + // if (responseJson.status === 'TRUE') { + // AsyncStorage.setItem('auth', responseJson.jwt) //store the token information with exp + // const tokenDetails = jwt_decode(responseJson.jwt); + // console.log(tokenDetails.data) + // AsyncStorage.setItem('roleCount', tokenDetails.data.roleCount) + // // dispatch(setCurrentUser(tokenDetails.data)); //store the user information + // AsyncStorage.setItem('status', tokenDetails.data.empStatus) + + + // AsyncStorage.setItem('userToken', tokenDetails.data.empId); + // AsyncStorage.setItem('userName', tokenDetails.data.userName); + // AsyncStorage.setItem('emp_role', tokenDetails.data.role); + // AsyncStorage.setItem('cropcode', tokenDetails.data.corp); + // AsyncStorage.setItem('fullName', tokenDetails.data.fullName); + // AsyncStorage.setItem('projectId', tokenDetails.data.projectId); + + // this.props.navigation.navigate("MyTask"); + + // } + if (responseJson.status === 'TRUE') { + if (responseJson.role === "admin" || responseJson.role === "Admin") { + AsyncStorage.setItem('auth', responseJson.jwt) //store the token information with exp + const tokenDetails = jwt_decode(responseJson.jwt); + // console.log(tokenDetails.data) + AsyncStorage.setItem('roleCount', tokenDetails.data.roleCount) + // // dispatch(setCurrentUser(tokenDetails.data)); //store the user information + AsyncStorage.setItem('status', tokenDetails.data.empStatus) + + + AsyncStorage.setItem('userToken', tokenDetails.data.empId); + AsyncStorage.setItem('userName', tokenDetails.data.userName); + AsyncStorage.setItem('emp_role', tokenDetails.data.role); + AsyncStorage.setItem('cropcode', tokenDetails.data.corp); + AsyncStorage.setItem('fullName', tokenDetails.data.fullName); + AsyncStorage.setItem('projectId', tokenDetails.data.projectId); + this.testNotification(); + + this.setState({ + userGoogleInfo: '', + // loaded: true + }) + + // this.props.navigation.navigate("AdminReports"); + } + else { + AsyncStorage.setItem('auth', responseJson.jwt) //store the token information with exp + const tokenDetails = jwt_decode(responseJson.jwt); + // console.log(tokenDetails.data) + AsyncStorage.setItem('roleCount', tokenDetails.data.roleCount) + // // dispatch(setCurrentUser(tokenDetails.data)); //store the user information + AsyncStorage.setItem('status', tokenDetails.data.empStatus) + + + AsyncStorage.setItem('userToken', tokenDetails.data.empId); + AsyncStorage.setItem('userName', tokenDetails.data.userName); + AsyncStorage.setItem('emp_role', tokenDetails.data.role); + AsyncStorage.setItem('cropcode', tokenDetails.data.corp); + AsyncStorage.setItem('fullName', tokenDetails.data.fullName); + AsyncStorage.setItem('projectId', tokenDetails.data.projectId); + this.testNotification1() + this.setState({ + userGoogleInfo: '', + // loaded: true + }) + // this.props.navigation.navigate("MyTask"); + } + } + + else if (responseJson.status === "False") { + AsyncStorage.setItem('roleCount', tokenDetails.data.roleCount) + AsyncStorage.setItem('empId', tokenDetails.data.empId) //store the token information with exp + AsyncStorage.setItem('user', tokenDetails.data.username) //store the token information with exp + // dispatch(setCurrentUser(response)); //store the user information + // setRedirect(true) + console.warn(responseJsone) + Alert('warning', responseJsone) + // store.dispatch(isLoaded()); + } + else { + console.log(JSON.stringify(responseJson)); + alert(JSON.stringify(responseJson.message)) + // alert("Login Details are Invalid") + log("Warn", "UserName and Password is not entered correctly"); + + } + + }).catch((error) => { + console.error(error); + log("Error", "Login Error"); + }); + + + } + + //User or Admin Login onSignIn() { // alert("hello") @@ -331,60 +500,60 @@ export default class Login extends Component { // if (userId === null) { // alert("Relogin Again") // this.setState({ - + // username: '', // password: '' // }) // } // else { - NetInfo.fetch().then(state => { - if (state.type == "none") { - console.log(state.type); - log("Warn", "No internet connection"); - Snackbar.show({ - title: 'No Internet Connection', - backgroundColor: 'red', - duration: Snackbar.LENGTH_LONG, - }); - } + NetInfo.fetch().then(state => { + if (state.type == "none") { + console.log(state.type); + log("Warn", "No internet connection"); + Snackbar.show({ + title: 'No Internet Connection', + backgroundColor: 'red', + duration: Snackbar.LENGTH_LONG, + }); + } - else { - fetch(API + 'device_store.php', { - method: 'POST', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - device_id: userId, - empId: empId, - action: "store_device", + else { + fetch(API + 'device_store.php', { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + device_id: userId, + empId: empId, + action: "store_device", - }) - }).then((response) => response.json()) - .then((responseJson) => { - // alert(JSON.stringify(responseJson)); - console.log(JSON.stringify(responseJson)); - - if (responseJson.status === 'True') { - this.props.navigation.navigate("UserDashboard") - // alert("Sucess") - console.log("done") - // this.props.navigation.goBack(); - this.setState({ open: false }) - } - }).catch((error) => { - console.error(error); - log("Error", "addSubTask error"); - }); + }) + }).then((response) => response.json()) + .then((responseJson) => { + // alert(JSON.stringify(responseJson)); + console.log(JSON.stringify(responseJson)); + + if (responseJson.status === 'True') { + this.props.navigation.navigate("UserDashboard") + // alert("Sucess") + console.log("done") + // this.props.navigation.goBack(); + this.setState({ open: false }) + } + }).catch((error) => { + console.error(error); + log("Error", "addSubTask error"); + }); - } - // } - }); + } + // } + }); // } }); @@ -553,10 +722,29 @@ export default class Login extends Component { <TouchableOpacity onPress={() => this.props.navigation.navigate("ReportBug")} style={[styles.buttonContainerforgot,]}> <Text style={styles.signUpTextforgot}>Support</Text> - <Icon name="handshake-o" size={20} style={{ color: '#fff',}} /> + <Icon name="handshake-o" size={20} style={{ color: '#fff', }} /> </TouchableOpacity> - <View > - {/* <Text style={{ color: 'white' }} onPress={()=>this.props.navigation.navigate('RegisterUser')}> New User ? </Text> */} + + <View style={[styles.googlesigninstyles]}> + + <GoogleSigninButton + style={{ width: 222, height: 48 }} + size={GoogleSigninButton.Size.Wide} + color={GoogleSigninButton.Color.Dark} + onPress={this.signIn} + /> + {/* {this.state.loaded ? + <View> + <Text>{this.state.userGoogleInfo.user.name}</Text> + <Text>{this.state.userGoogleInfo.user.email}</Text> + <Image + style={{ width: 100, height: 100 }} + source={{ uri: this.state.userGoogleInfo.user.photo }} + /> + + </View> + + : <Text>Not SignedIn</Text>} */} </View> </View> @@ -655,6 +843,16 @@ const styles = StyleSheet.create({ borderRadius: 30, flexDirection: 'row', + }, + googlesigninstyles: { + height: 45, + justifyContent: 'center', + alignItems: 'center', + marginBottom: 10, + width: 290, + borderRadius: 30, + flexDirection: 'column', + }, signupButton: { backgroundColor: "#ffffff", diff --git a/src/UserComponents/UserDashboardPersonalTodo.js b/src/UserComponents/UserDashboardPersonalTodo.js index 5130b2723db1a8b75c725772236a0a1efc1a356d..0f5d379bc8f2b7926909ebcdf22d93419887c080 100644 --- a/src/UserComponents/UserDashboardPersonalTodo.js +++ b/src/UserComponents/UserDashboardPersonalTodo.js @@ -625,7 +625,8 @@ export default class UserDashboardPersonalTodo extends React.Component { if (responseJson.status === 'True') { // this.refs.toast.showCenter('Epic Squad is Deactivated', Toast.Duration.long, Toast.Position.center); console.log("done") - alert(JSON.stringify(responseJson.message)); + // alert(JSON.stringify(responseJson.message)); + alert("Sucessfully Deleted") //this.refs.toast.showBottom('Employee is Deleted'); this.getModules(); this.setState({ open: false }) diff --git a/src/UserComponents/UserGroupChat.js b/src/UserComponents/UserGroupChat.js index f397246c664d9b4d7333c229fae1e491125f3774..70db241cd7fcf5a786ffc3876ddae9ee52a20a71 100644 --- a/src/UserComponents/UserGroupChat.js +++ b/src/UserComponents/UserGroupChat.js @@ -739,6 +739,7 @@ export default class UserGroupChat extends Component { }); this.getGroupDetails(); + // this.onRefresh(); // alert("Project Changed Successfully") @@ -1194,6 +1195,7 @@ export default class UserGroupChat extends Component { componentWillReceiveProps(nextProps) { this.userApprovedProjects(); + this.getGroupDetails() } //userApprovedProjects getting userApprovedProjects() { @@ -1245,6 +1247,8 @@ export default class UserGroupChat extends Component { }, function () { }); + // this.onRefresh(); + this.getGroupDetails(); // console.warn(responseJson.taskStatus); // this.arrayholder = responseJson.data; } else { @@ -1254,7 +1258,7 @@ export default class UserGroupChat extends Component { dataSource: [], }) Snackbar.show({ - title: 'No UserApproved Projects', + title: 'No Groups Found', backgroundColor: '#3BB9FF', duration: Snackbar.LENGTH_LONG, }); diff --git a/src/UserComponents/UserSupport.js b/src/UserComponents/UserSupport.js index 5a6beda76cddf678d95d52284e9c1e10dff215d8..6452f9505963515f77195119372fcfa5289422ab 100644 --- a/src/UserComponents/UserSupport.js +++ b/src/UserComponents/UserSupport.js @@ -221,7 +221,7 @@ isValid() { else if (steps_for_bug.length === 0) { log("Warn", "Steps should not be empty"); - // alert("Enter Steps of Bugs"); + alert("Enter Steps of Bugs"); } // else if (mobile.length === 0) {