유희정

referesh

This diff is collapsed. Click to expand it.
......@@ -10,6 +10,7 @@
"lint": "eslint ."
},
"dependencies": {
"aws-sdk": "^2.589.0",
"d3": "^5.14.2",
"express": "^4.17.1",
"react": "16.9.0",
......
......@@ -5,13 +5,17 @@ import Circle from '../component/circle_component'
import {Table, TableWrapper, Row,Rows} from 'react-native-table-component'
var date = new Date();
date.setHours(date.getHours()+9);
var month = date.getMonth()+1;
if(month == 11){
month = 12
}
export default class HomeTab extends Component {
constructor(props){
super(props);
this.state = {
today : date.getFullYear() + "." + date.getMonth() + "." + date.getDate(),
ID : this.props.navigation.getParam('id','pi1'),
today : date.getFullYear() + "." + month + "." + date.getDate(),
current_weight : 0,
table_contents : [['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],['오후','4:27:52', '+0.12kg', 'Total : 1.38kg'],
['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],
......@@ -21,11 +25,34 @@ export default class HomeTab extends Component {
]
}
}
get_diff_data(){
return fetch('http://10.0.2.2:3000/app/get_diff_data/',{
method:'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body:JSON.stringify({
ras_id : this.state.ID,
date : this.state.today,
}),
})
.then((response) => console.log(response.json()))
.then((responseJson)=> {
console.log(responseJson)
},function(){
})
.catch((error) => {
console.error(error);
})
}
render() {
return (
<View style={style.container}>
<View style={style.header}>
<Text style={style.tabName}>Home</Text>
<Text style={style.tabName}>Home {this.state.ID}</Text>
</View>
<View style={{flexDirection:'row',flex:0.8,backgroundColor: "rgba(230,230,230,0.5)"}}>
<View style={{flex:1,justifyContent:'center'}}>
......@@ -38,7 +65,8 @@ export default class HomeTab extends Component {
</View>
<View style={style.current_state}>
<Circle
title={"3.6"}>
title={"3.6"}
onPress={()=>{this.get_diff_data()}}>
</Circle>
</View>
<View style={style.waste_detail}>
......
......@@ -4,16 +4,40 @@ import AddButton from '../component/AddButton'
var date = new Date();
date.setHours(date.getHours()+9);
date.setMonth(date.getMonth()+1);
export default class SettingTab extends Component {
constructor(props){
super(props);
this.state = {
ID : 'abcdefg1234'
ID : 'pi1',
user : 'user1'
}
}
save_app_data(){
return fetch('http://10.0.2.2:3000/app/save_data/',{
method:'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body:JSON.stringify({
ras_id : this.state.ID,
user_id : this.state.user,
}),
})
.then((response) => console.log(response.json()))
.then((responseJson)=> {
console.log(responseJson)
},function(){
})
.catch((error) => {
console.error(error);
})
}
delete_id(){
this.setState({ID: ''})
//기기연결 해제, 디비비우기
......@@ -54,8 +78,9 @@ export default class SettingTab extends Component {
placeholder="New Rasberry ID"
value={this.state.text}
onChangeText={(text)=>this.setState({ID:text})}/>
<AddButton></AddButton>
</View>
<AddButton
onPress={()=>{this.save_app_data()}}/>
</View>
</View>
</View>
......