소스 검색

Say what is missing in the booking dialog instead of greying out the button (#600)

* Say what is missing in the booking dialog instead of greying out the button

* Say the time limits in the message and show it when the browser stops the submit
Bernt Christian Egeland 13 시간 전
부모
커밋
fa0d31ce13

+ 8 - 0
messages/de/calendar.json

@@ -220,6 +220,14 @@
     "durationHours": "{count, plural, one {# Stunde} other {# Stunden}}",
     "durationHours": "{count, plural, one {# Stunde} other {# Stunden}}",
     "durationMinutes": "{count, plural, one {# Minute} other {# Minuten}}",
     "durationMinutes": "{count, plural, one {# Minute} other {# Minuten}}",
     "endAfterStart": "Das Ende muss nach dem Beginn liegen, höchstens eine Woche später.",
     "endAfterStart": "Das Ende muss nach dem Beginn liegen, höchstens eine Woche später.",
+    "missing": {
+      "title": "Zuerst einen Titel eingeben.",
+      "times": "Ein Ende mindestens 5 Minuten nach dem Beginn festlegen, höchstens eine Woche später.",
+      "who": "Zuerst einen Kunden oder ein Fahrzeug wählen.",
+      "whoMarine": "Zuerst einen Kunden oder ein Boot wählen.",
+      "notifications": "Zuerst die Zeiten der Benachrichtigungen prüfen.",
+      "customerNotice": "Einen Kunden wählen oder die Benachrichtigung an den Kunden entfernen."
+    },
     "appointmentWhoHint": "Wählen Sie einen Kunden, um ihn vor dem Termin benachrichtigen zu können.",
     "appointmentWhoHint": "Wählen Sie einen Kunden, um ihn vor dem Termin benachrichtigen zu können.",
     "appointmentWhoHintMarine": "Wählen Sie einen Kunden, um ihn vor dem Termin benachrichtigen zu können.",
     "appointmentWhoHintMarine": "Wählen Sie einen Kunden, um ihn vor dem Termin benachrichtigen zu können.",
     "whoLocked": "Ändern Sie Fahrzeug oder Kunde im Arbeitsauftrag.",
     "whoLocked": "Ändern Sie Fahrzeug oder Kunde im Arbeitsauftrag.",

+ 8 - 0
messages/en/calendar.json

@@ -220,6 +220,14 @@
     "durationHours": "{count, plural, one {# hour} other {# hours}}",
     "durationHours": "{count, plural, one {# hour} other {# hours}}",
     "durationMinutes": "{count, plural, one {# minute} other {# minutes}}",
     "durationMinutes": "{count, plural, one {# minute} other {# minutes}}",
     "endAfterStart": "The end has to be after the start, and at most a week later.",
     "endAfterStart": "The end has to be after the start, and at most a week later.",
+    "missing": {
+      "title": "Add a title first.",
+      "times": "Set an end at least 5 minutes after the start, and at most a week later.",
+      "who": "Choose a customer or a car first.",
+      "whoMarine": "Choose a customer or a boat first.",
+      "notifications": "Check the notification times first.",
+      "customerNotice": "Choose a customer, or remove the notification to the customer."
+    },
     "appointmentWhoHint": "Choose a customer to be able to notify them before the appointment.",
     "appointmentWhoHint": "Choose a customer to be able to notify them before the appointment.",
     "appointmentWhoHintMarine": "Choose a customer to be able to notify them before the appointment.",
     "appointmentWhoHintMarine": "Choose a customer to be able to notify them before the appointment.",
     "whoLocked": "Change the car or the customer on the work order.",
     "whoLocked": "Change the car or the customer on the work order.",

+ 8 - 0
messages/es/calendar.json

@@ -220,6 +220,14 @@
     "durationHours": "{count, plural, one {# hora} other {# horas}}",
     "durationHours": "{count, plural, one {# hora} other {# horas}}",
     "durationMinutes": "{count, plural, one {# minuto} other {# minutos}}",
     "durationMinutes": "{count, plural, one {# minuto} other {# minutos}}",
     "endAfterStart": "El fin tiene que ser posterior al inicio, y como mucho una semana después.",
     "endAfterStart": "El fin tiene que ser posterior al inicio, y como mucho una semana después.",
+    "missing": {
+      "title": "Primero añade un título.",
+      "times": "Pon un fin al menos 5 minutos después del inicio, y como mucho una semana después.",
+      "who": "Primero elige un cliente o un vehículo.",
+      "whoMarine": "Primero elige un cliente o una embarcación.",
+      "notifications": "Primero revisa los tiempos de las notificaciones.",
+      "customerNotice": "Elige un cliente o quita la notificación al cliente."
+    },
     "appointmentWhoHint": "Elige un cliente para poder avisarle antes de la cita.",
     "appointmentWhoHint": "Elige un cliente para poder avisarle antes de la cita.",
     "appointmentWhoHintMarine": "Elige un cliente para poder avisarle antes de la cita.",
     "appointmentWhoHintMarine": "Elige un cliente para poder avisarle antes de la cita.",
     "whoLocked": "Cambia el vehículo o el cliente en la orden de trabajo.",
     "whoLocked": "Cambia el vehículo o el cliente en la orden de trabajo.",

+ 8 - 0
messages/fr/calendar.json

@@ -220,6 +220,14 @@
     "durationHours": "{count, plural, one {# heure} other {# heures}}",
     "durationHours": "{count, plural, one {# heure} other {# heures}}",
     "durationMinutes": "{count, plural, one {# minute} other {# minutes}}",
     "durationMinutes": "{count, plural, one {# minute} other {# minutes}}",
     "endAfterStart": "La fin doit être après le début, et au plus une semaine plus tard.",
     "endAfterStart": "La fin doit être après le début, et au plus une semaine plus tard.",
+    "missing": {
+      "title": "Ajoutez d'abord un titre.",
+      "times": "Indiquez une fin au moins 5 minutes après le début, et au plus une semaine plus tard.",
+      "who": "Choisissez d'abord un client ou un véhicule.",
+      "whoMarine": "Choisissez d'abord un client ou un bateau.",
+      "notifications": "Vérifiez d'abord les délais des notifications.",
+      "customerNotice": "Choisissez un client ou retirez la notification au client."
+    },
     "appointmentWhoHint": "Choisissez un client pour pouvoir le prévenir avant le rendez-vous.",
     "appointmentWhoHint": "Choisissez un client pour pouvoir le prévenir avant le rendez-vous.",
     "appointmentWhoHintMarine": "Choisissez un client pour pouvoir le prévenir avant le rendez-vous.",
     "appointmentWhoHintMarine": "Choisissez un client pour pouvoir le prévenir avant le rendez-vous.",
     "whoLocked": "Changez le véhicule ou le client sur l’ordre de travail.",
     "whoLocked": "Changez le véhicule ou le client sur l’ordre de travail.",

+ 8 - 0
messages/it/calendar.json

@@ -220,6 +220,14 @@
     "durationHours": "{count, plural, one {# ora} other {# ore}}",
     "durationHours": "{count, plural, one {# ora} other {# ore}}",
     "durationMinutes": "{count, plural, one {# minuto} other {# minuti}}",
     "durationMinutes": "{count, plural, one {# minuto} other {# minuti}}",
     "endAfterStart": "La fine deve essere dopo l'inizio, al massimo una settimana dopo.",
     "endAfterStart": "La fine deve essere dopo l'inizio, al massimo una settimana dopo.",
+    "missing": {
+      "title": "Aggiungi prima un titolo.",
+      "times": "Imposta una fine almeno 5 minuti dopo l'inizio, al massimo una settimana dopo.",
+      "who": "Scegli prima un cliente o un veicolo.",
+      "whoMarine": "Scegli prima un cliente o una barca.",
+      "notifications": "Controlla prima i tempi delle notifiche.",
+      "customerNotice": "Scegli un cliente oppure rimuovi la notifica al cliente."
+    },
     "appointmentWhoHint": "Scegli un cliente per poterlo avvisare prima dell'appuntamento.",
     "appointmentWhoHint": "Scegli un cliente per poterlo avvisare prima dell'appuntamento.",
     "appointmentWhoHintMarine": "Scegli un cliente per poterlo avvisare prima dell'appuntamento.",
     "appointmentWhoHintMarine": "Scegli un cliente per poterlo avvisare prima dell'appuntamento.",
     "whoLocked": "Cambia l'auto o il cliente nell'ordine di lavoro.",
     "whoLocked": "Cambia l'auto o il cliente nell'ordine di lavoro.",

+ 8 - 0
messages/lt/calendar.json

@@ -220,6 +220,14 @@
     "durationHours": "{count, plural, one {# valanda} few {# valandos} many {# valandos} other {# valandų}}",
     "durationHours": "{count, plural, one {# valanda} few {# valandos} many {# valandos} other {# valandų}}",
     "durationMinutes": "{count, plural, one {# minutė} few {# minutės} many {# minutės} other {# minučių}}",
     "durationMinutes": "{count, plural, one {# minutė} few {# minutės} many {# minutės} other {# minučių}}",
     "endAfterStart": "Pabaiga turi būti po pradžios ir ne vėliau kaip po savaitės.",
     "endAfterStart": "Pabaiga turi būti po pradžios ir ne vėliau kaip po savaitės.",
+    "missing": {
+      "title": "Pirmiausia įrašykite pavadinimą.",
+      "times": "Nustatykite pabaigą bent 5 minutės po pradžios ir ne vėliau kaip po savaitės.",
+      "who": "Pirmiausia pasirinkite klientą arba automobilį.",
+      "whoMarine": "Pirmiausia pasirinkite klientą arba laivą.",
+      "notifications": "Pirmiausia patikrinkite pranešimų laikus.",
+      "customerNotice": "Pasirinkite klientą arba pašalinkite pranešimą klientui."
+    },
     "appointmentWhoHint": "Pasirinkite klientą, kad galėtumėte jam priminti prieš vizitą.",
     "appointmentWhoHint": "Pasirinkite klientą, kad galėtumėte jam priminti prieš vizitą.",
     "appointmentWhoHintMarine": "Pasirinkite klientą, kad galėtumėte jam priminti prieš vizitą.",
     "appointmentWhoHintMarine": "Pasirinkite klientą, kad galėtumėte jam priminti prieš vizitą.",
     "whoLocked": "Automobilį ar klientą keiskite darbo užsakyme.",
     "whoLocked": "Automobilį ar klientą keiskite darbo užsakyme.",

+ 8 - 0
messages/nb/calendar.json

@@ -220,6 +220,14 @@
     "durationHours": "{count, plural, one {# time} other {# timer}}",
     "durationHours": "{count, plural, one {# time} other {# timer}}",
     "durationMinutes": "{count, plural, one {# minutt} other {# minutter}}",
     "durationMinutes": "{count, plural, one {# minutt} other {# minutter}}",
     "endAfterStart": "Slutt må være etter start, og høyst en uke senere.",
     "endAfterStart": "Slutt må være etter start, og høyst en uke senere.",
+    "missing": {
+      "title": "Legg til en tittel først.",
+      "times": "Sett en slutt minst 5 minutter etter start, og høyst en uke senere.",
+      "who": "Velg en kunde eller en bil først.",
+      "whoMarine": "Velg en kunde eller en båt først.",
+      "notifications": "Sjekk tidene for varslene først.",
+      "customerNotice": "Velg en kunde, eller fjern varselet til kunden."
+    },
     "appointmentWhoHint": "Velg en kunde for å kunne varsle kunden før timeavtalen.",
     "appointmentWhoHint": "Velg en kunde for å kunne varsle kunden før timeavtalen.",
     "appointmentWhoHintMarine": "Velg en kunde for å kunne varsle kunden før timeavtalen.",
     "appointmentWhoHintMarine": "Velg en kunde for å kunne varsle kunden før timeavtalen.",
     "whoLocked": "Endre bilen eller kunden på arbeidsordren.",
     "whoLocked": "Endre bilen eller kunden på arbeidsordren.",

+ 8 - 0
messages/nl/calendar.json

@@ -220,6 +220,14 @@
     "durationHours": "{count, plural, one {# uur} other {# uur}}",
     "durationHours": "{count, plural, one {# uur} other {# uur}}",
     "durationMinutes": "{count, plural, one {# minuut} other {# minuten}}",
     "durationMinutes": "{count, plural, one {# minuut} other {# minuten}}",
     "endAfterStart": "Het einde moet na het begin liggen, en hoogstens een week later.",
     "endAfterStart": "Het einde moet na het begin liggen, en hoogstens een week later.",
+    "missing": {
+      "title": "Voeg eerst een titel toe.",
+      "times": "Stel een einde in dat minstens 5 minuten na het begin ligt, en hoogstens een week later.",
+      "who": "Kies eerst een klant of een voertuig.",
+      "whoMarine": "Kies eerst een klant of een boot.",
+      "notifications": "Controleer eerst de tijden van de meldingen.",
+      "customerNotice": "Kies een klant, of verwijder de melding aan de klant."
+    },
     "appointmentWhoHint": "Kies een klant om die vóór de afspraak te kunnen herinneren.",
     "appointmentWhoHint": "Kies een klant om die vóór de afspraak te kunnen herinneren.",
     "appointmentWhoHintMarine": "Kies een klant om die vóór de afspraak te kunnen herinneren.",
     "appointmentWhoHintMarine": "Kies een klant om die vóór de afspraak te kunnen herinneren.",
     "whoLocked": "Wijzig de auto of de klant op de werkorder.",
     "whoLocked": "Wijzig de auto of de klant op de werkorder.",

+ 8 - 0
messages/pl/calendar.json

@@ -220,6 +220,14 @@
     "durationHours": "{count, plural, one {# godzina} few {# godziny} many {# godzin} other {# godziny}}",
     "durationHours": "{count, plural, one {# godzina} few {# godziny} many {# godzin} other {# godziny}}",
     "durationMinutes": "{count, plural, one {# minuta} few {# minuty} many {# minut} other {# minuty}}",
     "durationMinutes": "{count, plural, one {# minuta} few {# minuty} many {# minut} other {# minuty}}",
     "endAfterStart": "Koniec musi być po początku i najwyżej tydzień później.",
     "endAfterStart": "Koniec musi być po początku i najwyżej tydzień później.",
+    "missing": {
+      "title": "Najpierw dodaj tytuł.",
+      "times": "Ustaw koniec co najmniej 5 minut po początku i najwyżej tydzień później.",
+      "who": "Najpierw wybierz klienta lub pojazd.",
+      "whoMarine": "Najpierw wybierz klienta lub łódź.",
+      "notifications": "Najpierw sprawdź czasy powiadomień.",
+      "customerNotice": "Wybierz klienta albo usuń powiadomienie dla klienta."
+    },
     "appointmentWhoHint": "Wybierz klienta, aby móc powiadomić go przed wizytą.",
     "appointmentWhoHint": "Wybierz klienta, aby móc powiadomić go przed wizytą.",
     "appointmentWhoHintMarine": "Wybierz klienta, aby móc powiadomić go przed wizytą.",
     "appointmentWhoHintMarine": "Wybierz klienta, aby móc powiadomić go przed wizytą.",
     "whoLocked": "Auto lub klienta zmienisz w zleceniu.",
     "whoLocked": "Auto lub klienta zmienisz w zleceniu.",

+ 8 - 0
messages/pt-BR/calendar.json

@@ -220,6 +220,14 @@
     "durationHours": "{count, plural, one {# hora} other {# horas}}",
     "durationHours": "{count, plural, one {# hora} other {# horas}}",
     "durationMinutes": "{count, plural, one {# minuto} other {# minutos}}",
     "durationMinutes": "{count, plural, one {# minuto} other {# minutos}}",
     "endAfterStart": "O fim precisa ser depois do início e, no máximo, uma semana depois.",
     "endAfterStart": "O fim precisa ser depois do início e, no máximo, uma semana depois.",
+    "missing": {
+      "title": "Adicione um título primeiro.",
+      "times": "Defina um fim pelo menos 5 minutos depois do início e, no máximo, uma semana depois.",
+      "who": "Escolha primeiro um cliente ou um veículo.",
+      "whoMarine": "Escolha primeiro um cliente ou um barco.",
+      "notifications": "Confira primeiro os tempos das notificações.",
+      "customerNotice": "Escolha um cliente ou remova a notificação ao cliente."
+    },
     "appointmentWhoHint": "Escolha um cliente para poder avisá-lo antes do agendamento.",
     "appointmentWhoHint": "Escolha um cliente para poder avisá-lo antes do agendamento.",
     "appointmentWhoHintMarine": "Escolha um cliente para poder avisá-lo antes do agendamento.",
     "appointmentWhoHintMarine": "Escolha um cliente para poder avisá-lo antes do agendamento.",
     "whoLocked": "Altere o carro ou o cliente na ordem de serviço.",
     "whoLocked": "Altere o carro ou o cliente na ordem de serviço.",

+ 8 - 0
messages/pt-PT/calendar.json

@@ -220,6 +220,14 @@
     "durationHours": "{count, plural, one {# hora} other {# horas}}",
     "durationHours": "{count, plural, one {# hora} other {# horas}}",
     "durationMinutes": "{count, plural, one {# minuto} other {# minutos}}",
     "durationMinutes": "{count, plural, one {# minuto} other {# minutos}}",
     "endAfterStart": "O fim tem de ser depois do início e, no máximo, uma semana depois.",
     "endAfterStart": "O fim tem de ser depois do início e, no máximo, uma semana depois.",
+    "missing": {
+      "title": "Adicione primeiro um título.",
+      "times": "Defina um fim pelo menos 5 minutos depois do início e, no máximo, uma semana depois.",
+      "who": "Escolha primeiro um cliente ou um veículo.",
+      "whoMarine": "Escolha primeiro um cliente ou um barco.",
+      "notifications": "Verifique primeiro os tempos das notificações.",
+      "customerNotice": "Escolha um cliente ou remova a notificação ao cliente."
+    },
     "appointmentWhoHint": "Escolha um cliente para o poder avisar antes da marcação.",
     "appointmentWhoHint": "Escolha um cliente para o poder avisar antes da marcação.",
     "appointmentWhoHintMarine": "Escolha um cliente para o poder avisar antes da marcação.",
     "appointmentWhoHintMarine": "Escolha um cliente para o poder avisar antes da marcação.",
     "whoLocked": "Altere a viatura ou o cliente na ordem de serviço.",
     "whoLocked": "Altere a viatura ou o cliente na ordem de serviço.",

+ 8 - 0
messages/ru/calendar.json

@@ -220,6 +220,14 @@
     "durationHours": "{count, plural, one {# час} few {# часа} many {# часов} other {# часа}}",
     "durationHours": "{count, plural, one {# час} few {# часа} many {# часов} other {# часа}}",
     "durationMinutes": "{count, plural, one {# минута} few {# минуты} many {# минут} other {# минуты}}",
     "durationMinutes": "{count, plural, one {# минута} few {# минуты} many {# минут} other {# минуты}}",
     "endAfterStart": "Конец должен быть позже начала, но не более чем через неделю.",
     "endAfterStart": "Конец должен быть позже начала, но не более чем через неделю.",
+    "missing": {
+      "title": "Сначала добавьте название.",
+      "times": "Укажите конец не раньше чем через 5 минут после начала и не позже чем через неделю.",
+      "who": "Сначала выберите клиента или автомобиль.",
+      "whoMarine": "Сначала выберите клиента или лодку.",
+      "notifications": "Сначала проверьте время уведомлений.",
+      "customerNotice": "Выберите клиента или удалите уведомление клиенту."
+    },
     "appointmentWhoHint": "Выберите клиента, чтобы напомнить ему о записи заранее.",
     "appointmentWhoHint": "Выберите клиента, чтобы напомнить ему о записи заранее.",
     "appointmentWhoHintMarine": "Выберите клиента, чтобы напомнить ему о записи заранее.",
     "appointmentWhoHintMarine": "Выберите клиента, чтобы напомнить ему о записи заранее.",
     "whoLocked": "Автомобиль или клиента можно изменить в заказ-наряде.",
     "whoLocked": "Автомобиль или клиента можно изменить в заказ-наряде.",

+ 8 - 0
messages/tr/calendar.json

@@ -220,6 +220,14 @@
     "durationHours": "{count, plural, one {# saat} other {# saat}}",
     "durationHours": "{count, plural, one {# saat} other {# saat}}",
     "durationMinutes": "{count, plural, one {# dakika} other {# dakika}}",
     "durationMinutes": "{count, plural, one {# dakika} other {# dakika}}",
     "endAfterStart": "Bitiş, başlangıçtan sonra ve en fazla bir hafta sonra olmalıdır.",
     "endAfterStart": "Bitiş, başlangıçtan sonra ve en fazla bir hafta sonra olmalıdır.",
+    "missing": {
+      "title": "Önce bir başlık ekleyin.",
+      "times": "Başlangıçtan en az 5 dakika sonra ve en fazla bir hafta sonra bir bitiş belirleyin.",
+      "who": "Önce bir müşteri veya araç seçin.",
+      "whoMarine": "Önce bir müşteri veya tekne seçin.",
+      "notifications": "Önce bildirim sürelerini kontrol edin.",
+      "customerNotice": "Bir müşteri seçin veya müşteriye giden bildirimi kaldırın."
+    },
     "appointmentWhoHint": "Randevudan önce haber verebilmek için bir müşteri seçin.",
     "appointmentWhoHint": "Randevudan önce haber verebilmek için bir müşteri seçin.",
     "appointmentWhoHintMarine": "Randevudan önce haber verebilmek için bir müşteri seçin.",
     "appointmentWhoHintMarine": "Randevudan önce haber verebilmek için bir müşteri seçin.",
     "whoLocked": "Aracı veya müşteriyi iş emrinde değiştirin.",
     "whoLocked": "Aracı veya müşteriyi iş emrinde değiştirin.",

+ 53 - 6
src/__tests__/features/calendar/booking-dialog.test.tsx

@@ -245,18 +245,63 @@ describe('a new booking', () => {
   it('will not save without a title or with the end before the start', async () => {
   it('will not save without a title or with the end before the start', async () => {
     await renderDialog()
     await renderDialog()
     chooseKind('Appointment')
     chooseKind('Appointment')
-    expect(saveButton()).toBeDisabled()
+    fireEvent.click(saveButton())
+    expect(createBooking).not.toHaveBeenCalled()
 
 
     fireEvent.change(titleField(), { target: { value: 'Call Kari' } })
     fireEvent.change(titleField(), { target: { value: 'Call Kari' } })
-    expect(saveButton()).toBeEnabled()
-
     fireEvent.change(screen.getByLabelText('End'), { target: { value: '09:00' } })
     fireEvent.change(screen.getByLabelText('End'), { target: { value: '09:00' } })
-    expect(saveButton()).toBeDisabled()
+    fireEvent.click(saveButton())
+    expect(createBooking).not.toHaveBeenCalled()
     expect(
     expect(
       screen.getByText('The end has to be after the start, and at most a week later.')
       screen.getByText('The end has to be after the start, and at most a week later.')
     ).toBeInTheDocument()
     ).toBeInTheDocument()
   })
   })
 
 
+  it('never greys the button out: a press says what is missing and marks it', async () => {
+    await renderDialog()
+    chooseKind('Appointment')
+    // Nothing is said before the person has tried.
+    expect(saveButton()).toBeEnabled()
+    expect(screen.queryByRole('alert')).not.toBeInTheDocument()
+
+    fireEvent.click(saveButton())
+    expect(screen.getByRole('alert')).toHaveTextContent('Add a title first.')
+    expect(saveButton()).toHaveAccessibleDescription('Add a title first.')
+    expect(titleField()).toBeInvalid()
+    expect(titleField()).toHaveFocus()
+
+    // The mark and the words go as soon as it is put right.
+    fireEvent.change(titleField(), { target: { value: 'Call Kari' } })
+    expect(titleField()).toBeValid()
+    expect(screen.queryByRole('alert')).not.toBeInTheDocument()
+
+    fireEvent.change(screen.getByLabelText('End'), { target: { value: '09:00' } })
+    expect(screen.getByRole('alert')).toHaveTextContent(
+      'Set an end at least 5 minutes after the start, and at most a week later.'
+    )
+    // Too short is said the same way as the wrong way round.
+    fireEvent.change(screen.getByLabelText('End'), { target: { value: '09:01' } })
+    expect(screen.getByRole('alert')).toHaveTextContent('at least 5 minutes after the start')
+
+    fireEvent.change(screen.getByLabelText('End'), { target: { value: '10:00' } })
+    chooseKind('Work order')
+    expect(screen.getByRole('alert')).toHaveTextContent('Choose a customer or a car first.')
+    expect(createBooking).not.toHaveBeenCalled()
+  })
+
+  it('says what is missing on the press even when the browser stops the submit', async () => {
+    await renderDialog()
+    chooseKind('Appointment')
+    fireEvent.change(titleField(), { target: { value: 'Call Kari' } })
+    // An emptied time is refused by the browser before the form submits.
+    fireEvent.change(screen.getByLabelText('End'), { target: { value: '' } })
+    expect(screen.queryByRole('alert')).not.toBeInTheDocument()
+
+    fireEvent.click(saveButton())
+    expect(screen.getByRole('alert')).toHaveTextContent('at least 5 minutes after the start')
+    expect(createBooking).not.toHaveBeenCalled()
+  })
+
   it('will not book a work order until it knows the customer or the car', async () => {
   it('will not book a work order until it knows the customer or the car', async () => {
     createBooking.mockResolvedValue({
     createBooking.mockResolvedValue({
       success: true,
       success: true,
@@ -277,11 +322,13 @@ describe('a new booking', () => {
     addConcern('Oil service')
     addConcern('Oil service')
     expect(screen.getByLabelText('Concern 1')).toHaveValue('Front brakes squeal')
     expect(screen.getByLabelText('Concern 1')).toHaveValue('Front brakes squeal')
     expect(screen.getByLabelText('Concern 2')).toHaveValue('Oil service')
     expect(screen.getByLabelText('Concern 2')).toHaveValue('Oil service')
-    expect(saveButton()).toBeDisabled()
+    fireEvent.click(saveButton())
+    expect(createBooking).not.toHaveBeenCalled()
+    expect(screen.getByRole('alert')).toHaveTextContent('Choose a customer or a car first.')
 
 
     await chooseCustomer()
     await chooseCustomer()
     expect(customerField()).toHaveTextContent('Kari Nordmann')
     expect(customerField()).toHaveTextContent('Kari Nordmann')
-    expect(saveButton()).toBeEnabled()
+    expect(screen.queryByRole('alert')).not.toBeInTheDocument()
     fireEvent.click(saveButton())
     fireEvent.click(saveButton())
 
 
     await waitFor(() => expect(onSaved).toHaveBeenCalled())
     await waitFor(() => expect(onSaved).toHaveBeenCalled())

+ 60 - 5
src/features/calendar/Components/BookingDialog.tsx

@@ -1,6 +1,7 @@
 'use client'
 'use client'
 
 
-import { useEffect, useMemo, useState } from 'react'
+import { useEffect, useMemo, useRef, useState } from 'react'
+import { cn } from '@/lib/utils'
 import { useTranslations } from 'next-intl'
 import { useTranslations } from 'next-intl'
 import { toast } from 'sonner'
 import { toast } from 'sonner'
 import {
 import {
@@ -242,6 +243,9 @@ function BookingForm({
   const [meeting, setMeeting] = useState<string | null>(null)
   const [meeting, setMeeting] = useState<string | null>(null)
   // The end date shows for a booking that runs into another day, or once asked for.
   // The end date shows for a booking that runs into another day, or once asked for.
   const [multiDay, setMultiDay] = useState(false)
   const [multiDay, setMultiDay] = useState(false)
+  // Set by a press of the button that could not save.
+  const [tried, setTried] = useState(false)
+  const titleRef = useRef<HTMLInputElement>(null)
 
 
   // What the workshop offers, and the booking being changed.
   // What the workshop offers, and the booking being changed.
   useEffect(() => {
   useEffect(() => {
@@ -342,6 +346,21 @@ function BookingForm({
     customerRowsOk &&
     customerRowsOk &&
     (!isWorkOrder || Boolean(vehicleId || customerId))
     (!isWorkOrder || Boolean(vehicleId || customerId))
 
 
+  // What still stands between the form and a booking. The button is never
+  // greyed out for it: a press that cannot save marks what is missing and
+  // says so beside the button, where a dead button leaves the person guessing.
+  const missing = !titleText.trim()
+    ? t('missing.title')
+    : !timesValid
+      ? t('missing.times')
+      : isWorkOrder && !(vehicleId || customerId)
+        ? t(isMarine ? 'missing.whoMarine' : 'missing.who')
+        : !rowsValid
+          ? t('missing.notifications')
+          : !customerRowsOk
+            ? t('missing.customerNotice')
+            : null
+
   const chooseKind = (next: BookingKind) => {
   const chooseKind = (next: BookingKind) => {
     setKind(next)
     setKind(next)
     if (!edit) {
     if (!edit) {
@@ -362,7 +381,12 @@ function BookingForm({
 
 
   const handleSubmit = async (e: React.FormEvent) => {
   const handleSubmit = async (e: React.FormEvent) => {
     e.preventDefault()
     e.preventDefault()
-    if (!ready || saving) return
+    if (saving) return
+    if (!ready) {
+      setTried(true)
+      if (!titleText.trim()) titleRef.current?.focus()
+      return
+    }
     onSavingChange(true)
     onSavingChange(true)
     try {
     try {
       const payload = {
       const payload = {
@@ -428,13 +452,15 @@ function BookingForm({
         {/* Title and what it is, the way a calendar app opens. */}
         {/* Title and what it is, the way a calendar app opens. */}
         <div className="space-y-2.5 pr-6">
         <div className="space-y-2.5 pr-6">
           <Input
           <Input
+            ref={titleRef}
             aria-label={t('titleLabel')}
             aria-label={t('titleLabel')}
+            aria-invalid={tried && !titleText.trim() ? true : undefined}
             value={titleText}
             value={titleText}
             onChange={(e) => setTitleText(e.target.value)}
             onChange={(e) => setTitleText(e.target.value)}
             placeholder={t('titlePlaceholder')}
             placeholder={t('titlePlaceholder')}
             maxLength={200}
             maxLength={200}
             autoFocus
             autoFocus
-            className="h-14 rounded-none border-0 border-b-2 border-border bg-transparent px-1 text-2xl font-medium tracking-tight shadow-none placeholder:font-normal placeholder:text-muted-foreground/70 focus-visible:border-primary focus-visible:ring-0 md:text-2xl dark:bg-transparent"
+            className="h-14 rounded-none border-0 border-b-2 border-border bg-transparent px-1 text-2xl font-medium tracking-tight shadow-none placeholder:font-normal placeholder:text-muted-foreground/70 focus-visible:border-primary focus-visible:ring-0 aria-invalid:border-destructive aria-invalid:focus-visible:border-destructive md:text-2xl dark:bg-transparent"
           />
           />
           <div className="flex flex-wrap items-center gap-3">
           <div className="flex flex-wrap items-center gap-3">
             <Tabs value={kind} onValueChange={(v) => chooseKind(v as BookingKind)}>
             <Tabs value={kind} onValueChange={(v) => chooseKind(v as BookingKind)}>
@@ -568,7 +594,14 @@ function BookingForm({
                 }}
                 }}
               />
               />
               {(lockedWho || isWorkOrder) && (
               {(lockedWho || isWorkOrder) && (
-                <p className="text-xs text-muted-foreground">
+                <p
+                  className={cn(
+                    'text-xs',
+                    tried && isWorkOrder && !hasCustomer
+                      ? 'text-destructive'
+                      : 'text-muted-foreground'
+                  )}
+                >
                   {lockedWho
                   {lockedWho
                     ? isMarine
                     ? isMarine
                       ? t('whoLockedMarine')
                       ? t('whoLockedMarine')
@@ -692,10 +725,32 @@ function BookingForm({
         <Button type="button" variant="outline" onClick={onCancel} disabled={saving}>
         <Button type="button" variant="outline" onClick={onCancel} disabled={saving}>
           {tc('cancel')}
           {tc('cancel')}
         </Button>
         </Button>
-        <Button data-save-shortcut type="submit" disabled={!ready || saving}>
+        <Button
+          data-save-shortcut
+          type="submit"
+          disabled={saving}
+          // On the press, not only on submit: a field the browser itself
+          // refuses (an emptied time, a fractional amount) never reaches the
+          // form's submit, and the press must still say what is missing.
+          onClick={() => {
+            if (!ready) setTried(true)
+          }}
+          aria-describedby={tried && missing ? 'booking-missing' : undefined}
+        >
           {saving && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
           {saving && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
           {editing ? tc('save') : converting ? t('convertSubmit') : t('submit')}
           {editing ? tc('save') : converting ? t('convertSubmit') : t('submit')}
         </Button>
         </Button>
+        {/* Last in the markup so it sits above the buttons on a phone, where
+            the footer stacks upwards; first on a wider screen. */}
+        {tried && missing && (
+          <p
+            id="booking-missing"
+            role="alert"
+            className="text-sm text-destructive sm:order-first sm:mr-auto sm:self-center"
+          >
+            {missing}
+          </p>
+        )}
       </DialogFooter>
       </DialogFooter>
     </form>
     </form>
   )
   )