Skip to content

Commit

Permalink
pre commit avant de fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Pauline Saur committed Dec 17, 2024
1 parent 0ec4918 commit 871df93
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
14 changes: 7 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ services:
test: curl -f http://localhost:5984/_up || exit 1
interval: 2s
timeout: 3s

accessible_backend:
image: curlimages/curl
entrypoint: ["/bin/sh","-c"]
entrypoint: [ "/bin/sh", "-c" ]
command:
- |
alias put="curl -X PUT -u '${COUCHDB_USER}:${COUCHDB_PASSWORD}'"
Expand All @@ -33,10 +33,10 @@ services:
depends_on:
backend:
condition: service_healthy

updated_samples:
image: curlimages/curl
entrypoint: ["/bin/sh","-c"]
entrypoint: [ "/bin/sh", "-c" ]
volumes:
- ./frontend/public/sample_data.json:/sample_data.json
command:
Expand All @@ -45,15 +45,15 @@ services:
depends_on:
accessible_backend:
condition: service_completed_successfully

index:
image: curlimages/curl
entrypoint: ["/bin/sh","-c"]
entrypoint: [ "/bin/sh", "-c" ]
volumes:
- ./backend/bydate.json:/bydate.json
command:
- |
curl -X POST http://backend:5984/database_joblinker_prot3/_index -H "Content-Type: application/json" -d @/bydate.json -u '${COUCHDB_USER}:${COUCHDB_PASSWORD}'
depends_on:
accessible_backend:
condition: service_completed_successfully
condition: service_completed_successfully
1 change: 1 addition & 0 deletions frontend/src/Headlines.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function Headlines({ searchTerm, setSearchTerm, contractType, setContractType, r

const handleSearch = (e) => {
e.preventDefault();
console.log(e);
onSearchClick(); // Appel de la fonction pour déclencher le filtrage
};

Expand Down
15 changes: 11 additions & 4 deletions frontend/src/Offer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ function Offer({ searchTerm, contractType, region, isSearchClicked, setIsSearchC
const [filteredOffers, setFilteredOffers] = useState([]);
const [nextBookmark, setNextBookmark] = useState()
const [requestedBookmark, setRequestedBookmark] = useState()
const [hasMoreOffers, setHasMoreOffers] = useState(true)

useEffect(() => {
//mettre ça dans une nouvelle fonction et dans le useeffect t'appele cette fonction
// fetch('http://localhost:5984/qvotidie/_all_docs?include_docs=true ')
fetch("http://localhost:5984/database_joblinker_prot3/_find", {
method: "POST",
Expand All @@ -23,7 +25,7 @@ function Offer({ searchTerm, contractType, region, isSearchClicked, setIsSearchC
issued: "desc"
}
],
limit: 100,
limit: 25,
bookmark: requestedBookmark
})
})
Expand All @@ -33,6 +35,11 @@ function Offer({ searchTerm, contractType, region, isSearchClicked, setIsSearchC
setAllOffers([...allOffers, ...allDocs]);
setNextBookmark(data.bookmark);
setFilteredOffers((prev) => [...prev, ...allDocs]);

if (allDocs.length === 0) {
setHasMoreOffers(false);
}

})
.catch((error) =>
console.error("Erreur lors du chargement des données :", error)
Expand All @@ -43,14 +50,14 @@ function Offer({ searchTerm, contractType, region, isSearchClicked, setIsSearchC

useEffect(() => {
if (isSearchClicked) {
const offers = allOffers.filter((doc) => {
const offers = allOffers.filter((doc) => { //enlever jusque
const matchesSearchTerm = doc.title?.toLowerCase().includes(searchTerm.toLowerCase());
const matchesContractType = contractType === "" || doc.type === contractType;
const matchesRegion = region === "" || doc.location === region;

return matchesSearchTerm && matchesContractType && matchesRegion;
});
setFilteredOffers(offers);
setFilteredOffers(offers); //la //ajouter l'appel a la future fonction que on vas faire avec un tab vide
setIsSearchClicked(false);
}
}, [isSearchClicked, searchTerm, contractType, region, setIsSearchClicked, allOffers]);
Expand All @@ -65,7 +72,7 @@ function Offer({ searchTerm, contractType, region, isSearchClicked, setIsSearchC
<OfferCard key={index} doc={doc} />
))}
</div>
{ nextBookmark && (
{nextBookmark && (
<button
onClick={() => {
setRequestedBookmark(nextBookmark); // Charge les offres suivantes
Expand Down

0 comments on commit 871df93

Please sign in to comment.