유희정

id수정

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