@@ -5,6 +5,17 @@ import { PostCardSingle } from "@/content/Posts/PostSingle";
5
5
import { useSession , useSupabaseClient } from "@supabase/auth-helpers-react" ;
6
6
import StarnetLayout from "@/components/Layout/Starnet" ;
7
7
8
+ interface Classification {
9
+ id : number ;
10
+ created_at : string ;
11
+ content : string | null ;
12
+ author : string | null ;
13
+ anomaly : number | null ;
14
+ media : any | null ;
15
+ classificationtype : string | null ;
16
+ classificationConfiguration : any | null ;
17
+ } ;
18
+
8
19
export default function Starnet ( ) {
9
20
const supabase = useSupabaseClient ( ) ;
10
21
const session = useSession ( ) ;
@@ -19,41 +30,41 @@ export default function Starnet() {
19
30
setLoading ( false ) ;
20
31
return ;
21
32
}
22
-
33
+
23
34
setLoading ( true ) ;
24
35
setError ( null ) ;
25
36
try {
26
37
const { data, error } = await supabase
27
- . from ( " classifications" )
28
- . select ( "*, classificationConfiguration, classificationtype" )
29
- . eq ( " author" , session . user . id )
30
- . order ( " created_at" , { ascending : false } ) ;
31
-
38
+ . from ( ' classifications' )
39
+ . select ( '*' )
40
+ . eq ( ' author' , session . user . id )
41
+ . order ( ' created_at' , { ascending : false } ) as { data : Classification [ ] ; error : any } ;
42
+
32
43
if ( error ) throw error ;
33
-
44
+
34
45
const processedData = data . map ( ( classification ) => {
35
46
const media = classification . media ;
36
47
let images : string [ ] = [ ] ;
37
-
48
+
38
49
if ( Array . isArray ( media ) && media . length === 2 && typeof media [ 1 ] === "string" ) {
39
50
images . push ( media [ 1 ] ) ;
40
51
} else if ( media && media . uploadUrl ) {
41
52
images . push ( media . uploadUrl ) ;
42
53
}
43
-
54
+
44
55
const votes = classification . classificationConfiguration ?. votes || 0 ;
45
-
56
+
46
57
return { ...classification , images, votes } ;
47
58
} ) ;
48
-
59
+
49
60
setClassifications ( processedData ) ;
50
61
} catch ( error ) {
51
62
console . error ( "Error fetching classifications:" , error ) ;
52
63
setError ( "Failed to load classifications." ) ;
53
64
} finally {
54
65
setLoading ( false ) ;
55
66
}
56
- } ;
67
+ } ;
57
68
58
69
useEffect ( ( ) => {
59
70
fetchClassifications ( ) ;
0 commit comments