@@ -4,15 +4,14 @@ import { useEffect, useState } from "react";
44import CreatePostModal from "@/components/modals/CreatePostModal" ;
55import { Button } from "@/components/ui/button" ;
66import { useUserStore } from "@/store/codev-store" ;
7- import { MessageSquareText } from "lucide-react" ;
87
98import Feed from "./_components/Feed" ;
10- import { getSocialPoints , getUserRole } from "./_services/action" ;
9+ import SocialPointsCard from "./_components/SocialPointsCard" ;
10+ import { getUserRole } from "./_services/action" ;
1111
1212export default function FeedsPage ( ) {
1313 const [ isAdmin , setIsAdmin ] = useState ( true ) ;
1414 const [ isModalOpen , setIsModalOpen ] = useState ( false ) ;
15- const [ socialPoints , setSocialPoints ] = useState ( 0 ) ;
1615 const { user } = useUserStore ( ) ;
1716
1817 useEffect ( ( ) => {
@@ -22,16 +21,7 @@ export default function FeedsPage() {
2221 setIsAdmin ( role === "Admin" ) ;
2322 } ;
2423
25- const fetchSocialPoints = async ( ) => {
26- if ( ! user ) return ;
27- const socialPoints = await getSocialPoints ( user . id ) ;
28- setSocialPoints ( socialPoints || 0 ) ;
29- } ;
30-
31- if ( user ) {
32- fetchRole ( ) ;
33- fetchSocialPoints ( ) ;
34- }
24+ if ( user ) fetchRole ( ) ;
3525 } , [ user ] ) ;
3626
3727 const openModal = ( ) => setIsModalOpen ( true ) ;
@@ -47,35 +37,9 @@ export default function FeedsPage() {
4737 Codebility community.
4838 </ p >
4939 </ div >
50- { /* Social Points Card*/ }
51- < 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" >
52- < div className = "relative" >
53- < div className = "mb-3 flex items-center justify-between" >
54- < div className = "flex items-center gap-2" >
55- < div className = "rounded-lg bg-gradient-to-br from-blue-500 to-cyan-500 p-2 text-white" >
56- < MessageSquareText className = "h-6 w-6" />
57- </ div >
58- < div >
59- < p className = "text-sm font-medium text-gray-300" >
60- Social Points
61- </ p >
62- < p className = "text-xs text-gray-500" > Feed Engagement</ p >
63- </ div >
64- </ div >
65- < div className = "text-right" >
66- < p className = "bg-gradient-to-r from-blue-600 to-cyan-600 bg-clip-text text-2xl font-bold text-transparent" >
67- { socialPoints }
68- </ p >
69- < p className = "text-xs text-gray-500" > points</ p >
70- </ div >
71- </ div >
72- < div className = "space-y-1" >
73- < p className = "text-xs text-gray-500 dark:text-gray-400" >
74- Earn more points by posting and getting likes and comments!
75- </ p >
76- </ div >
77- </ div >
78- </ div >
40+
41+ { /* Social Points Card */ }
42+ < SocialPointsCard />
7943
8044 < Button className = "mb-4 mt-4 w-auto" onClick = { openModal } >
8145 Create Post
0 commit comments