Skip to content

Commit 874be3d

Browse files
committed
fix:prepare for publish, sso referral
1 parent 2f2489c commit 874be3d

5 files changed

Lines changed: 38 additions & 17 deletions

File tree

src/app/[lang]/citizens/[id]/page.jsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export default async function citizenSinglePage({
2929
}
3030

3131
const profileData = await getUserData();
32+
console.log('profileData123',profileData.data);
33+
3234

3335

3436

@@ -74,8 +76,13 @@ export default async function citizenSinglePage({
7476

7577
//to make description less than 200 character
7678
async function makeLessCharacter(){
77-
let temp = profileData.data.customs.about
78-
temp = temp.slice(0,200)
79+
let temp;
80+
if(profileData.data?.customs?.about){
81+
temp = profileData.data.customs.about
82+
temp = temp.slice(0,200)
83+
}else(
84+
temp = ""
85+
)
7986
return temp
8087
}
8188

@@ -87,7 +94,7 @@ export default async function citizenSinglePage({
8794
return item.url
8895
}),
8996
"url": `http://rgb.irpsc.com/fa/citizen/${params.id}`,
90-
"jobTitle": `${profileData.data.customs.occupation}`,
97+
"jobTitle": `${profileData.data?.customs?.occupation}`,
9198
"description": `${await makeLessCharacter()}`,
9299
"birthDate": `${profileData.data.kyc.birth_date}`,
93100
"email": `${profileData.data.kyc.email}`,
@@ -222,8 +229,13 @@ export async function generateMetadata({ params }) {
222229

223230
//to make description less than 200 character
224231
async function makeLessCharacter(){
225-
let temp = profileData.data.customs.about
226-
temp = temp.slice(0,200)
232+
let temp;
233+
if(profileData.data?.customs?.about){
234+
temp = profileData.data.customs.about
235+
temp = temp.slice(0,200)
236+
}else(
237+
temp = ""
238+
)
227239
return temp
228240
}
229241

src/app/[lang]/citizens/layout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default async function CitizensLayout({
1313
params,
1414
}: {
1515
children: React.ReactNode;
16-
params: { lang: "en" | "fa" };
16+
params: any;
1717
}) {
1818
const defaultTheme = useServerDarkMode();
1919

@@ -63,6 +63,7 @@ export default async function CitizensLayout({
6363
tab.toShow = true;
6464
}
6565
});
66+
console.log("params4", params);
6667

6768
return (
6869
<main className="flex h-screen dark:bg-black" dir={langData.direction}>

src/app/[lang]/levels/citizen/[levelName]/[tabs]/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default async function CitizensLayout({
1313
params,
1414
}: {
1515
children: React.ReactNode;
16-
params: { lang: "en" | "fa" };
16+
params: any;
1717
}) {
1818
const defaultTheme = useServerDarkMode();
1919

src/components/module/sidebar/LoginMenuModule.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,27 @@ export default function LoginMenuModule({ isClosed, tabsMenu, params }: any) {
9090
}, [isMounted, cookies.auth]);
9191

9292
const handleLogin = async () => {
93+
let temp = pathname.split("/");
94+
let last = temp[temp.length - 1];
95+
let referral;
96+
if (last.startsWith("hm-") || last.startsWith("HM-")) {
97+
referral = last;
98+
}
99+
93100
const urlToUse = `${window.location.origin}${pathname.toString()}`;
94-
const res = await axios.get("https://api.rgb.irpsc.com/api/auth/redirect", {
95-
headers: {
96-
"Content-Type": "application/json",
97-
},
98-
params: {
99-
redirect_to: urlToUse,
100-
},
101-
});
101+
const res = await axios.get(
102+
`https://api.rgb.irpsc.com/api/auth/redirect?redirect_to=${urlToUse}&referral=${referral}`,
103+
{
104+
headers: {
105+
"Content-Type": "application/json",
106+
},
107+
}
108+
);
102109
if (res) {
103110
const redirectUrl = res.data.url;
104111
window.location.href = redirectUrl;
105112
} else {
106-
throw new Error("Failed to fetch redirectUrl, client");
113+
throw new Error("Failed to fetch redirectUrl, client!");
107114
}
108115
};
109116

src/components/module/sidebar/SideBar.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export default function SideBar({
2121
const toggleSide = useCallback(() => {
2222
setisClosed((prev) => !prev);
2323
}, []);
24-
24+
console.log('params3', params);
25+
2526
return (
2627
<>
2728
<HeaderMobile

0 commit comments

Comments
 (0)