See challenges you've accepted too
This commit is contained in:
parent
798253f887
commit
c93f9c5483
|
@ -134,11 +134,11 @@ export function listenForUserChallenges(
|
||||||
return listenForValues<Challenge>(listUserChallenges(fromId), setLinks)
|
return listenForValues<Challenge>(listUserChallenges(fromId), setLinks)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useUserChallenges = (fromId: string) => {
|
export const useUserChallenges = (fromId?: string) => {
|
||||||
const [links, setLinks] = useState<Challenge[]>([])
|
const [links, setLinks] = useState<Challenge[]>([])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return listenForUserChallenges(fromId, setLinks)
|
if (fromId) return listenForUserChallenges(fromId, setLinks)
|
||||||
}, [fromId])
|
}, [fromId])
|
||||||
|
|
||||||
return links
|
return links
|
||||||
|
|
|
@ -36,8 +36,12 @@ const amountClass = columnClass + ' max-w-[75px] font-bold'
|
||||||
|
|
||||||
export default function ChallengesListPage() {
|
export default function ChallengesListPage() {
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
const userChallenges = useUserChallenges(user?.id ?? '')
|
|
||||||
const challenges = useAcceptedChallenges()
|
const challenges = useAcceptedChallenges()
|
||||||
|
const userChallenges = useUserChallenges(user?.id)
|
||||||
|
.concat(
|
||||||
|
user ? challenges.filter((c) => c.acceptances[0].userId === user.id) : []
|
||||||
|
)
|
||||||
|
.sort((a, b) => b.createdTime - a.createdTime)
|
||||||
|
|
||||||
const userTab = user
|
const userTab = user
|
||||||
? [
|
? [
|
||||||
|
|
Loading…
Reference in New Issue
Block a user