1
1
import React , { useState } from "react" ;
2
2
import axios from "axios" ;
3
- import env from "react-dotenv" ;
4
-
5
3
import {
6
4
FaDiscord ,
7
5
FaReddit ,
@@ -12,21 +10,23 @@ import {
12
10
} from 'react-icons/fa' ;
13
11
14
12
const Contact = ( ) => {
15
- const url = env . url ;
13
+ const url = process . env . REACT_APP_API_URL ;
16
14
const [ data , setData ] = useState ( {
17
15
name : "" ,
18
16
email : "" ,
19
17
message : "" ,
20
18
} ) ;
19
+
21
20
function handle ( e ) {
22
21
const newData = { ...data } ;
23
22
newData [ e . target . id ] = e . target . value ;
24
23
setData ( newData ) ;
25
24
console . log ( newData ) ;
26
25
}
26
+
27
27
function submit ( e ) {
28
28
e . preventDefault ( ) ;
29
- console . log ( "click" ) ;
29
+ console . log ( "Submitting to:" , url ) ;
30
30
axios
31
31
. post ( url , {
32
32
name : data . name ,
@@ -35,93 +35,61 @@ const Contact = () => {
35
35
} )
36
36
. then ( ( res ) => {
37
37
console . log ( res . data ) ;
38
- alert ( "Thanks for Equiring we will shortly contact you :)" ) ;
38
+ alert ( "Thanks for inquiring, we will contact you shortly :)" ) ;
39
39
setData ( {
40
40
name : "" ,
41
41
email : "" ,
42
42
message : "" ,
43
43
} ) ;
44
+ } )
45
+ . catch ( ( error ) => {
46
+ console . error ( "Error submitting form:" , error ) ;
47
+ alert ( "There was an error submitting the form. Please try again." ) ;
44
48
} ) ;
45
49
}
50
+
46
51
return (
47
52
< div >
48
- < section class = "text-gray-400 bg-gray-1000 body-font " >
49
- < div class = "container px-5 py-24 mx-auto" >
50
- < div class = "flex flex-col text-center w-full mb-12" >
51
- < h1 class = "sm:text-3xl text-2xl font-medium title-font mb-4 text-white" >
53
+ < section className = "text-gray-400 bg-gray-1000 body-font" >
54
+ < div className = "container px-5 py-24 mx-auto" >
55
+ < div className = "flex flex-col text-center w-full mb-12" >
56
+ < h1 className = "sm:text-3xl text-2xl font-medium title-font mb-4 text-white" >
52
57
Contact Us
53
58
</ h1 >
54
- < p class = "lg:w-2/3 mx-auto leading-relaxed text-base" > </ p >
55
59
</ div >
56
- < div className = "lg:w-1/2 md:w-2/3 mx-auto mb-8" >
57
- < div className = "flex justify-center md:space-x-12 lg:space-x-14 xl:space-x-20 space-x-6" >
58
- < div className = "w-12 h-10 flex flex-col items-center" >
59
- < a href = "https://discord.com/invite/4xruwjjU9B" target = "discord" > < FaDiscord className = " hover:fill-current hover:text-[#0DFF1C] hover:w-12 " size = { 40 } /> </ a >
60
- </ div >
61
- < div className = "w-12 h-10 flex flex-col items-center" >
62
- < a href = "https://www.reddit.com/r/fosscu/" target = "discord" > < FaReddit className = " hover:fill-current hover:text-[#0DFF1C] hover:w-12 " size = { 40 } /> </ a >
63
- </ div >
64
- < div className = "w-12 h-10 flex flex-col items-center" >
65
- < a href = "Mailto:[email protected] " target = "mail" > < FaEnvelope className = " hover:fill-current hover:text-[#0DFF1C] hover:w-12 hover:h-10" size = { 35 } /> </ a >
66
- </ div >
67
- < div className = "w-12 h-10 flex flex-col items-center" >
68
- < a href = "https://www.linkedin.com/company/fosscu/" target = "linkedin" > < FaLinkedin className = " fill-current hover:text-[#0DFF1C] hover:w-12 hover:h-10" size = { 35 } /> </ a >
69
- </ div >
70
- < div className = "w-12 h-10 flex flex-col items-center" >
71
- < a href = "https://twitter.com/fosscuk" target = "twitter" > < FaTwitter className = " fill-current hover:text-[#0DFF1C] hover:w-12 hover:h-10 " size = { 35 } /> </ a >
72
- </ div >
73
- < div className = "w-12 h-10 flex flex-col items-center" >
74
- < a href = "https://matrix.to/#/#fosscu:matrix.org" target = "Matrix" > < FaNetworkWired className = " fill-current hover:text-[#0DFF1C] hover:w-12 hover:h-10 " size = { 35 } /> </ a >
75
- </ div >
60
+ < div className = "lg:w-1/2 md:w-2/3 mx-auto mb-8" >
61
+ < div className = "flex justify-center md:space-x-12 lg:space-x-14 xl:space-x-20 space-x-6" >
62
+ < SocialIcon href = "https://discord.com/invite/4xruwjjU9B" Icon = { FaDiscord } />
63
+ < SocialIcon href = "https://www.reddit.com/r/fosscu/" Icon = { FaReddit } />
64
+ < SocialIcon href = "Mailto:[email protected] " Icon = { FaEnvelope } />
65
+ < SocialIcon href = "https://www.linkedin.com/company/fosscu/" Icon = { FaLinkedin } />
66
+ < SocialIcon href = "https://twitter.com/fosscuk" Icon = { FaTwitter } />
67
+ < SocialIcon href = "https://matrix.to/#/#fosscu:matrix.org" Icon = { FaNetworkWired } />
76
68
</ div >
77
69
</ div >
78
- < div class = "lg:w-1/2 md:w-2/3 mx-auto" >
79
- < form class = "flex flex-wrap -m-2" onSubmit = { ( e ) => submit ( e ) } >
80
- < div class = "p-2 w-1/2" >
81
- < div class = "" >
82
- < label for = "name" class = "leading-7 text-sm text-gray-400" >
83
- Name
84
- </ label >
85
- < input
86
- type = "text"
87
- id = "name"
88
- onChange = { ( e ) => handle ( e ) }
89
- value = { data . name }
90
- class = "w-full bg-gray-800 hover:outline-2 bg-opacity-40 rounded border border-gray-700 focus:border-[#0dff1c] focus:bg-gray-900 focus:ring-2 focus:ring-[#0dff1c] text-base outline-none text-gray-100 py-1 px-3 leading-8 transition-colors duration-200 ease-in-out"
91
- />
92
- </ div >
93
- </ div >
94
- < div class = "p-2 w-1/2" >
95
- < div class = "" >
96
- < label for = "email" class = "leading-7 text-sm text-gray-400" >
97
- Email
98
- </ label >
99
- < input
100
- type = "email"
101
- id = "email"
102
- name = "email"
103
- onChange = { ( e ) => handle ( e ) }
104
- value = { data . email }
105
- class = "w-full bg-gray-800 bg-opacity-40 rounded border border-gray-700 focus:border-[#0dff1c] focus:bg-gray-900 focus:ring-2 focus:ring-[#0dff1c] text-base outline-none text-gray-100 py-1 px-3 leading-8 transition-colors duration-200 ease-in-out"
106
- />
107
- </ div >
108
- </ div >
109
- < div class = "p-2 w-full" >
110
- < div class = "" >
111
- < label for = "message" class = "leading-7 text-sm text-gray-400" >
112
- Message
113
- </ label >
114
- < textarea
115
- id = "message"
116
- name = "message"
117
- onChange = { ( e ) => handle ( e ) }
118
- value = { data . message }
119
- class = "w-full bg-gray-800 bg-opacity-40 rounded border border-gray-700 focus:border-[#0dff1c] focus:bg-gray-900 focus:ring-2 focus:ring-[#0dff1c] h-32 text-base outline-none text-gray-100 py-1 px-3 resize-none leading-6 transition-colors duration-200 ease-in-out"
120
- > </ textarea >
121
- </ div >
122
- </ div >
123
- < div class = "p-2 w-full" >
124
- < button class = "flex mx-auto tracking-tight font-semibold text-black bg-[#00ff11c4] border-0 py-2 px-8 focus:outline-none hover:bg-[#0dff1c] rounded text-lg" >
70
+ < div className = "lg:w-1/2 md:w-2/3 mx-auto" >
71
+ < form className = "flex flex-wrap -m-2" onSubmit = { submit } >
72
+ < InputField
73
+ id = "name"
74
+ label = "Name"
75
+ value = { data . name }
76
+ onChange = { handle }
77
+ />
78
+ < InputField
79
+ id = "email"
80
+ label = "Email"
81
+ type = "email"
82
+ value = { data . email }
83
+ onChange = { handle }
84
+ />
85
+ < TextArea
86
+ id = "message"
87
+ label = "Message"
88
+ value = { data . message }
89
+ onChange = { handle }
90
+ />
91
+ < div className = "p-2 w-full" >
92
+ < button className = "flex mx-auto tracking-tight font-semibold text-black bg-[#00ff11c4] border-0 py-2 px-8 focus:outline-none hover:bg-[#0dff1c] rounded text-lg" >
125
93
Submit
126
94
</ button >
127
95
</ div >
@@ -133,4 +101,6 @@ const Contact = () => {
133
101
) ;
134
102
} ;
135
103
136
- export default Contact ;
104
+ // ... (SocialIcon, InputField, and TextArea components remain the same)
105
+
106
+ export default Contact ;
0 commit comments