Skip to content

Commit 1dfded3

Browse files
committed
Merge branch 'dev' into stage
2 parents ca518f2 + 71afd1c commit 1dfded3

File tree

13 files changed

+54
-58
lines changed

13 files changed

+54
-58
lines changed

public/locales/bg/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
"communities.overview.courses.description": "In the courses of this community, you will be able to learn about new technologies, solve challenges, get feedback and earn bounties.",
168168
"communities.overview.scoreboard.title": "Scoreboard",
169169
"communities.overview.scoreboard.description": "On the scoreboard, you can see which users have accumulated the most reputation by giving valuable feedback to their peers.",
170+
"communities.scoreboard.empty-state.title": "Няма оценки за тази категория.",
170171
"communities.card.estimated": "Estimated Time",
171172
"communities.card.earn": "Earn rewards",
172173
"communities.card.submissions": "{{count}} Изявления",

public/locales/en/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
"communities.overview.courses.description": "In the courses of this community, you will be able to learn about new technologies, solve challenges, get feedback and earn bounties.",
171171
"communities.overview.scoreboard.title": "Scoreboard",
172172
"communities.overview.scoreboard.description": "On the scoreboard, you can see which users have accumulated the most reputation by giving valuable feedback to their peers.",
173+
"communities.scoreboard.empty-state.title": "No scores for this category",
173174
"communities.card.estimated": "Estimated Time",
174175
"communities.card.earn": "Earn rewards",
175176
"communities.card.submissions": "{{count}} Submissions",

public/locales/es/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
"communities.overview.courses.description": "En los cursos de esta comunidad, podrá aprender sobre nuevas tecnologías, resolver retos, recibir feedbacks y ganar premios.",
171171
"communities.overview.scoreboard.title": "Tabla de Resultados",
172172
"communities.overview.scoreboard.description": "En la tabla de resultados, puede ver qué usuarios han acumulado la mejor reputación dando su valioso feedback a sus compañeras.",
173+
"communities.scoreboard.empty-state.title": "No hay puntuaciones para esta categoría.",
173174
"communities.card.estimated": "Tiempo estimado",
174175
"communities.card.earn": "Gane recompensas",
175176
"communities.card.submissions": "{{count}} Envíos",

public/locales/hr/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
"communities.overview.courses.description": "In the courses of this community, you will be able to learn about new technologies, solve challenges, get feedback and earn bounties.",
155155
"communities.overview.scoreboard.title": "Scoreboard",
156156
"communities.overview.scoreboard.description": "On the scoreboard, you can see which users have accumulated the most reputation by giving valuable feedback to their peers.",
157+
"communities.scoreboard.empty-state.title": "Nema bodova za ovu kategoriju.",
157158
"communities.card.estimated": "Estimated Time",
158159
"communities.card.earn": "Earn rewards",
159160
"communities.overview.challenge.rewards": "Nagrade",

src/components/cards/Scoreboard.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface ScoreboardCardProps {
1414
feedbacks: number;
1515
score: number;
1616
submissions: number;
17+
submissionPoints: number;
1718
};
1819
index: number;
1920
}
@@ -42,8 +43,8 @@ export default function ScoreboardCard({ value, index }: ScoreboardCardProps): J
4243
<span>{value.submissions === 1 ? "Submission" : "Submissions"}</span>
4344
</p>
4445
<p className="whitespace-nowrap sm:px-4 px-3 text-xs space-x-1">
45-
<span>{value.score}</span>
46-
<span>{value.score === 1 ? "Total Point" : "Total Points"}</span>
46+
<span>{value.submissionPoints}</span>
47+
<span>{value.submissionPoints === 1 ? "Submission Point" : "Submission Points"}</span>
4748
</p>
4849
<p className="whitespace-nowrap text-xs sm:px-4 px-3 space-x-1">
4950
<span>{value.feedbacks}</span>

src/components/layout/Navbar.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { Colors } from "@/types/community";
1515
import classNames from "classnames";
1616
import Loader from "../ui/Loader";
1717
import { IRootState } from "@/store";
18+
import { User } from "@/types/bounty";
1819

1920
interface NavbarProps {
2021
settings?: {
@@ -38,13 +39,14 @@ interface NavbarProps {
3839
export default function Navbar({ settings, sidebarBurgerColor = false }: NavbarProps): ReactElement {
3940
const { t } = useTranslation();
4041
const router = useRouter();
41-
const { isAuthenticated, isAuthenticatedAndVerified, isAuthLoading } = useMultiSelector<
42+
const { isAuthenticated, isAuthenticatedAndVerified, isAuthLoading, authData } = useMultiSelector<
4243
unknown,
43-
{ isAuthenticated: boolean; isAuthenticatedAndVerified: boolean; isAuthLoading: boolean }
44+
{ isAuthenticated: boolean; isAuthenticatedAndVerified: boolean; isAuthLoading: boolean; authData: User }
4445
>({
4546
isAuthenticatedAndVerified: (state: IRootState) => authVerify(state),
4647
isAuthenticated: (state: IRootState) => authCheck(state),
4748
isAuthLoading: (state: IRootState) => state.auth.isAuthLoading,
49+
authData: (state: IRootState) => state.auth.data,
4850
});
4951

5052
const colors = useMemo(() => {
@@ -94,7 +96,7 @@ export default function Navbar({ settings, sidebarBurgerColor = false }: NavbarP
9496
</ul>
9597
)}
9698

97-
{isAuthLoading ? (
99+
{isAuthLoading && !authData ? (
98100
<ul className="ml-auto relative">
99101
<Loader isSmallSpinner />
100102
</ul>

src/components/list/Objectives.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface ObjectiveProps {
2323
*/
2424
export default function ObjectiveList({ iconcolor = "", crossmark = false, objectives = [] }: ObjectiveProps): ReactElement {
2525
return (
26-
<div className="flex flex-col gap-y-3 md:grid md:w-99 md:gap-x-3 md:items-stretch pt-6 md:pb-2 md:mb-2">
26+
<div className="flex flex-col gap-y-3 md:grid md:w-fit md:gap-x-3 md:items-stretch pt-6 md:pb-2 md:mb-2">
2727
{objectives.map((objective, index) => (
2828
<Objective key={`objective-list-${index}`} crossmark={crossmark} objective={objective} iconcolor={iconcolor} />
2929
))}

src/components/sections/communities/overview/scoreboard/Filter.tsx

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { ChangeEvent, ReactElement, useCallback, useEffect, useState } from "react";
22
import FilterOption from "./_partials/FilterOption";
3-
import { selectList, setLoading, setFilterBy as setScoreboardFilterBy, setScoreboardList, sortScoreboards } from "@/store/feature/communities/scoreboard.slice";
3+
import { setLoading } from "@/store/feature/communities/scoreboard.slice";
44
import { useDispatch } from "@/hooks/useTypedDispatch";
55
import { useRouter } from "next/router";
6-
import { useSelector } from "@/hooks/useTypedSelector";
76
import { filterScoreboards } from "@/store/services/communities/scoreboard.service";
87

98
/**
@@ -76,12 +75,11 @@ export default function Filters(): ReactElement {
7675
const [sortBy, setSortBy] = useState("score");
7776

7877
const dispatch = useDispatch();
79-
const list = useSelector((state) => selectList(state));
80-
const filteredScoreboards = useSelector((state) => selectList(state));
8178
const router = useRouter();
8279
const { slug } = router.query;
8380

8481
const onFilterScoreboards = useCallback(async () => {
82+
dispatch(setLoading(true));
8583
await dispatch(
8684
filterScoreboards({
8785
slug: slug as string,
@@ -90,28 +88,13 @@ export default function Filters(): ReactElement {
9088
locale: router.locale as string,
9189
})
9290
);
93-
const data = filteredScoreboards;
94-
if (data) {
95-
const filteredData = [...data];
96-
dispatch(setScoreboardFilterBy(filterBy));
97-
if (sortBy) {
98-
filteredData?.sort((firstItem, secondItem) => secondItem[sortBy] - firstItem[sortBy]);
99-
}
100-
dispatch(setScoreboardList(filteredData));
101-
}
102-
setLoading(true);
91+
dispatch(setLoading(false));
10392
}, [dispatch, filterBy, router.locale, slug, sortBy]);
10493

10594
useEffect(() => {
10695
onFilterScoreboards();
10796
}, [onFilterScoreboards]);
10897

109-
useEffect(() => {
110-
dispatch(setScoreboardList(sortScoreboards({ sortBy, list })));
111-
// Eslint disable because the list is running the effect infinitely
112-
// eslint-disable-next-line react-hooks/exhaustive-deps
113-
}, [dispatch, sortBy]);
114-
11598
const handleFilterByChange = (event: ChangeEvent<HTMLInputElement>) => {
11699
const newValue = event.target.value;
117100
if (newValue === filterBy) return;

src/components/sections/communities/overview/scoreboard/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import ScoreboardCard from "@/components/cards/Scoreboard";
33
import ArrowButton from "@/components/ui/button/Arrow";
44
import { useTranslation } from "next-i18next";
55
import { ReactElement, useState } from "react";
6+
import Loader from "@/components/ui/Loader";
7+
import EmptyState from "@/components/ui/EmptyState";
68

79
/**
810
* Scoreboard Overview index component
@@ -14,7 +16,7 @@ import { ReactElement, useState } from "react";
1416

1517
export default function ScoreboardOverview(): ReactElement {
1618
const { t } = useTranslation();
17-
const { list, filterBy } = useSelector((state) => state.scoreboard);
19+
const { list, loading } = useSelector((state) => state.scoreboard);
1820

1921
const [items, setItems] = useState(3);
2022

@@ -24,7 +26,11 @@ export default function ScoreboardOverview(): ReactElement {
2426

2527
return (
2628
<>
27-
{(list && list.length !== 0) || filterBy !== "all" ? (
29+
{loading ? (
30+
<div className="h-full w-full grid">
31+
<Loader className="place-self-center" />
32+
</div>
33+
) : list && list.length !== 0 ? (
2834
<div className="flex flex-col w-full overflow-hidden border border-gray-200 border-solid divide-y divide-gray-200 divide-solid rounded-3xl">
2935
{list.slice(0, items).map((item, i) => (
3036
<ScoreboardCard key={`list-element-${i}`} index={i + 1} value={item} />
@@ -38,7 +44,9 @@ export default function ScoreboardOverview(): ReactElement {
3844
)}
3945
</div>
4046
) : (
41-
<></>
47+
<div className=" w-full overflow-hidden border-t border-gray-200 ">
48+
<EmptyState title={t("communities.scoreboard.empty-state.title")} />
49+
</div>
4250
)}
4351
</>
4452
);

src/components/ui/Avatar.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,20 @@ export default function Avatar({
118118
className={`bg-primary h-full w-full flex overflow-hidden text-white items-center justify-center uppercase leading-none align-middle relative z-0 ${shapeClassName}`}
119119
>
120120
{user && user.avatar && userAvatarLoaded ? (
121-
<Image
122-
src={user.avatar}
123-
alt="user-avatar"
124-
fill={true}
125-
className="object-cover w-full h-full"
126-
onError={() => {
127-
setUserAvatarLoaded(false);
128-
}}
129-
/>
121+
<div>
122+
<Image
123+
src={user.avatar}
124+
alt="user-avatar"
125+
fill={true}
126+
className="object-cover w-full h-full relative z-10"
127+
onError={() => {
128+
setUserAvatarLoaded(false);
129+
}}
130+
/>
131+
<div className="absolute inset-0 z-0 h-full flex items-center justify-center">
132+
<span >{initials}</span>
133+
</div>
134+
</div>
130135
) : (
131136
<span>{initials}</span>
132137
)}

0 commit comments

Comments
 (0)