Created
August 5, 2019 07:42
-
-
Save mdshadman/5b6480337928ecc7c2bb3a2ea96db8b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import { Container, Content, Text, Button, Header, Left, Body, Right, Icon, Form, Item, Input, Card, ListItem, CardItem, Thumbnail, Label, Toast } from 'native-base'; | |
import { Switch } from 'react-native'; | |
import CameraGallery from '../CameraGallery/CameraGallery'; | |
import firebase from 'react-native-firebase'; | |
import SpinnerComponent from '../../src/screens/Loader/LoaderView'; | |
class ModalContainer extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
togVal: true, | |
imageUrl: 'https://scontent-sin2-1.xx.fbcdn.net/v/t1.0-1/c0.0.240.240a/p240x240/65822324_2111355985637711_2881848018242371584_n.jpg?_nc_cat=104&_nc_oc=AQljBZvYRPBQlLX4oEPTOMKK_JRfgJk1vJffBvR_PJLpGyTKeht7zk00VIEOYsbfa1U&_nc_ht=scontent-sin2-1.xx&oh=8ae0df6ebccbd58480935944dd68ac52&oe=5DD9AA1A', | |
taskStatus: null, | |
titleInput: 'Shadman', | |
imageUpload: null, | |
getData: '', | |
receiveUpdatedData: null, | |
docId: null, | |
loader: false | |
}; | |
} | |
async componentDidMount() { | |
const toUpdateData = this.props.sendUpdatedData | |
console.log('didmount called success', toUpdateData); | |
this.setState({ | |
receiveUpdatedData: toUpdateData | |
}, () => { | |
console.log('receivedData', this.state.receiveUpdatedData); | |
if (this.state.receiveUpdatedData !== null && this.state.receiveUpdatedData !== undefined) { | |
const { receiveUpdatedData } = this.state; | |
this.setState({ | |
imageUrl: receiveUpdatedData.Image, | |
togVal: receiveUpdatedData.Status, | |
titleInput: receiveUpdatedData.Title, | |
docId: receiveUpdatedData.id | |
}) | |
} | |
}) | |
} | |
createUserDatabase = () => { | |
const { userName, phoneNo, userId } = this.state | |
the_uid = userId | |
const data = { | |
name: userName, | |
contact: phoneNo, | |
} | |
firebase.firestore().doc(`users/${the_uid}`).set(data) | |
.then(() => { | |
console.log("New poll data sent!") | |
}) | |
.catch(error => console.log("Error when creating new poll.", error)); | |
} | |
deleteTask = (docId) => { | |
console.log('delete pressed') | |
firebase.firestore().doc(`tasks/${docId}`).delete().then((res) => { | |
console.log('success delete', res) | |
}).catch((err) => { | |
console.log('error delete', err) | |
}) | |
} | |
} | |
export default ModalContainer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment