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
cf9f8ec9
Commit
cf9f8ec9
authored
Dec 03, 2021
by
Ahmad Izzudin Alifyandra
Browse files
fix: creator ecosystem follow logic
parent
57822efe
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/components/carousel/VerticalEcosystemCarousel.tsx
View file @
cf9f8ec9
...
...
@@ -38,6 +38,7 @@ const VerticalEcosystemCarousel = ({ list }: props) => {
image
:
item
.
pic
,
member
:
item
.
followerCount
.
toString
(),
rating
:
item
.
rating
.
toString
(),
creatorId
:
item
.
creatorId
,
},
});
}
}
...
...
src/screens/ecosystem/CategoryEcosystemListScreen.tsx
View file @
cf9f8ec9
...
...
@@ -110,6 +110,7 @@ const CategoryEcosystemListScreen = ({
image
:
item
.
pic
,
member
:
item
.
followerCount
.
toString
(),
rating
:
item
.
rating
.
toString
(),
creatorId
:
item
.
creatorId
,
},
})
}
...
...
src/screens/ecosystem/EcosystemDetailScreen.tsx
View file @
cf9f8ec9
...
...
@@ -16,21 +16,18 @@ import { useEffect, useState } from "react";
import
RatingForm
from
"
../../components/RatingForm
"
;
import
{
rateEcosystem
}
from
"
../../service/functions/rateEcosystem
"
;
import
{
getEcosystemRating
}
from
"
../../service/firestore/ecosystem/getEcosystemRating
"
;
import
{
isOwner
}
from
"
../../service/firestore/ecosystem/isOwner
"
;
import
{
deleteEcosystem
}
from
"
../../service/functions/deleteEcosystem
"
;
const
EcosystemDetailScreen
=
({
route
,
}:
EcosystemStackScreenProps
<
"
EcosystemDetails
"
>
)
=>
{
const
{
id
,
title
,
desc
,
image
,
member
,
rating
}
=
route
.
params
;
const
{
id
,
title
,
desc
,
image
,
member
,
rating
,
creatorId
}
=
route
.
params
;
const
nav
=
useNavigation
();
const
user
=
useUser
();
const
[
isInEcosystem
,
setIsInEcosystem
]
=
useState
(
false
);
const
[
isFetched
,
setIsFetched
]
=
useState
(
false
);
const
[
isRating
,
setIsRating
]
=
useState
(
false
);
const
[
currentRating
,
setCurrentRating
]
=
useState
(
0
);
const
[
isEcosystemOwner
,
setIsEcosystemOnwer
]
=
useState
(
false
);
const
[
isOwnerFetched
,
setIsOwnerFetched
]
=
useState
(
false
);
useEffect
(()
=>
{
inEcosystem
(
id
,
user
.
id
).
then
((
res
)
=>
{
...
...
@@ -40,14 +37,6 @@ const EcosystemDetailScreen = ({
getEcosystemRating
(
id
,
user
.
id
).
then
((
res
)
=>
setCurrentRating
(
res
));
},
[]);
useEffect
(()
=>
{
isOwner
(
id
,
user
.
id
)
.
then
((
res
)
=>
{
setIsEcosystemOnwer
(
res
);
})
.
then
(()
=>
setIsOwnerFetched
(
true
));
},
[]);
const
alertFollow
=
()
=>
{
Alert
.
alert
(
"
Joined Ecosystem
"
,
"
You have joined the ecosystem
"
);
inEcosystem
(
id
,
user
.
id
).
then
((
res
)
=>
setIsInEcosystem
(
res
));
...
...
@@ -143,7 +132,9 @@ const EcosystemDetailScreen = ({
<
Text
style
=
{
styles
.
textBody
}
>
{
desc
}
</
Text
>
<
Spacer
variant
=
{
"
xl
"
}
/>
{
(()
=>
{
if
(
isInEcosystem
&&
isFetched
)
{
if
(
creatorId
==
user
.
id
)
{
return
null
;
}
else
if
(
isInEcosystem
&&
isFetched
)
{
return
(
<
SmallButton
text
=
{
"
Keluar dari Ekosistem
"
}
...
...
@@ -180,7 +171,7 @@ const EcosystemDetailScreen = ({
)
}
<
Spacer
variant
=
{
"
l
"
}
/>
{
(()
=>
{
if
(
isEcosystemOwner
&&
isOwnerFetche
d
)
{
if
(
creatorId
==
user
.
i
d
)
{
return
(
<
SmallButton
text
=
{
"
Hapus Ekosistem
"
}
...
...
src/screens/ecosystem/EcosystemSearch.tsx
View file @
cf9f8ec9
...
...
@@ -97,6 +97,7 @@ const EcosystemSearch = ({ route }: EcosystemStackScreenProps<"Search">) => {
image
:
item
.
pic
,
member
:
item
.
followerCount
.
toString
(),
rating
:
item
.
rating
.
toString
(),
creatorId
:
item
.
creatorId
,
},
});
}
}
...
...
src/screens/ecosystem/RecommendedEcosystemScreen.tsx
View file @
cf9f8ec9
...
...
@@ -101,6 +101,7 @@ const RecommendedEcosystemScreen = ({
image
:
item
.
pic
,
member
:
item
.
followerCount
.
toString
(),
rating
:
item
.
rating
.
toString
(),
creatorId
:
item
.
creatorId
,
},
});
}
}
...
...
src/service/firestore/ecosystem/followEcosystem.ts
View file @
cf9f8ec9
...
...
@@ -8,6 +8,7 @@ export const followEcosystem = async (ecosystemId: string, userId: string) => {
const
followDoc
:
IEcosystemFollow
=
{
userId
:
userId
,
ecosystemId
:
ecosystemId
,
isCreator
:
false
,
};
return
await
db
...
...
src/service/firestore/ecosystem/getByFollowed.ts
View file @
cf9f8ec9
...
...
@@ -12,6 +12,7 @@ export const getByFollowed = async (
const
query
=
db
.
collection
(
"
ecosystem_follows_
"
+
getEnv
())
.
where
(
"
userId
"
,
"
==
"
,
userId
)
.
where
(
"
isCreator
"
,
"
==
"
,
false
)
.
limit
(
10
);
const
followedEcosystemIdSnap
=
await
(
async
()
=>
{
...
...
src/types/firestore/ecosystemFollow.ts
View file @
cf9f8ec9
...
...
@@ -2,4 +2,5 @@ export type IEcosystemFollow = {
id
?:
string
;
userId
:
string
;
ecosystemId
:
string
;
isCreator
:
boolean
;
};
src/types/navigation/EcosystemStack.ts
View file @
cf9f8ec9
...
...
@@ -23,6 +23,7 @@ export type EcosystemStackParamList = {
image
:
string
;
member
:
string
;
rating
:
string
;
creatorId
:
string
;
};
UserList
:
{
headerTitle
?:
string
;
...
...
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