adjusted so only available pets for the selected store is displayed when adopting

This commit is contained in:
Alex
2026-04-12 18:00:24 -06:00
parent 42c9e96500
commit 077780c0c3
5 changed files with 24 additions and 20 deletions

View File

@@ -42,7 +42,7 @@ public interface PetApi {
Call<List<DropdownDTO>> getCustomerPets(@Path("customerId") Long customerId);
@GET("api/v1/dropdowns/adoption-pets")
Call<List<DropdownDTO>> getAdoptionPets();
Call<List<DropdownDTO>> getAdoptionPets(@Query("storeId") Long storeId);
@GET("api/v1/dropdowns/pets")
Call<List<DropdownDTO>> getPetDropdowns();

View File

@@ -43,8 +43,8 @@ public class PetRepository extends BaseRepository {
/**
* Retrieves a list of pets available for adoption from the dropdowns API.
*/
public LiveData<Resource<List<DropdownDTO>>> getAdoptionPets() {
return executeCall(petApi.getAdoptionPets());
public LiveData<Resource<List<DropdownDTO>>> getAdoptionPets(Long storeId) {
return executeCall(petApi.getAdoptionPets(storeId));
}
/**

View File

@@ -156,13 +156,9 @@ public class AdoptionDetailViewModel extends ViewModel {
}
private void loadAvailablePetsByStore(Long storeId) {
observeOnce(petRepository.getAvailablePetsByStore(storeId), r -> {
observeOnce(petRepository.getAdoptionPets(storeId), r -> {
if (r != null && r.status == Resource.Status.SUCCESS && r.data != null) {
List<DropdownDTO> dropdowns = new ArrayList<>();
for (com.example.petstoremobile.dtos.PetDTO pet : r.data.getContent()) {
dropdowns.add(new DropdownDTO(pet.getPetId(), pet.getPetName()));
}
petList.setValue(dropdowns);
petList.setValue(r.data);
}
});
}