Extract duplicate status display logic to shared utility
- Created frontend/app/utils/appointment.ts with getStatusDisplay() - Supports context-aware text (isOwnView parameter) - Updated both appointments pages to use shared utility
This commit is contained in:
parent
d24acfd322
commit
8cc2cfa2e4
3 changed files with 37 additions and 30 deletions
|
|
@ -8,24 +8,11 @@ import { Header } from "../../components/Header";
|
|||
import { useRequireAuth } from "../../hooks/useRequireAuth";
|
||||
import { components } from "../../generated/api";
|
||||
import { formatDateTime } from "../../utils/date";
|
||||
import { getStatusDisplay } from "../../utils/appointment";
|
||||
|
||||
type AppointmentResponse = components["schemas"]["AppointmentResponse"];
|
||||
type PaginatedAppointments = components["schemas"]["PaginatedResponse_AppointmentResponse_"];
|
||||
|
||||
// Helper to get status display
|
||||
function getStatusDisplay(status: string): { text: string; bgColor: string; textColor: string } {
|
||||
switch (status) {
|
||||
case "booked":
|
||||
return { text: "Booked", bgColor: "rgba(34, 197, 94, 0.2)", textColor: "#4ade80" };
|
||||
case "cancelled_by_user":
|
||||
return { text: "Cancelled by user", bgColor: "rgba(239, 68, 68, 0.2)", textColor: "#f87171" };
|
||||
case "cancelled_by_admin":
|
||||
return { text: "Cancelled by admin", bgColor: "rgba(239, 68, 68, 0.2)", textColor: "#f87171" };
|
||||
default:
|
||||
return { text: status, bgColor: "rgba(255,255,255,0.1)", textColor: "rgba(255,255,255,0.6)" };
|
||||
}
|
||||
}
|
||||
|
||||
const styles: Record<string, React.CSSProperties> = {
|
||||
main: {
|
||||
minHeight: "100vh",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue