Skip to content

Commit dbe071b

Browse files
Merge pull request #903 from dacadeorg/fix/console-errors
fix: resolve console errors
2 parents 6eca4d3 + 6959aa1 commit dbe071b

File tree

16 files changed

+56
-48
lines changed

16 files changed

+56
-48
lines changed

src/components/cards/Bounty.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default function BountyCard({ bounty }: BountyProps): ReactElement {
5757
const Component = link.startsWith("http") ? "a" : Link;
5858

5959
return (
60-
<div className="cursor-pointer flex md:flex-row-reverse md:space-x-5 px-5 min-h-32 md:h-auto md:w-full justify-between hover:bg-secondary relative">
60+
<div className="p-5 flex md:flex-row-reverse md:space-x-5 px-5 min-h-32 md:h-auto md:w-full justify-between hover:bg-secondary relative">
6161
<div className="bg-theme-accent flex-col w-full h-full justify-between md:-space-y-1 pl-3 pr-5 mt-7 mb-5">
6262
<Component className="relative w-full block" href={link}>
6363
<div className="font-medium text-md md:pt-1.5">{bounty.course ? bounty.course.name : bounty.name}</div>
@@ -71,15 +71,16 @@ export default function BountyCard({ bounty }: BountyProps): ReactElement {
7171
{bounty.submissions?.length ? (
7272
<div className="mt-4 space-y-0 divide-y divide-gray-200 border-t border-t-solid border-gray-200">
7373
{bounty.submissions.map((submission) => (
74-
<Link
75-
href={navigation.community.submissionPath(submission.id, bounty.challenge, bounty?.slug)}
76-
className="flex space-x-1 relative text-sm font-medium py-3"
77-
key={submission.id}
78-
>
74+
<div className="flex space-x-1 relative text-sm font-medium py-3" key={submission.id}>
7975
<div className="flex justify-between w-full pr-0 gap-1 sm:gap-0">
8076
<div className="flex space-x-1">
8177
<Avatar user={submission.user} size="mini" />
82-
<div className="text-ellipsis overflow-hidden w-17 sm:w-auto whitespace-nowrap">{submission.user.displayName}</div>
78+
<Link
79+
className="text-ellipsis overflow-hidden w-17 sm:w-auto whitespace-nowrap"
80+
href={navigation.community.submissionPath(submission.id, bounty.challenge, bounty?.slug)}
81+
>
82+
{submission.user.displayName}
83+
</Link>
8384
<div className="flex align-middle text-gray-500 text-middle bg-gray-200 px-2 text-xxs rounded-xl m-0 h-5">
8485
{submission.metadata && submission.metadata.feedbacks ? submission.metadata.feedbacks : 0}
8586
</div>
@@ -94,7 +95,7 @@ export default function BountyCard({ bounty }: BountyProps): ReactElement {
9495
)}
9596
</div>
9697
</div>
97-
</Link>
98+
</div>
9899
))}
99100
</div>
100101
) : (

src/components/cards/Reputation.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import Link from "next/link";
21
import Avatar from "@/components/ui/Avatar";
32
import Currency from "@/components/ui/Currency";
43
import { Community } from "@/types/community";
54
import { ReactElement } from "react";
65
import { User } from "@/types/bounty";
6+
import Link from "next/link";
77

88
/**
99
* Interface for the reputation card props
@@ -32,16 +32,16 @@ interface ReputationCardProps {
3232
*/
3333
export default function ReputationCard({ details = {} }: ReputationCardProps): ReactElement {
3434
return (
35-
<Link href={details?.community ? `/communities/${details.community.slug}` : ""} className="flex space-x-3 text-left hover:bg-gray-50 pb-3 -mx-5 px-5">
35+
<div className="flex space-x-3 text-left hover:bg-gray-50 pb-3 -mx-5 px-5">
3636
<Avatar icon={details.community?.icon} color={details.community?.colors?.cover?.background || details.community?.colors.primary} size="medium" shape="rounded" />
3737
{details?.score && (
38-
<div className="pt-1">
38+
<Link href={details?.community ? `/communities/${details.community.slug}` : ""} className="pt-1">
3939
<span className="block text-base font-medium leading-normal">
4040
<Currency value={details.score} token="REP" />
4141
</span>
4242
<span className="block font-normal text-sm">{details.community?.name}</span>
43-
</div>
43+
</Link>
4444
)}
45-
</Link>
45+
</div>
4646
);
4747
}

src/components/cards/challenge/Challenge.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Link from "next/link";
77
import RelatedContent from "./RelatedContent";
88
import Badges from "./Badges";
99
import { useMemo } from "react";
10-
import { useTranslation } from "react-i18next";
10+
import { useTranslation } from "next-i18next";
1111

1212
/**
1313
* `ChallengeCard` is a function component that renders a card
@@ -25,10 +25,12 @@ interface ChallengeCardProps {
2525
}
2626
export default function ChallengeCard({ data, community, isCourseEnd }: ChallengeCardProps) {
2727
const { t } = useTranslation();
28+
2829
const link = `/communities/${community.slug}/challenges/${data.id}`;
2930
const expiresAt = useMemo(() => (data.expiresAt ? new Date(data.expiresAt).toLocaleDateString() : null), [data.expiresAt]);
3031
const reward = isCourseEnd ? data?.rewards?.find((reward) => reward.type === "SUBMISSION") : data?.reward;
3132
const totalReward = data?.rewards?.reduce((acc, reward) => (acc += Number(reward.amount)), 0);
33+
3234
return (
3335
<div className="border-solid border border-gray-200 bg-gray-50 rounded-3xl mb-5 group text-gray-700">
3436
<div className="border-solid border-b border-gray-300 bg-white rounded-3xl sm:p-8 sm:pb-6 w-full p-6">
@@ -46,7 +48,7 @@ export default function ChallengeCard({ data, community, isCourseEnd }: Challeng
4648
<div className="md:pl-2 max-w-max">
4749
<div className="flex text-sm text-gray-700">
4850
<span className="block font-medium pr-1">
49-
{community.slug === "celo" && "NFT"} {t("communities.overview.challenge.certificate")}
51+
{community?.slug === "celo" && "NFT"} {t("communities.overview.challenge.certificate")}
5052
</span>
5153
</div>
5254
<div className="text-gray-400 text-xs font-normal">Upon successful completion</div>

src/components/cards/challenge/Overview.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from "react";
21
import Coin from "@/components/ui/Coin";
32
import { Challenge, Reward } from "@/types/course";
43
import { useTranslation } from "next-i18next";
@@ -43,7 +42,7 @@ export default function Overview({ challenge, community }: Props) {
4342
<div className="md:pl-2 max-w-max">
4443
<div className="flex text-sm text-gray-700">
4544
<span className="block font-medium pr-1">
46-
{community.slug === "celo" && "NFT"} {t("communities.overview.challenge.certificate")}
45+
{community?.slug === "celo" && "NFT"} {t("communities.overview.challenge.certificate")}
4746
</span>
4847
</div>
4948
<div className="text-gray-400 text-xs font-medium">{t("communities.overview.challenge.subtitle")}</div>

src/components/layout/NotificationBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default function Notification(): ReactElement {
3333
<div className="w-full flex justify-center">
3434
{error && (
3535
<div className="bg-red-50 border border-red-100 text-red-900 px-4 py-3 rounded-md relative w-full max-w-md justify-center flex" role="alert">
36-
<span className="block sm:inline">{t(error?.error?.data.message || error?.code)}</span>
36+
<span className="block sm:inline">{t(error?.error?.data?.message || error?.code)}</span>
3737
</div>
3838
)}
3939
</div>

src/components/list/Bounty.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,23 @@ interface BountyListProps {
3131
* @returns {ReactElement}
3232
*/
3333
export default function BountyList({ bounties = [], referrals = [] }: BountyListProps): ReactElement {
34-
const loading = useSelector((state: IRootState) => state.bounties.isLoading)
34+
const loading = useSelector((state: IRootState) => state.bounties.isLoading);
3535
return (
3636
<div>
3737
{bounties && !loading ? (
3838
<div className="relative w-full px-0 mb-10 space-y-0 overflow-hidden divide-y divide-gray-200 bg-gray-50 rounded-3xl lg:max-w-2xl">
3939
{referrals.map((referral) => (
4040
<Referral referral={referral} key={referral.name} />
4141
))}
42-
{bounties.map((bounty) => (
43-
<Bounty bounty={bounty} key={bounty.id} />
42+
{bounties.map((bounty, index) => (
43+
<Bounty bounty={bounty} key={`bounty-${index}-${bounty.id}`} />
4444
))}
4545
</div>
46-
) : <div className="h-24 sm:h-48 grid place-items-center">
47-
<Loader />
48-
</div>}
46+
) : (
47+
<div className="h-24 sm:h-48 grid place-items-center">
48+
<Loader />
49+
</div>
50+
)}
4951
</div>
5052
);
5153
}

src/components/sections/courses/CommunityNavigation.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Link from "next/link";
2-
import { ReactElement, useMemo } from "react";
2+
import { Fragment, ReactElement, useMemo } from "react";
33
import ChevronRightIcon from "@/icons/chevron-right.svg";
44
import { useSelector } from "@/hooks/useTypedSelector";
55

@@ -20,13 +20,13 @@ export default function CommunityNavigation({ paths }: { paths?: string[] }): Re
2020
<div className="leading-none text-gray-500">
2121
<Link href={path}>{community.name}</Link>
2222
</div>
23-
{paths?.map((path) => (
24-
<>
23+
{paths?.map((path, index) => (
24+
<Fragment key={`path-${index}`}>
2525
<div className="px-0.5">
2626
<ChevronRightIcon viewBox="0 0 20 20" className="w-3 h-3" />
2727
</div>
2828
<div className="font-medium leading-none">{path}</div>
29-
</>
29+
</Fragment>
3030
))}
3131
</div>
3232
</div>

src/contexts/AuthObserver.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ export default function AuthObserver({ children }: { children: ReactNode }) {
2929

3030
const isUserRoute = useMemo(
3131
() => (path: string) => {
32-
return matchesRoutes(path, ["/bounties", "/profile", "/profile/wallets", "/profile/referrals", "/profile/settings", "/profile/notifications"]);
32+
return (
33+
path.startsWith("/bounties/") || matchesRoutes(path, ["/bounties", "/profile", "/profile/wallets", "/profile/referrals", "/profile/settings", "/profile/notifications"])
34+
);
3335
},
3436
[]
3537
);

src/pages/bounties/[slug].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default function BountiesPage(): ReactElement {
4141
const dispatch = useDispatch();
4242

4343
const fetchBounties = useCallback(async () => {
44-
dispatch(fetchAllBounties());
44+
await dispatch(fetchAllBounties());
4545
dispatch(findBountiesBySlug(router.query.slug as string));
4646
}, [dispatch, router.query.slug]);
4747

src/pages/communities/[slug]/challenges/[challenge_id]/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,11 @@ export default function ChallengePage() {
9696

9797
useEffect(() => {
9898
if (challenge && isAuthenticated) {
99-
dispatch(getTeamByChallenge(challenge.id));
10099
dispatch(fetchChallengeAuthenticated({ id: challenge.id }));
101-
dispatch(getUserInvitesByChallenge(challenge.id));
100+
if (challenge.isTeamChallenge) {
101+
dispatch(getTeamByChallenge(challenge.id));
102+
dispatch(getUserInvitesByChallenge(challenge.id));
103+
}
102104
}
103105
}, [challenge, dispatch, isAuthenticated]);
104106

0 commit comments

Comments
 (0)