Fakultas Ilmu Komputer UI

Commit 2e78fe93 authored by Bagus Prabowo's avatar Bagus Prabowo
Browse files

Merge branch 'add-get-ecosystem-function' into 'master'

chore: add getEcosystem function and tweak ecosystem details

See merge request !165
parents 81375752 278bb75c
Pipeline #88970 passed with stage
in 10 minutes and 7 seconds
......@@ -41,7 +41,7 @@ const EcosystemDetailScreen = ({
setIsFetched(true);
});
getEcosystemRating(id, user.id).then((res) => setCurrentRating(res));
}, []);
}, [id, user.id]);
const alertFollow = () => {
Alert.alert("Joined Ecosystem", "You have joined the ecosystem");
......@@ -116,6 +116,9 @@ const EcosystemDetailScreen = ({
onPress={() => {
nav.navigate("UpdateEcosystem", {
screen: "UpdateEcosystemScreen",
params: {
id,
},
});
}}
/>
......
......@@ -24,8 +24,11 @@ export const fetchUsersByEcosystemIdAndType = async (
});
const users: IUser[] = [];
console.log(ecosystemCategoryMembers);
for (let i = 0; i < ecosystemCategoryMembers.length; i++) {
const userId = Object.keys(ecosystemCategoryMembers[i].members);
const userId = ecosystemCategoryMembers[i].members
? Object.keys(ecosystemCategoryMembers[i].members)
: [];
for (let j = 0; j < userId.length; j++) {
const userDoc = await getUser(userId[j]);
const userData = { ...(userDoc.data() as IUser), id: userDoc.id };
......
import firebase from "firebase";
import { getEnv } from "../../../helpers/getEnv";
import { IEcosystem } from "../../../types/firestore/ecosystems";
export const getEcosystem = async (
ecosystemId: string
): Promise<IEcosystem> => {
const db = firebase.firestore();
const doc = await db
.collection("ecosystems_" + getEnv())
.doc(ecosystemId)
.get();
return {
id: doc.id,
...(doc.data() as IEcosystem),
};
};
Supports Markdown
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