diff --git a/web/app/appointments/page.js b/web/app/appointments/page.js index 876981c6..1492909b 100644 --- a/web/app/appointments/page.js +++ b/web/app/appointments/page.js @@ -383,6 +383,10 @@ function AppointmentsPage() { const [showAddPetModal, setShowAddPetModal] = useState(false); const [cancellingId, setCancellingId] = useState(null); + const [apptSearch, setApptSearch] = useState(""); + const [adoptionSearch, setAdoptionSearch] = useState(""); + const [showPastAppts, setShowPastAppts] = useState(false); + const [showPastAdoptions, setShowPastAdoptions] = useState(false); const canBookAppointments = user?.role === "CUSTOMER" || user?.role === "ADMIN"; @@ -966,79 +970,164 @@ const canBookAppointments = user?.role === "CUSTOMER" || user?.role === "ADMIN";

{canBookAppointments ? "Your Appointments" : "Appointments"}

{loadingAppointments ? (

Loading appointments...

- ) : appointments.length === 0 ? ( -

No appointments yet.

- ) : ( -
- {appointments.map((a) => ( -
-
- {a.serviceName} - - {a.appointmentStatus} - + ) : (() => { + const activeAppts = appointments.filter((a) => a.appointmentStatus?.toLowerCase() === "booked"); + const pastAppts = appointments.filter((a) => a.appointmentStatus?.toLowerCase() !== "booked"); + const q = apptSearch.toLowerCase(); + const filteredActive = activeAppts.filter((a) => + !q || [a.serviceName, a.storeName, a.petName].some((v) => v?.toLowerCase().includes(q)) + ); + return ( + <> + setApptSearch(e.target.value)} + /> + {filteredActive.length === 0 ? ( +

{activeAppts.length === 0 ? "No active appointments." : "No results."}

+ ) : ( +
+ {filteredActive.map((a) => ( +
+
+ {a.serviceName} + + {a.appointmentStatus} + +
+
+ {a.storeName} + {a.appointmentDate} at {formatTime(a.appointmentTime)} +
+ {a.petName && ( +
Pet: {a.petName}
+ )} +
+ +
+
+ ))}
-
- {a.storeName} - {a.appointmentDate} at {formatTime(a.appointmentTime)} + )} + {pastAppts.length > 0 && ( +
+ + {showPastAppts && ( +
+ {pastAppts.map((a) => ( +
+
+ {a.serviceName} + + {a.appointmentStatus} + +
+
+ {a.storeName} + {a.appointmentDate} at {formatTime(a.appointmentTime)} +
+ {a.petName && ( +
Pet: {a.petName}
+ )} +
+ ))} +
+ )}
- {a.petName && ( -
- Pet: {a.petName} -
- )} - {a.appointmentStatus?.toLowerCase() === "booked" && ( -
- -
- )} -
- ))} -
- )} + )} + + ); + })()}

{canBookAppointments ? "Your Adoptions" : "Adoptions"}

{loadingAdoptions ? (

Loading adoptions...

- ) : adoptions.length === 0 ? ( -

No adoption requests yet.

- ) : ( -
- {adoptions.map((a) => ( -
-
- {a.petName} - - {a.adoptionStatus} - + ) : (() => { + const activeAdoptions = adoptions.filter((a) => a.adoptionStatus?.toLowerCase() === "pending"); + const pastAdoptions = adoptions.filter((a) => a.adoptionStatus?.toLowerCase() !== "pending"); + const q = adoptionSearch.toLowerCase(); + const filteredActive = activeAdoptions.filter((a) => + !q || [a.petName, a.sourceStoreName].some((v) => v?.toLowerCase().includes(q)) + ); + return ( + <> + setAdoptionSearch(e.target.value)} + /> + {filteredActive.length === 0 ? ( +

{activeAdoptions.length === 0 ? "No active adoption requests." : "No results."}

+ ) : ( +
+ {filteredActive.map((a) => ( +
+
+ {a.petName} + + {a.adoptionStatus} + +
+
+ {a.sourceStoreName} + {a.adoptionDate} +
+
+ +
+
+ ))}
-
- {a.sourceStoreName} - {a.adoptionDate} + )} + {pastAdoptions.length > 0 && ( +
+ + {showPastAdoptions && ( +
+ {pastAdoptions.map((a) => ( +
+
+ {a.petName} + + {a.adoptionStatus} + +
+
+ {a.sourceStoreName} + {a.adoptionDate} +
+
+ ))} +
+ )}
- {a.adoptionStatus?.toLowerCase() === "pending" && ( -
- -
- )} -
- ))} -
- )} + )} + + ); + })()}
diff --git a/web/app/contact/page.js b/web/app/contact/page.js index 5ae4b5e4..1983bd72 100644 --- a/web/app/contact/page.js +++ b/web/app/contact/page.js @@ -38,6 +38,10 @@ export default function ContactPage() { async function handleSend(e) { e.preventDefault(); + if (!token) { + setSendError("Please log in to send a message."); + return; + } setSending(true); setSendError(null); try { @@ -72,44 +76,42 @@ export default function ContactPage() {

Phone: (03) 9000 0000

Hours: Mon–Sat, 9:00 AM – 6:00 PM

- {token && ( -
-

Send Us a Message

- {sendSuccess ? ( -

Your message has been sent. We'll be in touch soon.

- ) : ( -
- -