Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angel #251

Merged
merged 10 commits into from
Nov 15, 2023
Merged

Angel #251

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions uniEmpleos/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import React from "react"
import Page from "./pages/index"
import "./assets/fonts/fonts.css"
import "./App.css"
import LanguageButton from "./components/LanguageButton/LanguageButton"

function App() {
return (
<StoreContext.Provider value={store}>
<div className="App">
<Page />
</div>
<LanguageButton />
</StoreContext.Provider>
)
}
Expand Down
35 changes: 35 additions & 0 deletions uniEmpleos/src/Hooks/useLanguage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { useStoreon } from "storeon/react"
import { useState } from "react"

const useLanguage = () => {
const { language, dispatch } = useStoreon("language")
const [ currentLanguage, setCurrentLanguage ] = useState(language.currentLanguage)

const changeLanguage = () => {
if (language.currentLanguage === "es") {
dispatch("language/config", {
currentLanguage: "en",
})
setCurrentLanguage("en")
return "en"
} else {
dispatch("language/config", {
currentLanguage: "es",
})
setCurrentLanguage("es")
return "es"
}
}

const getLanguage = () => {
return currentLanguage
}

return {
currentLanguage,
changeLanguage,
getLanguage,
}
}

export default useLanguage
22 changes: 12 additions & 10 deletions uniEmpleos/src/components/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import { LuLogOut } from "react-icons/lu"
import Logo from "../Logo/Logo"
import "./header.css"
import { navigate } from "../../store"
import { useTranslation } from "react-i18next"

const handleClick = () => {
navigate("/login")
}

export const Header = () => {
const { t } = useTranslation()
const [showNavbar, setShowNavbar] = useState(false)

const handleShowNavbar = () => {
Expand Down Expand Up @@ -41,10 +43,10 @@ export const Header = () => {
return (
<div className="actions">
<div className="actionlinks">
<a href="/editprofileestudiante">Perfil</a>
<a href="/profile">Vacantes</a>
<a href="/postulaciones">Postulaciones</a>
<a href="/chat">Chat</a>
<a href="/editprofileestudiante">{t("header.student.profile")}</a>
<a href="/profile">{t("header.student.offers")}</a>
<a href="/postulaciones">{t("header.student.postulations")}</a>
<a href="/chat">{t("header.student.chat")}</a>
</div>
<div className="buttonLogoutMobile" onClick={handleClick}>
<LuLogOut size={30} style={{ color: "#000" }} />
Expand All @@ -55,10 +57,10 @@ export const Header = () => {
return (
<div className="actions">
<div className="actionlinks">
<a href="/editprofileempresa">Perfil</a>
<a href="/newoffer">Crear Empleo</a>
<a href="/postulacionempresa">Mis Ofertas</a>
<a href="/chat">Chat</a>
<a href="/editprofileempresa">{t("header.enterprise.profile")}</a>
<a href="/newoffer">{t("header.enterprise.newOffer")}</a>
<a href="/postulacionempresa">{t("header.enterprise.myOffers")}</a>
<a href="/chat">{t("header.enterprise.chat")}</a>
</div>
<div className="buttonLogoutMobile" onClick={handleClick}>
<LuLogOut size={30} style={{ color: "#000" }} />
Expand All @@ -69,8 +71,8 @@ export const Header = () => {
return (
<div className="actions">
<div className="actionlinks">
<a href="/profileadmin">Empresas</a>
<a href="/profileadminstudent">Estudiantes</a>
<a href="/profileadmin">{t("header.admin.enterprises")}</a>
<a href="/profileadminstudent">{t("header.admin.students")}</a>
</div>
<div className="buttonLogoutMobile" onClick={handleClick}>
<LuLogOut size={30} style={{ color: "#000" }} />
Expand Down
10 changes: 8 additions & 2 deletions uniEmpleos/src/components/LanguageButton/LanguageButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ import React, { useState } from "react"
import { useTranslation } from "react-i18next"
import i18n from "../../i18n"
import style from "./LanguageButton.module.css"
import useLanguage from "../../Hooks/useLanguage"

const LanguageButton = () => {
const [language, setLanguage] = useState("en")

const idiom = useLanguage()
const [language, setLanguage] = useState(idiom.getLanguage())


const changeLanguage = () => {
if (language === "es") {
const currentLanguage = idiom.getLanguage()
idiom.changeLanguage()
if (currentLanguage === "es") {
setLanguage("en")
console.log("en")
i18n.changeLanguage("en")
Expand Down
2 changes: 1 addition & 1 deletion uniEmpleos/src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ i18n.use(initReactI18next).init({
translation: esTranslations,
},
},
lng: "en",
lng: "es",
interpolation: {
escapeValue: false,
},
Expand Down
52 changes: 26 additions & 26 deletions uniEmpleos/src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,37 @@
"desc1": "UniEmpleos is a platform that enables students from various universities in Guatemala to find job offers and professional internships.",
"title2": "How does it work?",
"desc2": "Companies publish their job offers and students can apply to them. The companies can view the profiles of the students and contact them."
},
},
"offerPostulation": {
"details": "Details",
"button1": "Back",
"button2": "Apply"
},

"login": {
"email": "Enter your email",
"password": "Enter your password",
"new":"New to UniEmpleos?",
"new": "New to UniEmpleos?",
"register": "Register",
"login": "Login"
},
"podcast": {
"title": "Podcast",
"listen": "Listen",
"description": "We educate about the impact that politics, social relations, and economics have on society. We motivate to exercise individual sovereignty to achieve positive impacts on society. Being increasingly aware of the potential impact of our actions."
},
"resources": {
"title": "Resources",
"categories": [
"All",
"Press",
"News",
"Articles"
]
},
"analysis": {
"title": "Analysis"
},
"contact": {
"title": "Get in Touch",
"subtitle": "Contact",
"collaborate": "I want to collaborate",
"motto": "The republic is still alive",
"address": "Address",
"media": "Social Media"

"header": {
"student": {
"profile": "Profile",
"offers": "Offers",
"postulations": "Applications",
"chat": "Chat"
},
"enterprise": {
"profile": "Profile",
"newOffer": "Create Job",
"myOffers": "My Offers",
"chat": "Chat"
},
"admin": {
"enterprises": "Enterprises",
"students": "Students"
}
}
}
51 changes: 26 additions & 25 deletions uniEmpleos/src/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,37 @@
"title2": "¿Cómo funciona?",
"desc2": "Las empresas publican sus ofertas de trabajo y los estudiantes pueden postular a ellas. Las empresas pueden ver los perfiles de los estudiantes y contactarlos."
},

"offerPostulation": {
"details": "Detalles",
"button1": "Regresar",
"button2": "Postularme"
},

"login": {
"email": "Ingrese su correo",
"password": "Ingrese su contraseña",
"new":"¿Eres nuevo?",
"new": "¿Eres nuevo?",
"register": "Regístrate",
"login": "Iniciar Sesión"
},
"podcast": {
"title": "Podcast",
"listen": "Escuchar",
"description": "Educamos sobre el impacto que la política, relaciones sociales y economía tiene en la sociedad. Motivamos a ejercer la soberanía individual para lograr impactos positivos en la sociedad. Ser cada vez más conscientes del potencial impacto de nuestras acciones."
},
"resources": {
"title": "Recursos",
"categories": [
"Todo",
"Prensa",
"Noticias",
"Artículos"
]
},
"analysis": {
"title": "Análisis"
},
"contact": {
"title": "Ponte en Contacto",
"subtitle": "Contacto",
"collaborate": "Quiero colaborar",
"motto": "La república sigue viva",
"address": "Address",
"media": "Redes Sociales"

"header": {
"student": {
"profile": "Perfil",
"offers": "Ofertas",
"postulations": "Postulaciones",
"chat": "Chat"
},
"enterprise": {
"profile": "Perfil",
"newOffer": "Crear Empleo",
"myOffers": "Mis Ofertas",
"chat": "Chat"
},
"admin": {
"enterprises": "Empresas",
"students": "Estudiantes"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const EditProfileEmpresa = () => {
body
)
if (apiResponse.status === 200) {
navigate("/profilecompany")
navigate("/postulacionempresa")
} else {
setTypePopUp(1)
setError("Upss... Algo salio mal atras, intenta mas tarde")
Expand Down
4 changes: 0 additions & 4 deletions uniEmpleos/src/pages/Home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import styles from "./Home.module.css"
import Infocontainer from "../../components/Infocontainer/Infocontainer"
import HeaderHome from "../../components/HeaderHome/HeaderHome"
import students from "./students.json"
import LanguageButton from "../../components/LanguageButton/LanguageButton"
import { useTranslation } from "react-i18next"

const Home = () => {
Expand Down Expand Up @@ -57,9 +56,6 @@ const Home = () => {
/>
</div>
</div>
<div className={styles.footer}>
<LanguageButton />
</div>
</div>
)
}
Expand Down
4 changes: 0 additions & 4 deletions uniEmpleos/src/pages/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Popup from "../../components/Popup/Popup"
import API_URL from "../../api"
import { useStoreon } from "storeon/react"
import { useTranslation } from "react-i18next"
import LanguageButton from "../../components/LanguageButton/LanguageButton"

const LogIn = () => {
const { t } = useTranslation()
Expand Down Expand Up @@ -125,9 +124,6 @@ const LogIn = () => {
320C960,320,840,320,720,320C600,320,480,320,360,320C240,320,120,320,60,320L0,320Z"
/>
</svg>
<div className={styles.footer}>
<LanguageButton />
</div>
</div>
)
}
Expand Down
3 changes: 2 additions & 1 deletion uniEmpleos/src/pages/Login/Login.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { mount, test, describe } from "vitest"
import { StoreContext } from "storeon/react"
import { store } from "../../store" // Asegúrate de importar tu store
import LogIn from "./Login"
import { getByTestId } from "@testing-library/dom"

test("LogIn component", () => {
test("should render without crashing", () => {
Expand Down Expand Up @@ -41,7 +42,7 @@ test("LogIn component", () => {

getByPlaceholderText("uni@gmail.com").value = "test@gmail.com"
getByPlaceholderText("micontraseña123").value = "wrongpassword"
getByText("Iniciar sesión").click()
getByTestId("Iniciar sesión").click()

await test.waitFor(() => {
test
Expand Down
29 changes: 20 additions & 9 deletions uniEmpleos/src/pages/postulacion/Postulacion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import Button from "../../components/Button/Button"
import { navigate } from "../../store"
import useApi from "../../Hooks/useApi"
import Popup from "../../components/Popup/Popup"
import { useTranslation } from "react-i18next"

const Postulacion = ({ id }) => {
const { t } = useTranslation()
const { user } = useStoreon("user")
const api = useApi()
const apiPostulation = useApi()

const { quill, quillRef } = useQuill({
readOnly: true, // Establecer el editor Quill en modo de solo lectura
modules: {
Expand Down Expand Up @@ -47,11 +50,15 @@ const Postulacion = ({ id }) => {
}, [quill, detalles])

const handlePostularme = async () => {
const apiResponse = await apiPostulation.handleRequest("POST", "/postulations/", {
id_oferta: parseInt(id, 10),
id_estudiante: user.id_user,
estado: "enviada",
})
const apiResponse = await apiPostulation.handleRequest(
"POST",
"/postulations/",
{
id_oferta: parseInt(id, 10),
id_estudiante: user.id_user,
estado: "enviada",
}
)
if (apiResponse.status === 200) {
setTypeError(3)
setError("Postulación enviada con éxito")
Expand Down Expand Up @@ -128,20 +135,24 @@ const Postulacion = ({ id }) => {
/>
</div>
<div className={style.label}>
<span className={style.detailsText}>Detalles</span>
<span className={style.detailsText}>
{t("offerPostulation.details")}
</span>
<div ref={quillRef} className={style.Editor} />
</div>
<div className={style.buttonContainer}>
<Button
label="Regresar"
label={t("offerPostulation.button1")}
backgroundColor="#ccc"
onClick={handleRegresar}
noborder
/>
<Button
label="Postularme"
label={t("offerPostulation.button2")}
backgroundColor="#a08ae5"
onClick={() => {handlePostularme()}}
onClick={() => {
handlePostularme()
}}
noborder
/>
</div>
Expand Down
Loading
Loading