Fakultas Ilmu Komputer UI

Commit 5694c238 authored by Ahmad Izzudin Alifyandra's avatar Ahmad Izzudin Alifyandra
Browse files

refactor: move getCategories function

parent d33d65b8
Pipeline #86127 passed with stage
in 9 minutes and 4 seconds
import { FlatList, SafeAreaView, StyleSheet } from "react-native";
import React, { useState } from "react";
import HorizontalCards from "../components/Cards/HorizontalCards";
import { useNavigation } from "@react-navigation/core";
// import { useNavigation } from "@react-navigation/core";
import Colors from "../constants/Colors";
import { View } from "../components/Themed";
import Spacer from "../components/Spacer/Spacer";
import { IEcosystem } from "../types/firestore/ecosystems";
// import { IEcosystem } from "../types/firestore/ecosystems";
import IconForm from "../components/Forms/IconForm";
const CategoryEcosystemListScreen = () => {
const nav = useNavigation();
// const nav = useNavigation();
const [search, setSearch] = useState("");
const [listData, setListData] = useState([
const [
listData,
// setListData
] = useState([
{
id: "1",
image:
......
import { FlatList, SafeAreaView, StyleSheet } from "react-native";
import React, { useState } from "react";
import HorizontalCards from "../components/Cards/HorizontalCards";
import { useNavigation } from "@react-navigation/core";
// import { useNavigation } from "@react-navigation/core";
import Colors from "../constants/Colors";
import { View } from "../components/Themed";
import Spacer from "../components/Spacer/Spacer";
import { IEcosystem } from "../types/firestore/ecosystems";
import { IEcosystemList } from "../types/ecosystemList";
// import { IEcosystem } from "../types/firestore/ecosystems";
// import { IEcosystemList } from "../types/ecosystemList";
const EcosystemListScreen = () => {
const nav = useNavigation();
const [listData, setListData] = useState([
// const nav = useNavigation();
const [
listData,
// setListData
] = useState([
{
id: "1",
image:
......
......@@ -23,6 +23,8 @@ const RegisterScreen = ({ navigation }: RootTabScreenProps<"TabOne">) => {
const [password, setPassword] = useState("");
const [phoneNo, setPhoneNo] = useState("");
const [picked, setPicked] = useState("");
// TODO: Use getCategories firestore function to fetch categories
const [categories, setCategories] = useState([
{ label: "Agrikultur", value: "B" },
{ label: "Pertanian", value: "D" },
......
import firebase from "firebase";
import { ICategory } from "../types/firestore";
import { ICategory } from "../../types/firestore";
export const getCategories = async (): Promise<ICategory[]> => {
const db = firebase.firestore();
......@@ -8,7 +8,7 @@ export const getCategories = async (): Promise<ICategory[]> => {
const categories: ICategory[] = [];
snap.docs.forEach((doc) => {
const data: ICategory = { ...(doc.data() as ICategory), id: doc.id };
categories.push({ name: data.name, id: doc.id });
categories.push(data);
});
return categories;
};
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