Skip to content

Commit 53e45bf

Browse files
refactor: resolve conflicts withing referrals service
2 parents aeb8f00 + c88b399 commit 53e45bf

File tree

9 files changed

+64
-12
lines changed

9 files changed

+64
-12
lines changed

public/locales/bg/common.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,10 @@
207207
"testimonials.community.stats.card-3.description": "learners gave to submissions of their peers.",
208208
"testimonials.community.join": "{{appName}} on Discord",
209209
"testimonials.text": "Dacade is really encouraging, I didn't realize the little that I know would matter. Thank you for making us learn more and to make research too.",
210-
"footer.text": "Dacade is created in collaboration with multiple contributors. If you are interested in collaborating, please <a href=\"https://discord.gg/U38KQHDtHe\">get in touch.</a>",
210+
"footer.text": "Dacade е отворена платформа и е създадена в сътрудничество с множество приносители. Отидете на <a href=\"https://github.com/dacadeorg/dacade-frontend-app\"> хранилището </a>, за да започнете да допринасяте.",
211211
"footer.privacy-policy": "Impressum & Privacy Policy",
212+
"footer.open.source": "Дакейд е платформа с отворен код.",
213+
"footer.open.source.contribute": "Станете един от нашите сътрудници",
212214
"feedback.bounty": "Feedback bounty",
213215
"feedback.issued": "Issued",
214216
"feedback.ends": "ending in ",

public/locales/en/common.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,10 @@
211211
"testimonials.community.stats.card-3.description": "learners gave to submissions of their peers.",
212212
"testimonials.community.join": "{{appName}} on Discord",
213213
"testimonials.text": "Dacade is really encouraging, I didn't realize the little that I know would matter. Thank you for making us learn more and to make research too.",
214-
"footer.text": "Dacade is created in collaboration with multiple contributors. If you are interested in collaborating, please <a href=\"https://discord.gg/U38KQHDtHe\">get in touch.</a>",
214+
"footer.text": "Dacade is an open-sourced platform and is created in collaboration with multiple contributors. Go to the <a href=\"https://github.com/dacadeorg/dacade-frontend-app\"> repository </a> to start contributing.",
215215
"footer.privacy-policy": "Impressum & Privacy Policy",
216+
"footer.open.source" : "Dacade is an open-sourced platform.",
217+
"footer.open.source.contribute":"Become one of our contributors",
216218
"feedback.bounty": "Feedback bounty",
217219
"feedback.issued": "Issued",
218220
"feedback.ends": "ending in ",

public/locales/es/common.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@
209209
"testimonials.community.stats.card-3.description": "los estudiantes mostraron sus propuestas a sus compañeras",
210210
"testimonials.community.join": "{{appName}} en Discord",
211211
"testimonials.text": "Dacade es muy motivadora, no era consciente de que mis pocos conocimientos podrían ser útiles. Gracias por permitirnos aprender e investigar más.",
212-
"footer.text": "Dacade ha sido creada en colaboración con múltiples contribuciones. Si le interesa colaborar <a href=\"https://discord.gg/U38KQHDtHe\">contáctenos.</a>",
212+
"footer.text": "Dacade es una plataforma de código abierto y se creó en colaboración con múltiples contribuyentes. Visita el <a href=\"https://github.com/dacadeorg/dacade-frontend-app\"> repositorio </a> para empezar a contribuir.",
213+
"footer.open.source": "Dacade es una plataforma de código abierto.",
214+
"footer.open.source.contribute": "Conviértase en uno de nuestros colaboradores",
213215
"footer.privacy-policy": "Impressum & Política de Privacidad",
214216
"feedback.bounty": "Premio por Feedback",
215217
"feedback.issued": "Emitido",

public/locales/hr/common.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,10 @@
207207
"testimonials.community.stats.card-3.description": "learners gave to submissions of their peers.",
208208
"testimonials.community.join": "{{appName}} on Discord",
209209
"testimonials.text": "Dacade is really encouraging, I didn't realize the little that I know would matter. Thank you for making us learn more and to make research too.",
210-
"footer.text": "Dacade is created in collaboration with multiple contributors. If you are interested in collaborating, please <a href=\"https://discord.gg/U38KQHDtHe\">get in touch.</a>",
210+
"footer.text": "Dacade je platforma s otvorenim kodom i stvorena je u suradnji s višestrukim suradnicima. Posjetite <a href=\"https://github.com/dacadeorg/dacade-frontend-app\"> repozitorij </a> kako biste počeli doprinositi.",
211211
"footer.privacy-policy": "Impressum & Privacy Policy",
212+
"footer.open.source": "Dacade je platforma otvorenog koda.",
213+
"footer.open.source.contribute": "Postanite jedan od naših suradnika",
212214
"feedback.bounty": "Feedback bounty",
213215
"feedback.issued": "Issued",
214216
"feedback.ends": "ending in ",

src/components/cards/profile/Request.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
import { useSelector } from "@/hooks/useTypedSelector";
1+
import { useMultiSelector } from "@/hooks/useTypedSelector";
22
import Avatar from "@/components/ui/Avatar";
33
import { ReactElement } from "react";
44
import { useRouter } from "next/router";
55
import Right from "@/icons/angle-right.svg";
66
import Link from "next/link";
7+
import { Referral } from "@/types/community";
8+
import { IRootState } from "@/store";
9+
10+
interface ReferralsMultiSelector {
11+
referrals: Referral[];
12+
count: number;
13+
}
714

815
/**
916
* Request component
@@ -13,7 +20,10 @@ import Link from "next/link";
1320
* @returns {}
1421
*/
1522
export default function Request(): ReactElement {
16-
const referrals = useSelector((state) => state.userReferrals.userReferralList);
23+
const { referrals, count } = useMultiSelector<unknown, ReferralsMultiSelector>({
24+
referrals: (state: IRootState) => state.userReferrals.userReferralList,
25+
count: (state: IRootState) => state.userReferrals.count,
26+
});
1727
const previewList = referrals.slice(0, 3);
1828
const router = useRouter();
1929

@@ -31,14 +41,13 @@ export default function Request(): ReactElement {
3141
))}
3242
</div>
3343
<div className="relative pl-3 font-normal cursor-pointer md:flex md:font-medium" onClick={onClick}>
34-
<span className="md:inline-block">{referrals?.length} Friends have used your invite code</span>
44+
<span className="md:inline-block">{count} Friends have used your invite code</span>
3545
</div>
3646
</div>
3747

3848
<div className="md:pl-4 py-4 md:py-0">4 Pending invitations</div>
3949
</div>
4050
<Link href={`/profile/referrals`} className="text-primary flex items-center justify-between gap-4 cursor-pointer">
41-
{" "}
4251
<span>See all</span>
4352
<Right />
4453
</Link>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import Link from "next/link";
2+
import ArrowRightIcon from "@/icons/arrow-right.svg";
3+
import { useTranslation } from "next-i18next";
4+
5+
/**
6+
* Open source section
7+
* @date 3/27/2023 - 5:26:28 PM
8+
*
9+
* @export
10+
* @returns {ReactElement}
11+
*/
12+
13+
export default function OpenSource() {
14+
const { t } = useTranslation();
15+
return (
16+
<div className="text-4xl lg:text-5xl pt-24 flex flex-col text-wrap space-y-2">
17+
<p >
18+
{t("footer.open.source")}
19+
<br className="block md:hidden lg:block" />
20+
<Link href="https://github.com/dacadeorg/dacade-frontend-app" target="_blank" className="text-primary items-center space-x-2">
21+
<span> {t("footer.open.source.contribute")}</span>
22+
<ArrowRightIcon className="w-6.5 h-5.5 inline-flex" />
23+
</Link>
24+
</p>
25+
</div>
26+
);
27+
}

src/components/sections/homepage/Testimonials.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ReactElement } from "react";
44
import CommunityStats from "./_partials/testimonials/CommunityStats";
55
import { useTranslation } from "next-i18next";
66
import { TFunction } from "i18next";
7+
import OpenSource from "./OpenSource";
78

89
/**
910
* Interface for the testimonial
@@ -80,6 +81,7 @@ export default function TestimonialsSection(): ReactElement {
8081
<Section type="secondary-light" padding="py-6 xl:py-10 md:py-8 mt-5">
8182
<CommunityStats />
8283
<Stories list={stories(t)} />
84+
<OpenSource/>
8385
</Section>
8486
);
8587
}

src/store/feature/user/referrals.slice.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ interface UserReferralsState {
99
userReferralList: Referral[];
1010
current: Referral | null;
1111
hasMore: boolean;
12+
count: number;
1213
}
1314

1415
const initialState: UserReferralsState = {
1516
userReferralList: [],
1617
current: null,
1718
hasMore: true,
19+
count: 0,
1820
};
1921

2022
/**
@@ -38,9 +40,12 @@ const userReferralsSlice = createSlice({
3840
setHasMoreReferrals: (state, action) => {
3941
state.hasMore = action.payload;
4042
},
43+
setCount: (state, action) => {
44+
state.count = action.payload;
45+
},
4146
},
4247
});
4348

44-
export const { setCurrent, clear, setUserReferralsList, setHasMoreReferrals } = userReferralsSlice.actions;
49+
export const { setCurrent, clear, setUserReferralsList, setHasMoreReferrals, setCount } = userReferralsSlice.actions;
4550

4651
export default userReferralsSlice;

src/store/services/referrals.service.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import baseQuery from "@/config/baseQuery";
22
import { createApi } from "@reduxjs/toolkit/dist/query";
33
import { setReferralsList } from "../feature/referrals.slice";
4-
import { clear, setUserReferralsList, setHasMoreReferrals } from "../feature/user/referrals.slice";
4+
import { clear, setUserReferralsList, setHasMoreReferrals, setCount } from "../feature/user/referrals.slice";
55
import { Referral } from "@/types/community";
66

77
/**
@@ -43,9 +43,10 @@ const referralsService = createApi({
4343
dispatch(clear());
4444
}
4545

46-
list.push(...(data.list || []));
46+
list.push(...(data?.list || []));
4747
dispatch(setUserReferralsList(list));
48-
dispatch(setHasMoreReferrals(data.list?.length > 0 ? true : false));
48+
dispatch(setCount(data?.count));
49+
dispatch(setHasMoreReferrals(data?.list?.length > 0 ? true : false));
4950
} catch (error) {
5051
console.log("error in fetching the userFetchReferrals ", error);
5152
}

0 commit comments

Comments
 (0)