diff --git a/src/App.tsx b/src/App.tsx index d23dff92..9d91bae0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -9,6 +9,7 @@ import SkillSet from './components/AboutPage/SkillSet' import GithubStats from './components/AboutPage/Github' import Projects from './components/Projects' import Page404 from './components/static/404' +import ContactPage from './components/ContactPage' // import logo from './logo.svg'; // import './App.css'; @@ -26,6 +27,7 @@ function App () { } /> } /> + } /> } /> ) diff --git a/src/components/ContactPage/index.tsx b/src/components/ContactPage/index.tsx new file mode 100644 index 00000000..7089482e --- /dev/null +++ b/src/components/ContactPage/index.tsx @@ -0,0 +1,95 @@ +import { useState } from "react" + +const isDev = process.env.NODE_ENV !== 'production' +export default function ContactPage() { + const [done, setDone] = useState(false) + const [error, setError] = useState(null) + const [email, setEmail] = useState("") + const [message, setMessage] = useState("") + const [nameOfPerson, setName] = useState("") + const onSubmit = (e: any) => { + if(isDev) { + // dev mode dosent have php backend so i have to run it do ABSOULTLEY NOTHING! + // just pretend it works + console.log(` + To: ${nameOfPerson} (${email}) + ${message} + `) +if(Math.random() > .5) { + setDone(true) +} else { + setError(`Math.random was NOT higher then .5`) +} + } else { + const form = new FormData(e.target) + fetch('/contact_form.php', { + body: form + }).then(e => { + return e.text() + }).then(text => { + if(text == "OK") { + setDone (true) + } else { + setError (text as string) + } + }) + } + } + const ui = (f: any) => (e: any) => f(e.target.value) + return
+
+
+

Contact Form

+ {/*

Provident cupiditate voluptatem et in. Quaerat fugiat ut assumenda excepturi exercitationem quasi. In deleniti eaque aut repudiandae et a id nisi.

*/} +{(error || done) ? : } + {/* */} +
+
+
+} +export function FormResults({ error, email, done } : { + error: string | null, + email: string, + done: Boolean +}) { +if(done) return
+

Thank you for your message! you will eventually recive a response at {email}

+
+ if(error) { + return

{error}

+ } + return

idk

+} +export function ContactForm({ onSubmit, + nameOfPerson, message, email, + uiE,uiN,uiM +}: any) { + return
+ + + +
+ +
+
+} \ No newline at end of file