added sort so appointment and adoption display the most recent created first
This commit is contained in:
@@ -24,7 +24,8 @@ public interface AdoptionApi {
|
|||||||
@Query("status") String status,
|
@Query("status") String status,
|
||||||
@Query("storeId") Long storeId,
|
@Query("storeId") Long storeId,
|
||||||
@Query("date") String date,
|
@Query("date") String date,
|
||||||
@Query("employeeId") Long employeeId);
|
@Query("employeeId") Long employeeId,
|
||||||
|
@Query("sort") String sort);
|
||||||
|
|
||||||
@GET("api/v1/adoptions/{id}")
|
@GET("api/v1/adoptions/{id}")
|
||||||
Call<AdoptionDTO> getAdoptionById(@Path("id") Long id);
|
Call<AdoptionDTO> getAdoptionById(@Path("id") Long id);
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ public interface AppointmentApi {
|
|||||||
@Query("status") String status,
|
@Query("status") String status,
|
||||||
@Query("storeId") Long storeId,
|
@Query("storeId") Long storeId,
|
||||||
@Query("date") String date,
|
@Query("date") String date,
|
||||||
@Query("employeeId") Long employeeId);
|
@Query("employeeId") Long employeeId,
|
||||||
|
@Query("sort") String sort);
|
||||||
|
|
||||||
@GET("api/v1/appointments/{id}")
|
@GET("api/v1/appointments/{id}")
|
||||||
Call<AppointmentDTO> getAppointmentById(@Path("id") Long id);
|
Call<AppointmentDTO> getAppointmentById(@Path("id") Long id);
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ public class AdoptionRepository extends BaseRepository {
|
|||||||
/**
|
/**
|
||||||
* Retrieves a paginated list of all adoptions from the API.
|
* Retrieves a paginated list of all adoptions from the API.
|
||||||
*/
|
*/
|
||||||
public LiveData<Resource<PageResponse<AdoptionDTO>>> getAllAdoptions(int page, int size, String query, String status, Long storeId, String date, Long employeeId) {
|
public LiveData<Resource<PageResponse<AdoptionDTO>>> getAllAdoptions(int page, int size, String query, String status, Long storeId, String date, Long employeeId, String sort) {
|
||||||
return executeCall(adoptionApi.getAllAdoptions(page, size, query, status, storeId, date, employeeId));
|
return executeCall(adoptionApi.getAllAdoptions(page, size, query, status, storeId, date, employeeId, sort));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ public class AppointmentRepository extends BaseRepository {
|
|||||||
/**
|
/**
|
||||||
* Retrieves a paginated list of all appointments from the API with filtering.
|
* Retrieves a paginated list of all appointments from the API with filtering.
|
||||||
*/
|
*/
|
||||||
public LiveData<Resource<PageResponse<AppointmentDTO>>> getAllAppointments(int page, int size, String query, String status, Long storeId, String date, Long employeeId) {
|
public LiveData<Resource<PageResponse<AppointmentDTO>>> getAllAppointments(int page, int size, String query, String status, Long storeId, String date, Long employeeId, String sort) {
|
||||||
return executeCall(appointmentApi.getAllAppointments(page, size, query, status, storeId, date, employeeId));
|
return executeCall(appointmentApi.getAllAppointments(page, size, query, status, storeId, date, employeeId, sort));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class AdoptionListViewModel extends ViewModel {
|
|||||||
if ("All Statuses".equals(status)) status = null;
|
if ("All Statuses".equals(status)) status = null;
|
||||||
|
|
||||||
isLoading.setValue(true);
|
isLoading.setValue(true);
|
||||||
observeOnce(adoptionRepository.getAllAdoptions(currentPage, PAGE_SIZE, query, status, storeId, date, employeeId), resource -> {
|
observeOnce(adoptionRepository.getAllAdoptions(currentPage, PAGE_SIZE, query, status, storeId, date, employeeId, "adoptionId,desc"), resource -> {
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
if (resource.status == Resource.Status.SUCCESS && resource.data != null) {
|
if (resource.status == Resource.Status.SUCCESS && resource.data != null) {
|
||||||
List<AdoptionDTO> currentList = reset ? new ArrayList<>() : new ArrayList<>(adoptions.getValue());
|
List<AdoptionDTO> currentList = reset ? new ArrayList<>() : new ArrayList<>(adoptions.getValue());
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class AppointmentListViewModel extends ViewModel {
|
|||||||
|
|
||||||
public void loadAppointments(String query, String status, Long storeId, String date, Long employeeId) {
|
public void loadAppointments(String query, String status, Long storeId, String date, Long employeeId) {
|
||||||
isLoading.setValue(true);
|
isLoading.setValue(true);
|
||||||
observeOnce(appointmentRepository.getAllAppointments(0, 500, query, status, storeId, date, employeeId), resource -> {
|
observeOnce(appointmentRepository.getAllAppointments(0, 500, query, status, storeId, date, employeeId, "appointmentId,desc"), resource -> {
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
if (resource.status == Resource.Status.SUCCESS && resource.data != null) {
|
if (resource.status == Resource.Status.SUCCESS && resource.data != null) {
|
||||||
appointments.setValue(resource.data.getContent());
|
appointments.setValue(resource.data.getContent());
|
||||||
|
|||||||
Reference in New Issue
Block a user