generated from WildCodeSchool/create-js-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add component cardOffer for Home Page when user not connected
- Loading branch information
1 parent
a9d5894
commit 51647b9
Showing
3 changed files
with
77 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,61 @@ | ||
import PropTypes from "prop-types"; | ||
import { useEffect, useState } from "react"; | ||
import ButtonMini from "../Boutons/ButtonMini"; | ||
import "./card-model.css"; | ||
import { useGlobalContext } from "../../contexts/GlobalContext"; | ||
|
||
function CardOffer() { | ||
const globalContext = useGlobalContext(); | ||
const [offers, setOffers] = useState([]); | ||
useEffect(() => { | ||
const getAllOffer = async () => { | ||
try { | ||
const response = await globalContext.apiService.get( | ||
`${import.meta.env.VITE_BACKEND_URL}/api/offer` | ||
); | ||
setOffers(response.data); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
}; | ||
getAllOffer(); | ||
}, []); | ||
|
||
return ( | ||
<div className="card-container"> | ||
<h3 className="pourcentage">Titre de l'offre</h3> | ||
<div className="competence"> | ||
<h3>HTML, CSS, JAVASCRIPT, REACT</h3> | ||
</div> | ||
<h3 className="label-offre">Titre de l'offre</h3> | ||
<h4 className="entreprise-champs">Nom entreprise</h4> | ||
<p className="p-description "> Description entreprise</p> | ||
<ButtonMini textBtn="Postuler" /> | ||
<div> | ||
{offers.map((offer) => ( | ||
<div className="card-container"> | ||
<h3 className="label-offre">{offer.title}</h3> | ||
<div className="competence"> | ||
<h3>HTML, CSS, JAVASCRIPT, REACT</h3> | ||
</div> | ||
<h5 className="poste-champs"> | ||
{offer.type} - {offer.city} | ||
</h5> | ||
<h4 className="entreprise-champs">{offer.company}</h4> | ||
<p className="p-description ">{offer.description}</p> | ||
<ButtonMini textBtn="Postuler" /> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
CardOffer.propTypes = { | ||
offer: PropTypes.shape({ | ||
id: PropTypes.number.isRequired, | ||
title: PropTypes.string.isRequired, | ||
company: PropTypes.string.isRequired, | ||
type: PropTypes.string.isRequired, | ||
city: PropTypes.string.isRequired, | ||
info: PropTypes.string.isRequired, | ||
competences: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
id: PropTypes.number.isRequired, | ||
name: PropTypes.string.isRequired, | ||
}) | ||
).isRequired, | ||
}).isRequired, | ||
}; | ||
|
||
export default CardOffer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters