File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,7 +37,12 @@ export default function TokenPoints() {
3737
3838 useEffect ( ( ) => {
3939 let isMounted = true ;
40- const supabase = createClientClientComponent ( ) ! ;
40+ const supabase = createClientClientComponent ( ) ;
41+ if ( ! supabase ) {
42+ setError ( "Failed to initialize Supabase client." ) ;
43+ setLoading ( false ) ;
44+ return ;
45+ }
4146
4247 const fetchPointsAndCategories = async ( ) => {
4348 setLoading ( true ) ;
@@ -363,7 +368,8 @@ export default function TokenPoints() {
363368 ( sum , point ) => sum + point ,
364369 0 ,
365370 ) ;
366- const totalPoints = totalSkillPoints + attendancePoints + profilePoints ;
371+ const totalPoints =
372+ totalSkillPoints + attendancePoints + profilePoints + socialPoints ;
367373
368374 return (
369375 < Box className = "!before:absolute !before:inset-0 !before:bg-gradient-to-br !before:from-white/10 !before:to-transparent !before:pointer-events-none relative flex w-full flex-1 flex-col gap-6 overflow-hidden !border-white/10 !bg-white/5 !shadow-2xl !backdrop-blur-2xl dark:!border-slate-400/10 dark:!bg-slate-900/5" >
@@ -382,7 +388,8 @@ export default function TokenPoints() {
382388 </ h2 >
383389 < p className = "text-sm text-gray-500 dark:text-gray-400" >
384390 Total: { totalPoints } points (Skills: { totalSkillPoints } +
385- Attendance: { attendancePoints } + Profile: { profilePoints } )
391+ Attendance: { attendancePoints } + Profile: { profilePoints } +
392+ Social: { socialPoints } )
386393 </ p >
387394 </ div >
388395 </ div >
Original file line number Diff line number Diff line change @@ -409,23 +409,23 @@ export async function deletePostContentImages(
409409 }
410410}
411411
412- export const getSocialPoints = async ( userId : string ) : Promise < number | null > => {
412+ export const getSocialPoints = async ( userId : string ) : Promise < number | null > => {
413413 const supabase = await createClientServerComponent ( ) ;
414414
415- try {
416- // Fetch user's points
417- const { data , error} = await supabase . rpc (
418- "calculate_social_points" ,
419- { codev_id : userId } ,
420- ) ;
415+ try {
416+ // Fetch user's points
417+ const { data, error } = await supabase . rpc (
418+ "calculate_social_points" ,
419+ { codev_id : userId } ,
420+ ) ;
421421
422- if ( error ) throw error ;
422+ if ( error ) throw error ;
423423
424- return data ;
425- } catch ( error ) {
426- console . error ( "Failed to fetch social points:" , error ) ;
427- throw error ;
428- }
424+ return data ;
425+ } catch ( error ) {
426+ console . error ( "Failed to fetch social points:" , error ) ;
427+ throw error ;
428+ }
429429} ;
430430
431431export async function createComment (
Original file line number Diff line number Diff line change @@ -17,12 +17,14 @@ export default function FeedsPage() {
1717
1818 useEffect ( ( ) => {
1919 const fetchRole = async ( ) => {
20- const role = await getUserRole ( user ! . role_id ?? null ) ;
20+ if ( ! user ) return ;
21+ const role = await getUserRole ( user . role_id ?? null ) ;
2122 setIsAdmin ( role === "Admin" ) ;
2223 } ;
2324
2425 const fetchSocialPoints = async ( ) => {
25- const socialPoints = await getSocialPoints ( user ! . id ) ;
26+ if ( ! user ) return ;
27+ const socialPoints = await getSocialPoints ( user . id ) ;
2628 setSocialPoints ( socialPoints || 0 ) ;
2729 } ;
2830
@@ -47,8 +49,6 @@ export default function FeedsPage() {
4749 </ div >
4850 { /* Social Points Card*/ }
4951 < div className = "dark:bg-white/3 relative mt-4 w-full rounded-xl border border-white/10 bg-gray-800 p-4 text-white shadow-lg backdrop-blur-sm transition-all duration-300 hover:scale-[1.02] hover:bg-white/10 hover:shadow-lg dark:border-white/5 xl:fixed xl:right-6 xl:top-20 xl:z-50 xl:mt-0 xl:w-64" >
50- < div className = "absolute inset-0 bg-gradient-to-br from-blue-500 to-cyan-500 opacity-5 transition-opacity hover:opacity-10 xl:rounded-xl" />
51- < div className = "absolute inset-0 bg-gradient-to-br from-blue-500 to-cyan-500 opacity-5 transition-opacity hover:opacity-10" />
5252 < div className = "relative" >
5353 < div className = "mb-3 flex items-center justify-between" >
5454 < div className = "flex items-center gap-2" >
You can’t perform that action at this time.
0 commit comments