AttachmentsToChat #145

Merged
RecentRunner merged 35 commits from AttachmentsToChat into main 2026-04-07 06:53:07 -06:00
3 changed files with 30 additions and 34 deletions
Showing only changes of commit 9bab45f04b - Show all commits

View File

@@ -59,14 +59,14 @@ public class AppointmentAdapter extends RecyclerView.Adapter<AppointmentAdapter.
String status = a.getStatus() != null ? a.getStatus() : "";
holder.tvAppointmentStatus.setText(status);
switch (status) {
case "Booked":
switch (status.toUpperCase()) {
case "BOOKED":
holder.tvAppointmentStatus.setBackgroundColor(Color.parseColor("#2196F3")); // blue
break;
case "Completed":
case "COMPLETED":
holder.tvAppointmentStatus.setBackgroundColor(Color.parseColor("#4CAF50")); // green
break;
case "Cancelled":
case "CANCELLED":
holder.tvAppointmentStatus.setBackgroundColor(Color.parseColor("#F44336")); // red
break;
default:

View File

@@ -1,8 +1,5 @@
package com.example.petstoremobile.dtos;
import java.math.BigDecimal;
import java.util.List;
public class AppointmentDTO {
private Long appointmentId;
@@ -17,20 +14,20 @@ public class AppointmentDTO {
private String appointmentDate;
private String appointmentTime;
private String appointmentStatus;
private List<String> petNames;
private List<Long> petIds;
private String petName;
private Long petId;
private String createdAt;
private String updatedAt;
public AppointmentDTO(Long customerId, Long storeId, Long serviceId,
String appointmentDate, String appointmentTime,
String appointmentStatus, List<Long> petIds) {
this(customerId, storeId, serviceId, null, appointmentDate, appointmentTime, appointmentStatus, petIds);
String appointmentStatus, Long petId) {
this(customerId, storeId, serviceId, null, appointmentDate, appointmentTime, appointmentStatus, petId);
}
public AppointmentDTO(Long customerId, Long storeId, Long serviceId, Long employeeId,
String appointmentDate, String appointmentTime,
String appointmentStatus, List<Long> petIds) {
String appointmentStatus, Long petId) {
this.customerId = customerId;
this.storeId = storeId;
this.serviceId = serviceId;
@@ -38,7 +35,7 @@ public class AppointmentDTO {
this.appointmentDate = appointmentDate;
this.appointmentTime = appointmentTime;
this.appointmentStatus = appointmentStatus;
this.petIds = petIds;
this.petId = petId;
}
public Long getAppointmentId() {
@@ -89,12 +86,12 @@ public class AppointmentDTO {
return appointmentStatus;
}
public List<String> getPetNames() {
return petNames;
public String getPetName() {
return petName;
}
public List<Long> getPetIds() {
return petIds;
public Long getPetId() {
return petId;
}
public String getCreatedAt() {
@@ -105,16 +102,8 @@ public class AppointmentDTO {
return updatedAt;
}
public String getPetName() {
return (petNames != null && !petNames.isEmpty()) ? petNames.get(0) : "";
}
public Long getPetID() {
return (petIds != null && !petIds.isEmpty()) ? petIds.get(0) : null;
}
public Long getPetId() {
return getPetID();
return petId;
}
public String getServiceType() {

View File

@@ -48,7 +48,6 @@ public class AppointmentDetailFragment extends Fragment {
private final Integer[] HOURS = {9,10,11,12,13,14,15,16,17};
private final Integer[] MINUTES = {0,15,30,45};
private final String[] STATUSES = {"Booked","Completed","Cancelled"};
private AppointmentViewModel appointmentViewModel;
private PetViewModel petViewModel;
@@ -95,7 +94,8 @@ public class AppointmentDetailFragment extends Fragment {
* Configures the adapters for spinners.
*/
private void setupSpinners() {
SpinnerUtils.setupStringSpinner(requireContext(), binding.spinnerAppointmentStatus, STATUSES);
SpinnerUtils.setupStringSpinner(requireContext(), binding.spinnerAppointmentStatus,
new String[]{"Booked", "Completed", "Cancelled", "Missed"});
String[] hours = new String[HOURS.length];
for (int i = 0; i < HOURS.length; i++)
@@ -243,7 +243,7 @@ public class AppointmentDetailFragment extends Fragment {
if (resource == null) return;
if (resource.status == Resource.Status.SUCCESS && resource.data != null) {
AppointmentDTO a = resource.data;
preselectedPetId = (a.getPetID() != null) ? a.getPetID() : -1;
preselectedPetId = (a.getPetId() != null) ? a.getPetId() : -1;
preselectedServiceId = (a.getServiceId() != null) ? a.getServiceId() : -1;
preselectedCustomerId = (a.getCustomerId() != null) ? a.getCustomerId() : -1;
preselectedStoreId = (a.getStoreId() != null) ? a.getStoreId() : -1;
@@ -265,7 +265,12 @@ public class AppointmentDetailFragment extends Fragment {
} catch (NumberFormatException ignored) {}
}
SpinnerUtils.setSelectionByValue(binding.spinnerAppointmentStatus, a.getAppointmentStatus());
// Match Title labels with backend values
String status = a.getAppointmentStatus();
if (status != null && !status.isEmpty()) {
String formattedStatus = status.substring(0, 1).toUpperCase() + status.substring(1).toLowerCase();
SpinnerUtils.setSelectionByValue(binding.spinnerAppointmentStatus, formattedStatus);
}
refreshPetSpinner();
refreshServiceSpinner();
@@ -306,11 +311,13 @@ public class AppointmentDetailFragment extends Fragment {
String time = String.format("%02d:%02d",
HOURS[binding.spinnerHour.getSelectedItemPosition()],
MINUTES[binding.spinnerMinute.getSelectedItemPosition()]);
String status = STATUSES[binding.spinnerAppointmentStatus.getSelectedItemPosition()];
// Get status and convert to uppercase for backend
String status = binding.spinnerAppointmentStatus.getSelectedItem().toString().toUpperCase();
// Validate future date+time if status is Booked
if ("Booked".equalsIgnoreCase(status)) {
// Validate future date+time if status is BOOKED
if ("BOOKED".equalsIgnoreCase(status)) {
try {
String[] dateParts = date.split("-");
String[] timeParts = time.split(":");
@@ -342,7 +349,7 @@ public class AppointmentDetailFragment extends Fragment {
date,
time,
status,
Collections.singletonList(pet.getPetId())
pet.getPetId()
);
androidx.lifecycle.Observer<Resource<AppointmentDTO>> observer = resource -> {