added sort so appointment and adoption display the most recent created first

This commit is contained in:
Alex
2026-04-11 22:18:39 -06:00
parent 6245fa88da
commit c503ddbbc2
6 changed files with 10 additions and 8 deletions

View File

@@ -24,7 +24,8 @@ public interface AdoptionApi {
@Query("status") String status,
@Query("storeId") Long storeId,
@Query("date") String date,
@Query("employeeId") Long employeeId);
@Query("employeeId") Long employeeId,
@Query("sort") String sort);
@GET("api/v1/adoptions/{id}")
Call<AdoptionDTO> getAdoptionById(@Path("id") Long id);

View File

@@ -24,7 +24,8 @@ public interface AppointmentApi {
@Query("status") String status,
@Query("storeId") Long storeId,
@Query("date") String date,
@Query("employeeId") Long employeeId);
@Query("employeeId") Long employeeId,
@Query("sort") String sort);
@GET("api/v1/appointments/{id}")
Call<AppointmentDTO> getAppointmentById(@Path("id") Long id);

View File

@@ -24,8 +24,8 @@ public class AdoptionRepository extends BaseRepository {
/**
* 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) {
return executeCall(adoptionApi.getAllAdoptions(page, size, query, status, storeId, date, 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, sort));
}
/**

View File

@@ -24,8 +24,8 @@ public class AppointmentRepository extends BaseRepository {
/**
* 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) {
return executeCall(appointmentApi.getAllAppointments(page, size, query, status, storeId, date, 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, sort));
}
/**

View File

@@ -55,7 +55,7 @@ public class AdoptionListViewModel extends ViewModel {
if ("All Statuses".equals(status)) status = null;
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.status == Resource.Status.SUCCESS && resource.data != null) {
List<AdoptionDTO> currentList = reset ? new ArrayList<>() : new ArrayList<>(adoptions.getValue());

View File

@@ -41,7 +41,7 @@ public class AppointmentListViewModel extends ViewModel {
public void loadAppointments(String query, String status, Long storeId, String date, Long employeeId) {
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.status == Resource.Status.SUCCESS && resource.data != null) {
appointments.setValue(resource.data.getContent());