Skip to content

Commit

Permalink
chore: Update CarModelContainer to fetch car models by brand ID and s…
Browse files Browse the repository at this point in the history
…earch term
  • Loading branch information
edmdz committed Aug 5, 2024
1 parent f53d6a7 commit 933d82d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/pages/Products/ModelViewer/CarModelContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const CarModelListContainer = () => {
setLoading(true); // Set loading to true before fetching data
let models = [];
if (selectedBrand && selectedBrand.id) {
models = await getCarModelsByBrandId(selectedBrand.id);
models = await getCarModelsByBrandId(selectedBrand.id, searchTerm);
} else {
models = await getCarModels(searchTerm);
}
Expand Down
4 changes: 2 additions & 2 deletions src/services/BrandService.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const getAllBrands = async (name = '') => {
return Array.isArray(result.response) ? result.response.map(brand => new Brand(brand)) : [];
};

const getCarModelsByBrandId = async (brandId) => {
const result = await axios.get(`/brand/${brandId}/models`);
const getCarModelsByBrandId = async (brandId, name) => {
const result = await axios.get(`/brand/${brandId}/models?name=${name}`);
return Array.isArray(result.response) ? result.response.map(model => new CarModel(model)) : [];
};

Expand Down

0 comments on commit 933d82d

Please sign in to comment.