diff --git a/src/components/carousel/CategoryHorizontalCarousel.tsx b/src/components/carousel/CategoryHorizontalCarousel.tsx index 9d58531c81ea67ddb5954d372a4a6aaceeb8df20..2e3ca024ed4eec36118f72c95954f2342808230f 100644 --- a/src/components/carousel/CategoryHorizontalCarousel.tsx +++ b/src/components/carousel/CategoryHorizontalCarousel.tsx @@ -2,12 +2,15 @@ import React from "react"; import { StyleSheet, View, FlatList, ScrollView } from "react-native"; import Spacer from "../Spacer/Spacer"; import ArrowlessPlainButton from "../button/ArrowlessPlainButton"; +import { ICategory } from "../../types/firestore"; +import { useNavigation } from "@react-navigation/core"; type props = { - list: { id: string; name: string }[]; + list: ICategory[]; }; const CategoryHorizontalCarousel = ({ list }: props) => { + const nav = useNavigation(); return ( { renderItem={({ item }) => { return ( - + + nav.navigate("Ecosystem", { + screen: "EcosystemList", + params: { + headerTitle: item.name, + toFetch: item.id, + }, + }) + } + /> ); }} - numColumns={Math.ceil(list.length / 2)} + numColumns={6} keyExtractor={(item) => item.id} ItemSeparatorComponent={() => } showsVerticalScrollIndicator={false} diff --git a/src/components/carousel/VerticalEcosystemCarousel.tsx b/src/components/carousel/VerticalEcosystemCarousel.tsx index f7285816d10fb984a584d05acdee1c964f2475ee..e6f79e10f1eb768e1f74a0a11f356e1cc15185b4 100644 --- a/src/components/carousel/VerticalEcosystemCarousel.tsx +++ b/src/components/carousel/VerticalEcosystemCarousel.tsx @@ -2,17 +2,15 @@ import React from "react"; import { StyleSheet, View, FlatList, ScrollView } from "react-native"; import Spacer from "../Spacer/Spacer"; import VerticalCard from "../Cards/VerticalCard"; +import { IEcosystem } from "../../types/firestore/ecosystems"; +import { useNavigation } from "@react-navigation/core"; type props = { - list: { - id: string; - name: string; - pic: string; - followerCount: number; - }[]; + list: IEcosystem[]; }; const VerticalEcosystemCarousel = ({ list }: props) => { + const nav = useNavigation(); return ( { members={item.followerCount} title={item.name} imageSource={item.pic} - onPressFunction={null} + onPressFunction={() => { + nav.navigate("Ecosystem", { + screen: "EcosystemDetails", + params: { + headerTitle: item.name, + title: item.name, + desc: item.description, + image: item.pic, + member: item.followerCount.toString(), + rating: item.rating.toString(), + }, + }); + }} /> ); @@ -52,6 +62,7 @@ const styles = StyleSheet.create({ width: 210, justifyContent: "center", alignItems: "center", + marginRight: 16, }, }); diff --git a/src/screens/EcosystemMapScreenDetail.tsx/CategoryEcosystemListScreen.tsx b/src/screens/EcosystemMapScreenDetail.tsx/CategoryEcosystemListScreen.tsx new file mode 100644 index 0000000000000000000000000000000000000000..6f25774bbed062f21cb01f6178569ce37722a0f8 --- /dev/null +++ b/src/screens/EcosystemMapScreenDetail.tsx/CategoryEcosystemListScreen.tsx @@ -0,0 +1,81 @@ +// import { FlatList, ScrollView, StyleSheet } from "react-native"; +// import React, { useEffect, useState } from "react"; +// import HorizontalCards from "../../components/Cards/HorizontalCards"; +// import { useNavigation } from "@react-navigation/core"; +// import Colors from "../../constants/Colors"; +// import { View } from "../../components/Themed"; +// import Spacer from "../../components/Spacer/Spacer"; +// import IconForm from "../../components/Forms/IconForm"; +// import { getByCategory } from "../../service/firestore/ecosystem/getByCategory"; +// import { IEcosystem } from "../../types/firestore/ecosystems"; +// // import { EcosystemStackScreenProps } from "../../types/navigation"; + +// const CategoryEcosystemListScreen = () => { +// const nav = useNavigation(); +// // const { toFetch } = route.params; +// const [search, setSearch] = useState(""); +// const [listData, setListData] = useState([]); + +// useEffect(() => { +// getByCategory("A").then((res) => setListData(res)); +// }); + +// return ( +// +// +// +// +// +// { +// return ( +// +// +// nav.navigate("Ecosystem", { +// screen: "EcosystemDetails", +// params: { +// headerTitle: item.name, +// title: item.name, +// desc: item.description, +// image: item.pic, +// member: item.followerCount.toString(), +// rating: item.rating.toString(), +// }, +// }) +// } +// /> +// +// ); +// }} +// keyExtractor={(item) => item.id} +// ItemSeparatorComponent={() => } +// showsVerticalScrollIndicator={false} +// showsHorizontalScrollIndicator={false} +// /> +// +// ); +// }; + +// const styles = StyleSheet.create({ +// container: { +// padding: 24, +// backgroundColor: Colors.background, +// }, +// horizontalCard: { +// paddingHorizontal: 4, +// paddingTop: 2, +// }, +// }); + +// export default CategoryEcosystemListScreen; diff --git a/src/screens/ecosystem/BusinessEcosystemScreen.tsx b/src/screens/ecosystem/BusinessEcosystemScreen.tsx index 04760f1bc93aab1bcd320b2118fcc8ab5e5e94b0..705d0c89542e2b6363817bea0a3330bc8736f097 100644 --- a/src/screens/ecosystem/BusinessEcosystemScreen.tsx +++ b/src/screens/ecosystem/BusinessEcosystemScreen.tsx @@ -1,187 +1,187 @@ import { useNavigation } from "@react-navigation/core"; -import React from "react"; -import { StyleSheet } from "react-native"; +import React, { useState, useEffect } from "react"; +import { ScrollView, StyleSheet } from "react-native"; import { TouchableOpacity } from "react-native-gesture-handler"; import SmallButton from "../../components/button/SmallButton"; +import VerticalEcosystemCarousel from "../../components/carousel/VerticalEcosystemCarousel"; +import CategoryHorizontalCarousel from "../../components/carousel/CategoryHorizontalCarousel"; import Spacer from "../../components/Spacer/Spacer"; import { Text, View } from "../../components/Themed"; import Colors from "../../constants/Colors"; -import { useUser } from "../../hooks/reduxHooks"; -import ecosystemService from "../../service/firestore/ecosystem"; -import { createEcosystem } from "../../service/functions/createEcosystem"; - +import { useAppSelector } from "../../hooks/reduxHooks"; +import { getByMostRecent } from "../../service/firestore/ecosystem/getMostRecent"; +import { getByPopularity } from "../../service/firestore/ecosystem/getByPopularity"; +import { getByFollowed } from "../../service/firestore/ecosystem/getByFollowed"; +import { IEcosystem } from "../../types/firestore/ecosystems"; +import { IUser } from "../../types/firestore/User"; +import { getCategories } from "../../service/firestore/categories"; +import { ICategory } from "../../types/firestore"; const BusinessEcosystemScreen = () => { const nav = useNavigation(); - const user = useUser(); + const user: IUser = useAppSelector((state) => state.user); + const [listData, setListData] = useState([]); + const [listBergabung, setListBergabung] = useState([]); + const [listTerbaru, setListTerbaru] = useState([]); + const [listCategory, setListCategory] = useState([]); + useEffect(() => { + getByPopularity().then((res) => { + setListData(res.slice(0, 5)); + }); + getByFollowed(user.id).then((res) => { + setListBergabung(res.slice(0, 5)); + }); + getByMostRecent().then((res) => { + setListTerbaru(res.slice(0, 5)); + }); + getCategories().then((res) => { + setListCategory(res.slice(0, 6)); + }); + }, []); return ( - + - Ekosistem Bisnis + Selamat Datang, {user.firstName} - { - nav.navigate("CreateEcosystem", { - screen: "CreateEcosystem", - }); - }} - /> - { nav.navigate("Ecosystem", { screen: "Recommended", - params: { - headerTitle: "Ekosistem Saya", - toFetch: "myEcosystem", - }, + params: { headerTitle: "Ekosistem Saya", toFetch: "myEcosystem" }, }); }} > - Ekosistem Saya + Ekosistem Saya - { - nav.navigate("Ecosystem", { screen: "EcosystemDetails" }); - }} - > - Sudah Bergabung - + nav.navigate("CreateBusinessEcosystem")} + colors={"primary"} + /> - - { - nav.navigate("Ecosystem", { - screen: "BusinessCategory", - params: { - fromScreen: "BusinessEcosystem", - }, - }); - }} - > - Kategori Bisnis - + + + Ekosistem Saya + + + + nav.navigate("Ecosystem", { + screen: "Recommended", + params: { + headerTitle: "Ekosistem Saya", + toFetch: "myEcosystem", + }, + }) + } + > + + Lihat Semua + + + - - { - nav.navigate("Ecosystem", { - screen: "Recommended", - params: { - headerTitle: "Paling Populer", - toFetch: "popular", - }, - }); - }} - > - Paling Populer - + + + Sudah bergabung + + + + nav.navigate("Ecosystem", { + screen: "Recommended", + params: { headerTitle: "Sudah Bergabung", toFetch: "joined" }, + }) + } + > + + Lihat Semua + + + + + - - { - nav.navigate("Ecosystem", { - screen: "Recommended", - params: { - headerTitle: "Terbaru Minggu Ini", - toFetch: "mostRecent", - }, - }); - }} - > - Terbaru Minggu Ini - + + + Kategori Bisnis + + + + nav.navigate("Ecosystem", { + screen: "BusinessCategory", + params: { + fromScreen: "BusinessEcosystem", + }, + }) + } + > + + Lihat Semua + + + + + - - { - nav.navigate("Ecosystem", { screen: "EcosystemMap" }); - }} - > - Peta Ekosistem - - - - { - createEcosystem({ - ecosystem: { - creatorId: "abc", - name: "cebetEco", - description: "abc", - categoryId: "A", - pic: "", - rating: 0, - raters: 0, - followerCount: 0, - visibility: "public", - }, - ecosystemCategoryMembers: [ - { - categoryMember: { - categoryId: "B", - type: "supplier", - }, - ecosystemMemberships: [ - { - userId: "7n8uc62bS6UGUl29fODxIp7PAdn2", - }, - ], - }, - { - categoryMember: { - categoryId: "D", - type: "supplier", - }, - ecosystemMemberships: [ - { - userId: "abciuh3789489ho340hdf", - }, - { - userId: "sdfbubsdyuibabciuh3789489ho340h df", - }, - { - userId: "uihgybubsdyuibabciuh3789489ho340h df", - }, - ], + + + Paling Populer + + + + nav.navigate("Ecosystem", { + screen: "Recommended", + params: { + headerTitle: "Paling Populer", + toFetch: "popular", }, - ], - }); - }} - > - Create - + }) + } + > + + Lihat Semua + + + - - { - ecosystemService.followEcosystem("FmclOe2dvRbIi7B2Ja5k", user.id); - }} - > - Follow - - - - { - ecosystemService.unfollowEcosystem("FmclOe2dvRbIi7B2Ja5k", user.id); - }} - > - Unfollow - + + + + + + Terbaru Minggu Ini + + + + nav.navigate("Ecosystem", { + screen: "Recommended", + params: { headerTitle: "Terbaru", toFetch: "mostRecent" }, + }) + } + > + + Lihat Semua + + + - + + + + ); }; @@ -189,14 +189,29 @@ const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: Colors.background, - paddingHorizontal: 24, - justifyContent: "center", + padding: 24, }, - link: { + textLink: { + fontSize: 24, color: Colors.text.link, - fontStyle: "normal", - fontSize: 14, - fontWeight: "400", + }, + text: { + fontSize: 24, + color: Colors.text.title, + }, + textContainer: { + flex: 1, + paddingRight: 118, + }, + headContainer: { + flexDirection: "row", + justifyContent: "space-between", + paddingBottom: 16, + alignItems: "center", + }, + subTitle: { + fontSize: 20, + color: Colors.text.subtitle, }, }); diff --git a/src/screens/ecosystem/RecommendedEcosystemScreen.tsx b/src/screens/ecosystem/RecommendedEcosystemScreen.tsx index 84a90f15dcd91e54556ab308e3686c7401e46f2c..6a5847ef39e522bf2bb8e8dcd535381d4e7ef4c7 100644 --- a/src/screens/ecosystem/RecommendedEcosystemScreen.tsx +++ b/src/screens/ecosystem/RecommendedEcosystemScreen.tsx @@ -14,6 +14,7 @@ import { useNavigation } from "@react-navigation/core"; const RecommendedEcosystemScreen = ({ route, }: EcosystemStackScreenProps<"Recommended">) => { + // Comment const { toFetch } = route.params; const nav = useNavigation(); diff --git a/src/screens/profile/AccountSettingsScreen.tsx b/src/screens/profile/AccountSettingsScreen.tsx index fcc5e8c766be89fc8ff49c66fe022cf3692a5cfb..330fe09b7f52ced1bf5aa377693d88cebe2a124d 100644 --- a/src/screens/profile/AccountSettingsScreen.tsx +++ b/src/screens/profile/AccountSettingsScreen.tsx @@ -50,6 +50,7 @@ export default function AccountSettingsScreen({