-
+
+
@@ -85,4 +122,4 @@ function NuevaVacante() {
)
}
-export default NuevaVacante
+export default NuevaOferta
diff --git a/frontend/src/pages/Register.jsx b/frontend/src/pages/Register.jsx
index e69de29..18aa7c2 100644
--- a/frontend/src/pages/Register.jsx
+++ b/frontend/src/pages/Register.jsx
@@ -0,0 +1,102 @@
+import { useContext } from "react"
+import { useState } from "react"
+import { AuthContext } from "../context/AuthContext"
+import { useNavigate } from "react-router-dom"
+import { API_URL } from "../config"
+
+function Register() {
+
+ const [username, setUsername] = useState("")
+ const [email, setEmail] = useState("")
+ const [password, setPassword] = useState("")
+ const [type, setType] = useState("")
+
+ const [error, setError] = useState("")
+
+ const { login } = useContext(AuthContext)
+ const navigate = useNavigate()
+
+ const handleSubmit = async (e) => {
+ e.preventDefault()
+
+ if (!type) return setError("Debes seleccionar un tipo de cuenta ('Busco trabajo / Ofrezco trabajo')")
+
+ const res = await fetch(`${API_URL}/register`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ username, email, password })
+ })
+
+ const data = await res.json()
+
+ if (res.ok) {
+ login(data)
+ navigate('/')
+ } else {
+ setError(data.error)
+ console.error(data.error)
+ }
+ }
+
+
+ return (
+ <>
+
+
+ >
+ )
+}
+
+export default Register