1
+ import { useSession , useSupabaseClient } from "@supabase/auth-helpers-react" ;
2
+ import { Button } from "../../_Core/ui/Button" ;
3
+ import { Card , CardContent , CardDescription , CardHeader , CardTitle } from "../../_Core/ui/Card" ;
4
+ import { Form , FormControl , FormField , FormItem , FormMessage } from "../../_Core/ui/Form" ;
5
+ import { Textarea } from "../../_Core/ui/TextArea" ;
6
+ import { useToast } from "../../_Core/ui/use-toast" ;
7
+ import { zodResolver } from "@hookform/resolvers/zod" ;
8
+ import { VenetianMask } from "lucide-react" ;
9
+ import React , { useContext , useEffect , useState } from "react" ;
10
+ import { useForm } from "react-hook-form" ;
11
+ import { UserContext } from "../../../context/UserContext" ;
12
+ import { useRouter } from "next/router" ;
13
+ import { Avatar , AvatarFallback } from "../../_Core/ui/Avatar" ;
14
+ import { AvatarImage } from "@radix-ui/react-avatar" ;
15
+
16
+ // -----------
17
+ import PostFormCardAnomalyTag from "./AnomalyPostFormCard" ; // This is important -> this file is for post creation not specifically for (referencing components on top of anomalies instead) classifications. Anomaly is for posts as classifications
18
+ import { ClimbingBoxLoader } from "react-spinners" ;
19
+ // -----------
20
+
21
+ type TProps = {
22
+ category_id : "1" | "2" ,
23
+ openCreateMenu : boolean ;
24
+ setOpenCreateMenu : ( value : React . SetStateAction < boolean > ) => void ;
25
+ setCreatedPost : ( value : React . SetStateAction < boolean > ) => void ;
26
+ } ;
27
+
28
+ // Look into methods to engage resource gathering with the lightcurves, make it a scrollable feed with planet content, show how the curves lead into the rover.
29
+
30
+ export function RoverContentPostForm ( { metadata, imageLink, sector } ) {
31
+ const supabase = useSupabaseClient ( ) ;
32
+ const session = useSession ( ) ;
33
+
34
+ const [ postContent , setPostContent ] = useState ( '' ) ;
35
+ const [ media , setMedia ] = useState ( [ ] ) ;
36
+
37
+ function createRoverClassification ( ) {
38
+ supabase
39
+ . from ( 'contentROVERIMAGES' )
40
+ . insert ( {
41
+ author : session ?. user ?. id ,
42
+ metadata : metadata ,
43
+ imageLink : imageLink ,
44
+ content : postContent ,
45
+ media : media ,
46
+ sector : sector ,
47
+ } , ) ;
48
+ } ;
49
+
50
+ const handlePostSubmit = async ( ) => {
51
+ if ( postContent ) {
52
+ const user = session ?. user ?. id ;
53
+ if ( user ) {
54
+ const response = await supabase . from ( 'contentROVERIMAGES' ) . upsert ( [
55
+ {
56
+ author : user ,
57
+ metadata : metadata ,
58
+ imageLink : imageLink ,
59
+ // planet: '1', // Change this when upserting in planets/[id].tsx
60
+ // basePlanet: '1',
61
+ content : postContent ,
62
+ media : null , // See slack comms
63
+ sector : sector ,
64
+ } ,
65
+ ] ) ;
66
+
67
+ if ( response . error ) {
68
+ console . error ( response . error ) ;
69
+ } else {
70
+ setPostContent ( '' ) ;
71
+ }
72
+ }
73
+ } ;
74
+ }
75
+
76
+ return (
77
+ < div className = "flex gap-2" >
78
+ { /* <Avatar>
79
+ <AvatarFallback>{session?.user?.id}</AvatarFallback>
80
+ </Avatar> */ }
81
+ < textarea value = { postContent } onChange = { e => setPostContent ( e . target . value ) } className = "grow p-3 h-24 rounded-xl" placeholder = { "What do you think about this image" } />
82
+ < div className = "text-center" >
83
+ < button onClick = { handlePostSubmit } className = "text-black px-2 py-1 rounded-md" > Share</ button >
84
+ </ div >
85
+ </ div >
86
+ ) ;
87
+ } ;
0 commit comments