update: gamification model

parent 1ba2ca37
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// https://aboutreact.com/react-native-login-and-signup/ // https://aboutreact.com/react-native-login-and-signup/
// Import React and Component // Import React and Component
import React, { useState } from "react"; import React, { useState, useEffect } from "react";
import { import {
StyleSheet, StyleSheet,
View, View,
...@@ -21,7 +21,28 @@ import axios from "axios"; ...@@ -21,7 +21,28 @@ import axios from "axios";
export function gamification({ navigation }) { export function gamification({ navigation }) {
// const [title, setTitle] = useState(); // const [title, setTitle] = useState();
const [earn, setEarn] = useState("");
const fetchData = async () => {
// const resp = await fetch("http://192.168.8.126:5000/getDetails", {method:"POST"});
axios({
method: "GET",
url: "http://192.168.8.126:5000/getVal/<id>",
})
.then(function (response) {
console.log(response.data.message);
// data = response.data
setEarn(response.data.message);
})
.catch(function (error) {
console.log("axios error" + error);
});
};
useEffect(() => {
fetchData();
},[]);
// const handlecarrot = () => { // const handlecarrot = () => {
// setTitle({title: "carrot"}); // setTitle({title: "carrot"});
// console.log(title) // console.log(title)
...@@ -38,9 +59,9 @@ export function gamification({ navigation }) { ...@@ -38,9 +59,9 @@ export function gamification({ navigation }) {
initialValues={{ name: "", title: "" }} initialValues={{ name: "", title: "" }}
onSubmit={(values, actions) => { onSubmit={(values, actions) => {
console.log(values); console.log(values);
// console.log(title) // console.log(title)
// console.log(title); // console.log(title);
// console.log(values.name); // console.log(values.name);
// console.log(values.title); // console.log(values.title);
...@@ -101,9 +122,9 @@ export function gamification({ navigation }) { ...@@ -101,9 +122,9 @@ export function gamification({ navigation }) {
<TouchableOpacity <TouchableOpacity
style={styles.buttonSub} style={styles.buttonSub}
title="carrot" title="carrot"
onPress={(title) =>{ onPress={(title) => {
props.setFieldValue('title', "carrot") props.setFieldValue("title", "carrot");
props.handleSubmit(title) props.handleSubmit(title);
}} }}
// onPress={handlecarrot} // onPress={handlecarrot}
> >
...@@ -113,9 +134,9 @@ export function gamification({ navigation }) { ...@@ -113,9 +134,9 @@ export function gamification({ navigation }) {
<TouchableOpacity <TouchableOpacity
style={styles.buttonSub} style={styles.buttonSub}
title="tomato" title="tomato"
onPress={(title) =>{ onPress={(title) => {
props.setFieldValue('title', "tomato") props.setFieldValue("title", "tomato");
props.handleSubmit(title) props.handleSubmit(title);
}} }}
> >
<Text style={styles.buttonText}>Tomato</Text> <Text style={styles.buttonText}>Tomato</Text>
...@@ -124,9 +145,9 @@ export function gamification({ navigation }) { ...@@ -124,9 +145,9 @@ export function gamification({ navigation }) {
<TouchableOpacity <TouchableOpacity
style={styles.buttonSub} style={styles.buttonSub}
title="chilli" title="chilli"
onPress={(title) =>{ onPress={(title) => {
props.setFieldValue('title', "chilli") props.setFieldValue("title", "chilli");
props.handleSubmit(title) props.handleSubmit(title);
}} }}
> >
<Text style={styles.buttonText}>chilli</Text> <Text style={styles.buttonText}>chilli</Text>
...@@ -135,24 +156,28 @@ export function gamification({ navigation }) { ...@@ -135,24 +156,28 @@ export function gamification({ navigation }) {
<TouchableOpacity <TouchableOpacity
style={styles.buttonSub} style={styles.buttonSub}
title="beans" title="beans"
onPress={(title) =>{ onPress={(title) => {
props.setFieldValue('title', "beans") props.setFieldValue("title", "beans");
props.handleSubmit(title) props.handleSubmit(title);
}} }}
> >
<Text style={styles.buttonText}>Beans</Text> <Text style={styles.buttonText}>Beans</Text>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<View <View
style={{ style={{
alignSelf: "center", alignSelf: "center",
marginTop: 10, marginTop: 10,
}} }}
> >
<FontAwesome name="money" size={50} color="black" /> <FontAwesome name="money" size={50} color="black" style={{
</View> alignSelf: "center",
<Text style={styles.textdata}>TOTAL EARNED $: 1000</Text> }}/>
<Text style={styles.textdata}>TOTAL EARNED $: {earn}</Text>
</View>
</View> </View>
)} )}
</Formik> </Formik>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment