Commit 8f0dfd6 1 parent 05dbaab commit 8f0dfd6 Copy full SHA for 8f0dfd6
File tree 3 files changed +60
-10
lines changed
3 files changed +60
-10
lines changed Original file line number Diff line number Diff line change
1
+ import React , { useState , useEffect } from "react" ;
2
+ import { useSession , useSupabaseClient } from "@supabase/auth-helpers-react" ;
3
+
4
+ export default function CreateNode ( ) {
5
+ const supabase = useSupabaseClient ( ) ;
6
+ const session = useSession ( ) ;
7
+
8
+ const [ repoName , setNodeName ] = useState ( '' ) ;
9
+
10
+ const createNodeDb = async ( ) => {
11
+ try {
12
+ if ( repoName == '' ) {
13
+ return ;
14
+ } ;
15
+
16
+ const { error, data } = await supabase
17
+ . from ( "posts_old" )
18
+ . insert ( {
19
+ content : repoName ,
20
+ author : session ?. user ?. id ,
21
+ } ) ;
22
+
23
+ if ( error ) {
24
+ console . error ( "Error inserting data into Supabase, " , error . message ) ;
25
+ return ;
26
+ } ;
27
+
28
+ console . log ( "Data inserted successfully: " , data ) ;
29
+ setNodeName ( '' ) ;
30
+ } catch ( error ) {
31
+ console . error ( "Error creating node: " , error ) ;
32
+ } ;
33
+ } ;
34
+
35
+ return (
36
+ < div >
37
+ < input
38
+ type = "text"
39
+ className = "border border-gray-300 rounded-md px-3 py-2 mr-2 focus:outline-none focus:border-blue-500"
40
+ placeholder = "Enter repository name"
41
+ value = { repoName }
42
+ onChange = { ( e ) => setNodeName ( e . target . value ) }
43
+ />
44
+ < button
45
+ className = "bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded"
46
+ onClick = { createNodeDb }
47
+ >
48
+ Create Node
49
+ </ button >
50
+ </ div >
51
+ ) ;
52
+ } ;
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export default function FileUpload() {
25
25
if ( error ) {
26
26
console . error ( "Error inserting data into Supabase:" , error . message ) ;
27
27
return ;
28
- }
28
+ } ;
29
29
30
30
console . log ( "Data inserted successfully:" , data ) ;
31
31
Original file line number Diff line number Diff line change 1
1
import { useSession , useSupabaseClient } from "@supabase/auth-helpers-react" ;
2
2
import React , { useEffect , useState } from "react" ;
3
- import CoreLayout from "../components/Core/Layout" ;
4
3
import Layout from "../components/Section/Layout" ;
5
4
import { useRouter } from "next/router" ;
6
- import Login from "./login" ;
7
-
8
- import styles from '../styles/Landing.module.css' ;
9
5
import { Metadata } from "next" ;
10
6
import FileUpload from "../components/Content/FileUpload" ;
7
+ import CreateNode from "../components/Content/CreateRepo" ;
11
8
12
9
export const metadata : Metadata = {
13
- title : "Star Sailors"
10
+ title : "Star Sailors" ,
14
11
}
15
12
16
13
export default function Home ( ) {
@@ -20,7 +17,7 @@ export default function Home() {
20
17
21
18
async function logoutUser ( ) {
22
19
const { error } = await supabase . auth . signOut ( )
23
- }
20
+ } ;
24
21
25
22
const userId = session ?. user ?. id ;
26
23
@@ -29,16 +26,17 @@ export default function Home() {
29
26
< Layout >
30
27
{ /* {userId} */ }
31
28
< div className = "flex flex-col gap-4" >
29
+ < CreateNode />
32
30
< FileUpload />
33
31
</ div >
34
32
</ Layout >
35
33
// <CoreLayout>
36
- )
37
- }
34
+ ) ;
35
+ } ;
38
36
39
37
return (
40
38
< div className = "grid grid-cols-2 h-screen-navbar" >
41
39
42
40
</ div >
43
41
) ;
44
- }
42
+ } ;
You canβt perform that action at this time.
0 commit comments