adjusted so only available pets for the selected store is displayed when adopting
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user