Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
PPL KI Ganjil 2021 2022
Clicks - Ecosystem Business
clicks-frontend
Commits
5694c238
Commit
5694c238
authored
Oct 09, 2021
by
Ahmad Izzudin Alifyandra
Browse files
refactor: move getCategories function
parent
d33d65b8
Pipeline
#86127
passed with stage
in 9 minutes and 4 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/screens/CategoryEcosystemListScreen.tsx
View file @
5694c238
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
:
...
...
src/screens/EcosystemListScreen.tsx
View file @
5694c238
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
:
...
...
src/screens/auth/RegisterScreen.tsx
View file @
5694c238
...
...
@@ -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
"
},
...
...
src/
db
/categories.ts
x
→
src/
service/firestore
/categories.ts
View file @
5694c238
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
;
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment