update: gamification model

parent 1ba2ca37
......@@ -2,7 +2,7 @@
// https://aboutreact.com/react-native-login-and-signup/
// Import React and Component
import React, { useState } from "react";
import React, { useState, useEffect } from "react";
import {
StyleSheet,
View,
......@@ -21,7 +21,28 @@ import axios from "axios";
export function gamification({ navigation }) {
// 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 = () => {
// setTitle({title: "carrot"});
// console.log(title)
......@@ -38,9 +59,9 @@ export function gamification({ navigation }) {
initialValues={{ name: "", title: "" }}
onSubmit={(values, actions) => {
console.log(values);
// console.log(title)
// console.log(title);
// console.log(values.name);
// console.log(values.title);
......@@ -101,9 +122,9 @@ export function gamification({ navigation }) {
<TouchableOpacity
style={styles.buttonSub}
title="carrot"
onPress={(title) =>{
props.setFieldValue('title', "carrot")
props.handleSubmit(title)
onPress={(title) => {
props.setFieldValue("title", "carrot");
props.handleSubmit(title);
}}
// onPress={handlecarrot}
>
......@@ -113,9 +134,9 @@ export function gamification({ navigation }) {
<TouchableOpacity
style={styles.buttonSub}
title="tomato"
onPress={(title) =>{
props.setFieldValue('title', "tomato")
props.handleSubmit(title)
onPress={(title) => {
props.setFieldValue("title", "tomato");
props.handleSubmit(title);
}}
>
<Text style={styles.buttonText}>Tomato</Text>
......@@ -124,9 +145,9 @@ export function gamification({ navigation }) {
<TouchableOpacity
style={styles.buttonSub}
title="chilli"
onPress={(title) =>{
props.setFieldValue('title', "chilli")
props.handleSubmit(title)
onPress={(title) => {
props.setFieldValue("title", "chilli");
props.handleSubmit(title);
}}
>
<Text style={styles.buttonText}>chilli</Text>
......@@ -135,24 +156,28 @@ export function gamification({ navigation }) {
<TouchableOpacity
style={styles.buttonSub}
title="beans"
onPress={(title) =>{
props.setFieldValue('title', "beans")
props.handleSubmit(title)
onPress={(title) => {
props.setFieldValue("title", "beans");
props.handleSubmit(title);
}}
>
<Text style={styles.buttonText}>Beans</Text>
</TouchableOpacity>
</View>
<View
style={{
alignSelf: "center",
marginTop: 10,
}}
>
<FontAwesome name="money" size={50} color="black" />
</View>
<Text style={styles.textdata}>TOTAL EARNED $: 1000</Text>
<View
style={{
alignSelf: "center",
marginTop: 10,
}}
>
<FontAwesome name="money" size={50} color="black" style={{
alignSelf: "center",
}}/>
<Text style={styles.textdata}>TOTAL EARNED $: {earn}</Text>
</View>
</View>
)}
</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