Compare commits
No commits in common. "8f3e4420779d01656fadb6b7c4b74ace77087515" and "c1805643c8bf7de0203ebeaaf937307e0db2549d" have entirely different histories.
8f3e442077
...
c1805643c8
@ -1,4 +1,4 @@
|
|||||||
import { View, StyleSheet, FlatList, Image } from "react-native";
|
import { View, StyleSheet, FlatList } from "react-native";
|
||||||
import Text from "@components/Text";
|
import Text from "@components/Text";
|
||||||
import Button from "@components/Button";
|
import Button from "@components/Button";
|
||||||
import { colors } from "@components/style";
|
import { colors } from "@components/style";
|
||||||
@ -14,8 +14,6 @@ export default function Tab() {
|
|||||||
fetchData();
|
fetchData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const API_HOST = process.env.EXPO_PUBLIC_API_URL.replace("/api/v1", "");
|
|
||||||
|
|
||||||
async function fetchData() {
|
async function fetchData() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${process.env.EXPO_PUBLIC_API_URL}/review/get`, {
|
const res = await fetch(`${process.env.EXPO_PUBLIC_API_URL}/review/get`, {
|
||||||
@ -25,28 +23,6 @@ export default function Tab() {
|
|||||||
let data = await res.json();
|
let data = await res.json();
|
||||||
// show only logged in user's data
|
// show only logged in user's data
|
||||||
data = data.data.filter((review) => review.user_id == user._id);
|
data = data.data.filter((review) => review.user_id == user._id);
|
||||||
|
|
||||||
let beers = await fetch(`${process.env.EXPO_PUBLIC_API_URL}/beer/get`, {
|
|
||||||
method: "GET",
|
|
||||||
credentials: "include",
|
|
||||||
});
|
|
||||||
beers = await beers.json();
|
|
||||||
beers = beers.data;
|
|
||||||
console.log(beers);
|
|
||||||
|
|
||||||
async function getBeerParam(search, beers) {
|
|
||||||
for (let i = 0; i < beers.length; i++) {
|
|
||||||
if (beers[i]._id == search) {
|
|
||||||
return beers[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
data.forEach(async (el) => {
|
|
||||||
el.beer = await getBeerParam(el.beer_id, beers);
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log("reviews", data);
|
console.log("reviews", data);
|
||||||
setData(data);
|
setData(data);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -72,36 +48,14 @@ export default function Tab() {
|
|||||||
style={styles.reviewList}
|
style={styles.reviewList}
|
||||||
keyExtractor={(item) => String(item._id)}
|
keyExtractor={(item) => String(item._id)}
|
||||||
renderItem={({ item }) => (
|
renderItem={({ item }) => (
|
||||||
<View style={styles.itemContainer}>
|
<View style={styles.item}>
|
||||||
<View>
|
|
||||||
<Text>{item.beer.name}</Text>
|
|
||||||
<Text>{item.beer.brand}</Text>
|
|
||||||
<Text>{item.beer.degree}°</Text>
|
|
||||||
<Text>{item.beer.packaging}</Text>
|
|
||||||
<Image
|
|
||||||
source={
|
|
||||||
item.beer.imgs[0]
|
|
||||||
? {
|
|
||||||
uri: `${API_HOST}/public/uploads/${item.beer.imgs[0]}`,
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
uri: "https://imagesvc.meredithcorp.io/v3/mm/image?url=https:%2F%2Fstatic.onecms.io%2Fwp-content%2Fuploads%2Fsites%2F44%2F2020%2F09%2F29%2Flight-beer.jpg",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
style={styles.itemImg}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View>
|
|
||||||
<Text>Foam → {opt3[item.foam - 1]}</Text>
|
<Text>Foam → {opt3[item.foam - 1]}</Text>
|
||||||
<Text>
|
<Text>Bitter / Sweetness → {opt3[item.bitter_sweetness - 1]}</Text>
|
||||||
Bitter / Sweetness → {opt3[item.bitter_sweetness - 1]}
|
|
||||||
</Text>
|
|
||||||
<Text>Taste → {opt5[item.taste - 1]}</Text>
|
<Text>Taste → {opt5[item.taste - 1]}</Text>
|
||||||
<Text>Packaging → {opt5[item.packaging - 1]}</Text>
|
<Text>Packaging → {opt5[item.packaging - 1]}</Text>
|
||||||
<Text>Sourness → {sourness[item.sourness - 1]}</Text>
|
<Text>Sourness → {sourness[item.sourness - 1]}</Text>
|
||||||
<Text>Would again? → {opt2[item.would_again - 1]}</Text>
|
<Text>Would again? → {opt2[item.would_again - 1]}</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
@ -120,20 +74,11 @@ export const styles = StyleSheet.create({
|
|||||||
paddingHorizontal: "15%",
|
paddingHorizontal: "15%",
|
||||||
marginTop: "5%",
|
marginTop: "5%",
|
||||||
},
|
},
|
||||||
itemContainer: {
|
item: {
|
||||||
borderColor: "gray",
|
borderColor: "gray",
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
padding: 13,
|
padding: 13,
|
||||||
marginBottom: "5%",
|
marginBottom: "5%",
|
||||||
flex: 1,
|
|
||||||
flexDirection: "row",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
},
|
|
||||||
itemImg: {
|
|
||||||
width: 150,
|
|
||||||
aspectRatio: 1,
|
|
||||||
resizeMode: "contain",
|
|
||||||
marginTop: "5%",
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user