유희정

id수정

......@@ -5,7 +5,7 @@ import { createStackNavigator } from 'react-navigation-stack'
// import MainScreen from './components/MainScreen';
import Login from './source/Login';
import MainScreen from './source/MainScreen';
import {getId} from './source/component/DBhelper'
import {checkUser} from './source/component/DBhelper'
// const AppStackNavigator = createStackNavigator({
// Main:{
......@@ -17,7 +17,7 @@ import {getId} from './source/component/DBhelper'
var initialName = ''
if(getId() == true){
if(checkUser() == true){
initialName = 'MainScreen'
}
else initialName = 'Login'
......
This diff is collapsed. Click to expand it.
......@@ -2,7 +2,7 @@ import React, { Component } from 'react';
import { View, Text, StyleSheet,ScrollView, RefreshControl } from 'react-native';
import HistoryGraph from '../component/HistoryGraph'
import SegmentedControlTab from "react-native-segmented-control-tab";
import {add_data, get_week_data, get_month_data, get_year_data, add_temp_data} from'../component/DBhelper.js';
import {get_id,add_data, get_week_data, get_month_data, get_year_data, add_temp_data} from'../component/DBhelper.js';
//var today = new Date();
//today.setHours(today.getHours()+9);
......@@ -22,7 +22,8 @@ export default class HomeTab extends Component {
data: get_week_data(),
title: "총 " + total(get_week_data())/1000 + "kg",
spane: "",
refreshing: false
refreshing: false,
ID: get_id(),
}
}
......@@ -67,7 +68,7 @@ export default class HomeTab extends Component {
'Content-Type': 'application/json',
},
body:JSON.stringify({
ras_id : "pi1",
ras_id : this.state.ID,
date : "1576339901541",
}),
})
......
......@@ -2,7 +2,7 @@ import React, { Component } from 'react';
import { View, Text, StyleSheet, SafeAreaView, ScrollView, Image } from 'react-native';
import Circle from '../component/circle_component'
import {Table, TableWrapper, Row,Rows} from 'react-native-table-component'
import {get_now_weight, get_today_data, add_data,add_temp_data} from'../component/DBhelper.js';
import {get_now_weight, get_today_data, add_data,add_temp_data,get_id} from'../component/DBhelper.js';
var date = new Date();
date.setHours(date.getHours()+9);
......@@ -15,7 +15,7 @@ export default class HomeTab extends Component {
constructor(props){
super(props);
this.state = {
ID : this.props.navigation.getParam('id','pi1'),
ID : get_id(),
today : date.getFullYear() + "." + month + "." + date.getDate(),
current_weight : get_now_weight() ,
table_contents : get_today_data()
......@@ -44,7 +44,7 @@ export default class HomeTab extends Component {
'Content-Type': 'application/json',
},
body:JSON.stringify({
ras_id : "pi1",
ras_id : this.state.ID,
date : "1576648647000",
}),
})
......
......@@ -16,7 +16,7 @@ export default class Login extends Component {
};
getdata() {
return fetch('http://testloadbalancer-1847561458.ap-northeast-2.elb.amazonaws.com/app/get_data/pi1')
return fetch('http://testloadbalancer-1847561458.ap-northeast-2.elb.amazonaws.com/app/get_data/'+this.state.ID)
.then((response) => response.json())
.then((responseJson) => {
add_data(responseJson);
......
......@@ -28,7 +28,7 @@ export function registerID(_id){
}
}
export function getId(){
export function checkUser(){
let user = realm.objects('ID');
console.log(user.length);
if(user.length>0)
......@@ -36,6 +36,11 @@ export function getId(){
return false;
}
export function get_id(){
let user = realm.objects('ID');
return user[0].id;
}
export function deleteId(){
let user = realm.objects('ID');
realm.write(()=>{
......