No Description

StateTime.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import React from "react";
  2. import firebase from "firebase";
  3. import { Component } from "react";
  4. import { TouchableWithoutFeedback, ImageBackground, Text, Button } from "react-native";
  5. import { styles } from "../../config/styles";
  6. import CustomButton from "../../components/CustomButton";
  7. export default class Time extends Component{
  8. constructor(props){
  9. super(props);
  10. this.state = {
  11. Appointment : this.props.route.params.Appointment_Date,
  12. int2_id : this.props.route.params.int_id,
  13. }
  14. this.time_assignment = this.time_assignment.bind(this);
  15. }
  16. time_assignment(desired_time, selectedTime){
  17. if(desired_time == 1){
  18. selectedTime = "8:00am-9:00am"
  19. }
  20. console.log(this.props.route.params)
  21. const user = firebase.auth().currentUser
  22. const uid = user.uid
  23. const month = this.state.Appointment.month
  24. const day = this.state.Appointment.day
  25. const _time_ = selectedTime
  26. const i_id = this.state.int2_id
  27. firebase.firestore()
  28. .collection('APPOINTMENTS')
  29. .add({
  30. i_id : i_id,
  31. uid1: uid,
  32. Month : month,
  33. Day: day,
  34. Time: _time_})
  35. this.props.navigation.navigate('Home')
  36. }
  37. render(){
  38. return(
  39. <TouchableWithoutFeedback style={styles.stdcontainer}>
  40. <ImageBackground style={styles.regcontainer} source={require('../../assets/yellow-white.jpg')}>
  41. <Text style={styles.stdcontainer}> Please select a time frame for the appointment</Text>
  42. <Button
  43. title ='Ver mapa'
  44. onPress= {() => this.props.navigation.navigate('Map')}
  45. />
  46. <CustomButton marginTop={25} title="8:00am-9:00am" onPress={() => this.time_assignment(1,)}/>
  47. </ImageBackground>
  48. </TouchableWithoutFeedback>
  49. );
  50. }
  51. }