L8 Notdienst: mobile Erfassung /m/emergency in drei Schritten
Kunde suchen oder vorläufig anlegen, Einsatzort mit Ansprechpartner, Grund mit optionaler Sprachnotiz, Beginn und Team; Start über die Sync-Op. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,236 @@
|
|||||||
|
{
|
||||||
|
"capture": {
|
||||||
|
"title": "Notdienst",
|
||||||
|
"sub": "Einsatz in 3 Schritten anlegen und sofort starten.",
|
||||||
|
"noAccess": "Die Notdienst-Erfassung ist für Ihre Rolle nicht freigeschaltet.",
|
||||||
|
"stepOf": "Schritt {step} von 3",
|
||||||
|
"steps": {
|
||||||
|
"customer": "Kunde",
|
||||||
|
"site": "Einsatzort",
|
||||||
|
"reason": "Grund & Start"
|
||||||
|
},
|
||||||
|
"next": "Weiter",
|
||||||
|
"back": "Zurück",
|
||||||
|
"required": "Bitte die markierten Pflichtfelder ausfüllen.",
|
||||||
|
"start": "Einsatz starten",
|
||||||
|
"starting": "Einsatz wird angelegt …",
|
||||||
|
"queued": "Einsatz ist gespeichert und wird übertragen, sobald wieder Verbindung besteht.",
|
||||||
|
"customer": {
|
||||||
|
"existing": "Bestehender Kunde",
|
||||||
|
"new": "Neuer Kunde",
|
||||||
|
"search": "Kunde suchen",
|
||||||
|
"searchPlaceholder": "Name, Ort oder Kundennummer",
|
||||||
|
"searchHint": "Mindestens 2 Zeichen eingeben.",
|
||||||
|
"searching": "Suche läuft …",
|
||||||
|
"offline": "Suche gerade nicht möglich. Ohne Verbindung bitte einen neuen Kunden anlegen.",
|
||||||
|
"noHits": "Kein Kunde gefunden. Legen Sie einen neuen Kunden an.",
|
||||||
|
"provisional": "Vorläufig",
|
||||||
|
"change": "Anderen Kunden wählen",
|
||||||
|
"selectRequired": "Bitte einen Kunden auswählen oder neu anlegen.",
|
||||||
|
"newHint": "Wird als vorläufiger Kunde angelegt. Das Büro prüft ihn am nächsten Arbeitstag.",
|
||||||
|
"companyName": "Firma",
|
||||||
|
"firstName": "Vorname",
|
||||||
|
"lastName": "Nachname",
|
||||||
|
"nameHint": "Firma oder Nachname angeben.",
|
||||||
|
"phone": "Telefon",
|
||||||
|
"email": "E-Mail (optional)",
|
||||||
|
"street": "Straße",
|
||||||
|
"houseNumber": "Nr.",
|
||||||
|
"postalCode": "PLZ",
|
||||||
|
"city": "Ort"
|
||||||
|
},
|
||||||
|
"site": {
|
||||||
|
"loading": "Objekte werden geladen …",
|
||||||
|
"existing": "Objekt des Kunden",
|
||||||
|
"newAddress": "Andere Einsatzadresse",
|
||||||
|
"none": "Für diesen Kunden ist kein Objekt hinterlegt. Bitte die Einsatzadresse erfassen.",
|
||||||
|
"newHint": "Die Einsatzadresse wird als vorläufiges Objekt angelegt.",
|
||||||
|
"useCustomerAddress": "Kundenadresse übernehmen",
|
||||||
|
"name": "Bezeichnung (optional)",
|
||||||
|
"contactTitle": "Ansprechpartner vor Ort",
|
||||||
|
"contactName": "Name",
|
||||||
|
"contactPhone": "Telefon"
|
||||||
|
},
|
||||||
|
"reason": {
|
||||||
|
"label": "Grund des Notdiensteinsatzes",
|
||||||
|
"placeholder": "z. B. Wasserrohrbruch im Keller, Heizung ausgefallen",
|
||||||
|
"voice": "Sprachnotiz (optional)",
|
||||||
|
"voiceRecord": "Sprachnotiz aufnehmen",
|
||||||
|
"voiceRecording": "Aufnahme läuft · {seconds} s",
|
||||||
|
"voiceStop": "Aufnahme beenden",
|
||||||
|
"voiceDiscard": "Aufnahme verwerfen",
|
||||||
|
"voiceHint": "Wird nach dem Start am Einsatz gespeichert.",
|
||||||
|
"voiceDenied": "Kein Zugriff auf das Mikrofon. Bitte in den Geräteeinstellungen erlauben.",
|
||||||
|
"startedAt": "Beginn",
|
||||||
|
"team": "Team",
|
||||||
|
"noTeam": "Ohne Team",
|
||||||
|
"technicians": "Monteure",
|
||||||
|
"me": "Ich (immer dabei)"
|
||||||
|
},
|
||||||
|
"errors": {
|
||||||
|
"not_found": "Kunde oder Objekt nicht gefunden. Bitte Auswahl prüfen.",
|
||||||
|
"forbidden": "Dafür fehlt Ihnen die Berechtigung.",
|
||||||
|
"invalid": "Bitte die Eingaben prüfen.",
|
||||||
|
"conflict": "Der Einsatz wurde bereits angelegt. Bitte die Auftragsliste prüfen.",
|
||||||
|
"blocked": "Der Einsatz kann gerade nicht angelegt werden.",
|
||||||
|
"internal": "Einsatz konnte nicht angelegt werden. Bitte erneut versuchen.",
|
||||||
|
"network": "Keine Verbindung. Bitte erneut auf „Einsatz starten“ tippen."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"review": {
|
||||||
|
"crumb": "Aufträge · Notdienst",
|
||||||
|
"title": "Notdienst-Prüfung",
|
||||||
|
"sub": "Notdiensteinsätze mit vorläufigen Stammdaten oder zur Prüfung.",
|
||||||
|
"filterLabel": "Filter Notdiensteinsätze",
|
||||||
|
"filter": {
|
||||||
|
"open": "Zu prüfen",
|
||||||
|
"all": "Alle Notdienste"
|
||||||
|
},
|
||||||
|
"emptyOpen": "Keine Notdiensteinsätze zu prüfen.",
|
||||||
|
"emptyAll": "Noch keine Notdiensteinsätze.",
|
||||||
|
"customer": "Kunde",
|
||||||
|
"site": "Objekt",
|
||||||
|
"technician": "Monteur",
|
||||||
|
"startedAt": "Beginn",
|
||||||
|
"provisional": "Vorläufig",
|
||||||
|
"progress": "{count} von {total} Prüfschritten erledigt",
|
||||||
|
"back": "Zur Notdienst-Prüfung",
|
||||||
|
"detailSub": "Monteur: {technician} · Einsatzbeginn: {start} · Einsatzende: {end}",
|
||||||
|
"running": "läuft noch",
|
||||||
|
"openOrder": "Auftrag öffnen",
|
||||||
|
"steps": {
|
||||||
|
"customer": "Kunde klären",
|
||||||
|
"site": "Objekt klären",
|
||||||
|
"order": "Auftrag ergänzen",
|
||||||
|
"report": "Bericht freigeben",
|
||||||
|
"billing": "Abrechnung freigeben"
|
||||||
|
},
|
||||||
|
"stepDone": "Erledigt",
|
||||||
|
"stepOpen": "Offen",
|
||||||
|
"reason": "Grund des Notdiensteinsatzes",
|
||||||
|
"customerName": "Name",
|
||||||
|
"customerNumber": "Kundennummer",
|
||||||
|
"numberOnConfirm": "wird bei Bestätigung vergeben",
|
||||||
|
"status": "Status",
|
||||||
|
"customerStatus": {
|
||||||
|
"active": "Aktiv",
|
||||||
|
"inactive": "Inaktiv",
|
||||||
|
"provisional": "Vorläufig – Prüfung durch Backoffice erforderlich",
|
||||||
|
"merged": "Zusammengeführt"
|
||||||
|
},
|
||||||
|
"phone": "Telefon",
|
||||||
|
"email": "E-Mail",
|
||||||
|
"address": "Adresse",
|
||||||
|
"contact": "Ansprechpartner",
|
||||||
|
"provisionalHint": "Vorläufiger Kunde: bestätigen, einem bestehenden Kunden zuordnen oder mit einer Dublette zusammenführen.",
|
||||||
|
"saved": "Gespeichert.",
|
||||||
|
"confirmCustomer": {
|
||||||
|
"title": "Kunden bestätigen",
|
||||||
|
"hint": "Der Kunde wird aktiv und erhält eine Kundennummer.",
|
||||||
|
"submit": "Kunden bestätigen"
|
||||||
|
},
|
||||||
|
"duplicates": {
|
||||||
|
"title": "Mögliche Dubletten",
|
||||||
|
"none": "Keine ähnlichen Kunden gefunden.",
|
||||||
|
"score": "Übereinstimmung {score} %"
|
||||||
|
},
|
||||||
|
"target": {
|
||||||
|
"select": "Bestehender Kunde",
|
||||||
|
"none": "Bitte wählen",
|
||||||
|
"number": "oder Kundennummer"
|
||||||
|
},
|
||||||
|
"assignCustomer": {
|
||||||
|
"title": "Bestehendem Kunden zuordnen",
|
||||||
|
"hint": "Auftrag, Objekt und Ansprechpartner werden zum gewählten Kunden umgehängt. Der vorläufige Datensatz wird als zusammengeführt markiert.",
|
||||||
|
"submit": "Zuordnen"
|
||||||
|
},
|
||||||
|
"mergeCustomer": {
|
||||||
|
"title": "Dublette zusammenführen",
|
||||||
|
"hint": "Alle Ansprechpartner, Objekte, Aufträge und Dokumente dieses Kunden gehen auf den gewählten Kunden über. Nicht umkehrbar.",
|
||||||
|
"confirm": "Ich habe geprüft, dass es derselbe Kunde ist.",
|
||||||
|
"submit": "Zusammenführen"
|
||||||
|
},
|
||||||
|
"siteName": "Bezeichnung",
|
||||||
|
"siteStatus": {
|
||||||
|
"active": "Aktiv",
|
||||||
|
"inactive": "Inaktiv",
|
||||||
|
"provisional": "Vorläufig – Prüfung durch Backoffice erforderlich"
|
||||||
|
},
|
||||||
|
"onSiteContact": "Ansprechpartner vor Ort",
|
||||||
|
"noSite": "Kein Objekt am Auftrag.",
|
||||||
|
"street": "Straße",
|
||||||
|
"houseNumber": "Nr.",
|
||||||
|
"postalCode": "PLZ",
|
||||||
|
"city": "Ort",
|
||||||
|
"accessNotes": "Zugangshinweise",
|
||||||
|
"correctSite": {
|
||||||
|
"title": "Objekt korrigieren",
|
||||||
|
"confirm": "Objekt bestätigen (vorläufig → aktiv)",
|
||||||
|
"submit": "Objekt speichern"
|
||||||
|
},
|
||||||
|
"assignSite": {
|
||||||
|
"title": "Bestehendes Objekt zuordnen",
|
||||||
|
"hint": "Der Auftrag wird dem gewählten Objekt zugeordnet. Ein nicht mehr genutztes vorläufiges Objekt wird entfernt.",
|
||||||
|
"select": "Objekt des Kunden",
|
||||||
|
"none": "Der Kunde hat keine weiteren Objekte.",
|
||||||
|
"submit": "Objekt zuordnen"
|
||||||
|
},
|
||||||
|
"completeOrder": {
|
||||||
|
"title": "Titel",
|
||||||
|
"description": "Beschreibung",
|
||||||
|
"orderType": "Auftragsart",
|
||||||
|
"billingType": "Abrechnungsart",
|
||||||
|
"choose": "Bitte wählen",
|
||||||
|
"hint": "Erledigt, sobald Auftragsart und Abrechnungsart gesetzt sind.",
|
||||||
|
"submit": "Auftrag speichern"
|
||||||
|
},
|
||||||
|
"billingTypes": {
|
||||||
|
"fixed": "Pauschal",
|
||||||
|
"time_material": "Nach Aufwand",
|
||||||
|
"maintenance_contract": "Wartungsvertrag",
|
||||||
|
"warranty": "Gewährleistung"
|
||||||
|
},
|
||||||
|
"report": {
|
||||||
|
"none": "Noch kein Bericht eingereicht.",
|
||||||
|
"open": "Bericht prüfen",
|
||||||
|
"hint": "Freigabe und Zurückweisung erfolgen auf der Berichtsseite.",
|
||||||
|
"version": "Version {version}",
|
||||||
|
"type": {
|
||||||
|
"daily": "Tagesbericht",
|
||||||
|
"completion": "Abschlussbericht"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"draft": "Entwurf",
|
||||||
|
"submitted": "Eingereicht",
|
||||||
|
"team_approved": "Vom Teamleiter geprüft",
|
||||||
|
"approved": "Freigegeben",
|
||||||
|
"rejected": "Zurückgewiesen",
|
||||||
|
"superseded": "Ersetzt"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"billing": {
|
||||||
|
"hint": "Möglich, wenn Kunde und Objekt geklärt sind und der Abschlussbericht freigegeben ist.",
|
||||||
|
"submit": "Zur Abrechnung freigeben",
|
||||||
|
"current": "Aktueller Status"
|
||||||
|
},
|
||||||
|
"errors": {
|
||||||
|
"generic": "Das hat nicht geklappt. Bitte erneut versuchen.",
|
||||||
|
"invalid": "Bitte die Eingaben prüfen.",
|
||||||
|
"not_found": "Nicht gefunden.",
|
||||||
|
"forbidden": "Dafür fehlt Ihnen die Berechtigung.",
|
||||||
|
"conflict": "Der Datensatz wurde inzwischen geändert. Bitte Seite neu laden.",
|
||||||
|
"blocked": "Noch nicht möglich: Voraussetzungen fehlen.",
|
||||||
|
"not_provisional": "Der Kunde ist nicht mehr vorläufig.",
|
||||||
|
"same_customer": "Bitte einen anderen Kunden wählen.",
|
||||||
|
"same_site": "Der Auftrag ist diesem Objekt bereits zugeordnet.",
|
||||||
|
"target_not_found": "Kunde nicht gefunden. Bitte Auswahl oder Kundennummer prüfen.",
|
||||||
|
"not_found_target": "Kunde nicht gefunden.",
|
||||||
|
"confirm_required": "Bitte die Prüfung bestätigen.",
|
||||||
|
"already_merged": "Einer der Kunden wurde bereits zusammengeführt.",
|
||||||
|
"no_site": "Der Auftrag hat kein Objekt.",
|
||||||
|
"master_data_open": "Erst Kunde und Objekt klären, dann zur Abrechnung freigeben.",
|
||||||
|
"number_allocation": "Kundennummer konnte nicht vergeben werden. Bitte erneut versuchen.",
|
||||||
|
"number_taken": "Diese Kundennummer ist bereits vergeben."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,236 @@
|
|||||||
|
{
|
||||||
|
"capture": {
|
||||||
|
"title": "Emergency call-out",
|
||||||
|
"sub": "Create the call-out in 3 steps and start right away.",
|
||||||
|
"noAccess": "Emergency capture is not enabled for your role.",
|
||||||
|
"stepOf": "Step {step} of 3",
|
||||||
|
"steps": {
|
||||||
|
"customer": "Customer",
|
||||||
|
"site": "Location",
|
||||||
|
"reason": "Reason & start"
|
||||||
|
},
|
||||||
|
"next": "Next",
|
||||||
|
"back": "Back",
|
||||||
|
"required": "Please fill in the marked required fields.",
|
||||||
|
"start": "Start call-out",
|
||||||
|
"starting": "Creating call-out …",
|
||||||
|
"queued": "Call-out saved. It will be transferred once you are back online.",
|
||||||
|
"customer": {
|
||||||
|
"existing": "Existing customer",
|
||||||
|
"new": "New customer",
|
||||||
|
"search": "Search customer",
|
||||||
|
"searchPlaceholder": "Name, city or customer number",
|
||||||
|
"searchHint": "Enter at least 2 characters.",
|
||||||
|
"searching": "Searching …",
|
||||||
|
"offline": "Search is not available right now. Without a connection, please create a new customer.",
|
||||||
|
"noHits": "No customer found. Create a new customer.",
|
||||||
|
"provisional": "Provisional",
|
||||||
|
"change": "Choose another customer",
|
||||||
|
"selectRequired": "Please select a customer or create a new one.",
|
||||||
|
"newHint": "Will be created as a provisional customer. The office reviews it on the next working day.",
|
||||||
|
"companyName": "Company",
|
||||||
|
"firstName": "First name",
|
||||||
|
"lastName": "Last name",
|
||||||
|
"nameHint": "Enter company or last name.",
|
||||||
|
"phone": "Phone",
|
||||||
|
"email": "E-mail (optional)",
|
||||||
|
"street": "Street",
|
||||||
|
"houseNumber": "No.",
|
||||||
|
"postalCode": "Postcode",
|
||||||
|
"city": "City"
|
||||||
|
},
|
||||||
|
"site": {
|
||||||
|
"loading": "Loading sites …",
|
||||||
|
"existing": "Customer site",
|
||||||
|
"newAddress": "Other call-out address",
|
||||||
|
"none": "No site on file for this customer. Please enter the call-out address.",
|
||||||
|
"newHint": "The call-out address is created as a provisional site.",
|
||||||
|
"useCustomerAddress": "Use customer address",
|
||||||
|
"name": "Label (optional)",
|
||||||
|
"contactTitle": "Contact on site",
|
||||||
|
"contactName": "Name",
|
||||||
|
"contactPhone": "Phone"
|
||||||
|
},
|
||||||
|
"reason": {
|
||||||
|
"label": "Reason for the emergency call-out",
|
||||||
|
"placeholder": "e.g. burst water pipe in the basement, heating failure",
|
||||||
|
"voice": "Voice note (optional)",
|
||||||
|
"voiceRecord": "Record voice note",
|
||||||
|
"voiceRecording": "Recording · {seconds} s",
|
||||||
|
"voiceStop": "Stop recording",
|
||||||
|
"voiceDiscard": "Discard recording",
|
||||||
|
"voiceHint": "Saved to the call-out after it has started.",
|
||||||
|
"voiceDenied": "No microphone access. Please allow it in the device settings.",
|
||||||
|
"startedAt": "Start",
|
||||||
|
"team": "Team",
|
||||||
|
"noTeam": "No team",
|
||||||
|
"technicians": "Technicians",
|
||||||
|
"me": "Me (always included)"
|
||||||
|
},
|
||||||
|
"errors": {
|
||||||
|
"not_found": "Customer or site not found. Please check your selection.",
|
||||||
|
"forbidden": "You do not have permission for this.",
|
||||||
|
"invalid": "Please check your entries.",
|
||||||
|
"conflict": "The call-out has already been created. Please check the order list.",
|
||||||
|
"blocked": "The call-out cannot be created right now.",
|
||||||
|
"internal": "The call-out could not be created. Please try again.",
|
||||||
|
"network": "No connection. Please tap “Start call-out” again."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"review": {
|
||||||
|
"crumb": "Work orders · Emergency",
|
||||||
|
"title": "Emergency review",
|
||||||
|
"sub": "Emergency call-outs with provisional master data or awaiting review.",
|
||||||
|
"filterLabel": "Filter emergency call-outs",
|
||||||
|
"filter": {
|
||||||
|
"open": "To review",
|
||||||
|
"all": "All call-outs"
|
||||||
|
},
|
||||||
|
"emptyOpen": "No emergency call-outs to review.",
|
||||||
|
"emptyAll": "No emergency call-outs yet.",
|
||||||
|
"customer": "Customer",
|
||||||
|
"site": "Site",
|
||||||
|
"technician": "Technician",
|
||||||
|
"startedAt": "Start",
|
||||||
|
"provisional": "Provisional",
|
||||||
|
"progress": "{count} of {total} review steps done",
|
||||||
|
"back": "Back to emergency review",
|
||||||
|
"detailSub": "Technician: {technician} · Start: {start} · End: {end}",
|
||||||
|
"running": "still running",
|
||||||
|
"openOrder": "Open work order",
|
||||||
|
"steps": {
|
||||||
|
"customer": "Clarify customer",
|
||||||
|
"site": "Clarify site",
|
||||||
|
"order": "Complete order",
|
||||||
|
"report": "Approve report",
|
||||||
|
"billing": "Release for billing"
|
||||||
|
},
|
||||||
|
"stepDone": "Done",
|
||||||
|
"stepOpen": "Open",
|
||||||
|
"reason": "Reason for the emergency call-out",
|
||||||
|
"customerName": "Name",
|
||||||
|
"customerNumber": "Customer number",
|
||||||
|
"numberOnConfirm": "assigned on confirmation",
|
||||||
|
"status": "Status",
|
||||||
|
"customerStatus": {
|
||||||
|
"active": "Active",
|
||||||
|
"inactive": "Inactive",
|
||||||
|
"provisional": "Provisional – review by back office required",
|
||||||
|
"merged": "Merged"
|
||||||
|
},
|
||||||
|
"phone": "Phone",
|
||||||
|
"email": "E-mail",
|
||||||
|
"address": "Address",
|
||||||
|
"contact": "Contact",
|
||||||
|
"provisionalHint": "Provisional customer: confirm, assign to an existing customer or merge with a duplicate.",
|
||||||
|
"saved": "Saved.",
|
||||||
|
"confirmCustomer": {
|
||||||
|
"title": "Confirm customer",
|
||||||
|
"hint": "The customer becomes active and receives a customer number.",
|
||||||
|
"submit": "Confirm customer"
|
||||||
|
},
|
||||||
|
"duplicates": {
|
||||||
|
"title": "Possible duplicates",
|
||||||
|
"none": "No similar customers found.",
|
||||||
|
"score": "Match {score} %"
|
||||||
|
},
|
||||||
|
"target": {
|
||||||
|
"select": "Existing customer",
|
||||||
|
"none": "Please choose",
|
||||||
|
"number": "or customer number"
|
||||||
|
},
|
||||||
|
"assignCustomer": {
|
||||||
|
"title": "Assign to existing customer",
|
||||||
|
"hint": "Order, site and contacts move to the chosen customer. The provisional record is marked as merged.",
|
||||||
|
"submit": "Assign"
|
||||||
|
},
|
||||||
|
"mergeCustomer": {
|
||||||
|
"title": "Merge duplicate",
|
||||||
|
"hint": "All contacts, sites, orders and documents of this customer move to the chosen customer. Cannot be undone.",
|
||||||
|
"confirm": "I have checked that this is the same customer.",
|
||||||
|
"submit": "Merge"
|
||||||
|
},
|
||||||
|
"siteName": "Label",
|
||||||
|
"siteStatus": {
|
||||||
|
"active": "Active",
|
||||||
|
"inactive": "Inactive",
|
||||||
|
"provisional": "Provisional – review by back office required"
|
||||||
|
},
|
||||||
|
"onSiteContact": "Contact on site",
|
||||||
|
"noSite": "No site on this order.",
|
||||||
|
"street": "Street",
|
||||||
|
"houseNumber": "No.",
|
||||||
|
"postalCode": "Postcode",
|
||||||
|
"city": "City",
|
||||||
|
"accessNotes": "Access notes",
|
||||||
|
"correctSite": {
|
||||||
|
"title": "Correct site",
|
||||||
|
"confirm": "Confirm site (provisional → active)",
|
||||||
|
"submit": "Save site"
|
||||||
|
},
|
||||||
|
"assignSite": {
|
||||||
|
"title": "Assign existing site",
|
||||||
|
"hint": "The order is assigned to the chosen site. A provisional site that is no longer used is removed.",
|
||||||
|
"select": "Customer site",
|
||||||
|
"none": "The customer has no other sites.",
|
||||||
|
"submit": "Assign site"
|
||||||
|
},
|
||||||
|
"completeOrder": {
|
||||||
|
"title": "Title",
|
||||||
|
"description": "Description",
|
||||||
|
"orderType": "Order type",
|
||||||
|
"billingType": "Billing type",
|
||||||
|
"choose": "Please choose",
|
||||||
|
"hint": "Done once order type and billing type are set.",
|
||||||
|
"submit": "Save order"
|
||||||
|
},
|
||||||
|
"billingTypes": {
|
||||||
|
"fixed": "Fixed price",
|
||||||
|
"time_material": "Time and material",
|
||||||
|
"maintenance_contract": "Maintenance contract",
|
||||||
|
"warranty": "Warranty"
|
||||||
|
},
|
||||||
|
"report": {
|
||||||
|
"none": "No report submitted yet.",
|
||||||
|
"open": "Review report",
|
||||||
|
"hint": "Approval and rejection happen on the report page.",
|
||||||
|
"version": "Version {version}",
|
||||||
|
"type": {
|
||||||
|
"daily": "Daily report",
|
||||||
|
"completion": "Completion report"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"draft": "Draft",
|
||||||
|
"submitted": "Submitted",
|
||||||
|
"team_approved": "Checked by team lead",
|
||||||
|
"approved": "Approved",
|
||||||
|
"rejected": "Rejected",
|
||||||
|
"superseded": "Superseded"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"billing": {
|
||||||
|
"hint": "Possible once customer and site are clarified and the completion report is approved.",
|
||||||
|
"submit": "Release for billing",
|
||||||
|
"current": "Current status"
|
||||||
|
},
|
||||||
|
"errors": {
|
||||||
|
"generic": "That did not work. Please try again.",
|
||||||
|
"invalid": "Please check your entries.",
|
||||||
|
"not_found": "Not found.",
|
||||||
|
"forbidden": "You do not have permission for this.",
|
||||||
|
"conflict": "The record has changed in the meantime. Please reload the page.",
|
||||||
|
"blocked": "Not possible yet: prerequisites are missing.",
|
||||||
|
"not_provisional": "The customer is no longer provisional.",
|
||||||
|
"same_customer": "Please choose a different customer.",
|
||||||
|
"same_site": "The order is already assigned to this site.",
|
||||||
|
"target_not_found": "Customer not found. Please check the selection or customer number.",
|
||||||
|
"not_found_target": "Customer not found.",
|
||||||
|
"confirm_required": "Please confirm the check.",
|
||||||
|
"already_merged": "One of the customers has already been merged.",
|
||||||
|
"no_site": "The order has no site.",
|
||||||
|
"master_data_open": "Clarify customer and site first, then release for billing.",
|
||||||
|
"number_allocation": "The customer number could not be assigned. Please try again.",
|
||||||
|
"number_taken": "This customer number is already taken."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,25 @@
|
|||||||
import { ModulePlaceholder } from "@/components/module-placeholder";
|
import { getTranslations } from "next-intl/server";
|
||||||
|
import { moduleGuard } from "@/server/action-guard";
|
||||||
|
import { can, ctxFromGuard } from "@/server/services/context";
|
||||||
|
import { emergencyTeamOptions } from "@/server/services/emergency/lookup";
|
||||||
|
import { EmergencyWizard } from "@/components/emergency/emergency-wizard";
|
||||||
|
|
||||||
export default function Page() {
|
/** `/m/emergency` — Notdienst erfassen (spec §19.2, US-010): max. 3 steps, then straight into the call-out. */
|
||||||
return <ModulePlaceholder moduleKey="emergency" />;
|
export default async function EmergencyPage() {
|
||||||
|
const ctx = ctxFromGuard(await moduleGuard("emergency")());
|
||||||
|
const t = await getTranslations("emergency.capture");
|
||||||
|
if (!can(ctx, "emergency:create") || !can(ctx, "field:execute")) {
|
||||||
|
return <p className="p-4 text-[15px]">{t("noAccess")}</p>;
|
||||||
|
}
|
||||||
|
const teams = await emergencyTeamOptions(ctx);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main className="space-y-4 p-4">
|
||||||
|
<div>
|
||||||
|
<h1 className="text-[26px]">{t("title")}</h1>
|
||||||
|
<p className="text-[15px] text-muted-foreground">{t("sub")}</p>
|
||||||
|
</div>
|
||||||
|
<EmergencyWizard teams={teams} userId={ctx.userId} />
|
||||||
|
</main>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,618 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useEffect, useMemo, useRef, useState, useTransition } from "react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { useTranslations } from "next-intl";
|
||||||
|
import { Building2, Check, ChevronLeft, ChevronRight, LoaderCircle, MapPin, Mic, Search, Siren, Square, TriangleAlert, UserPlus, Users } from "lucide-react";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { errorKey, isSuccess, newClientId, submitOp } from "@/lib/field/client-ops";
|
||||||
|
import { uploadFieldFile } from "@/lib/field/upload";
|
||||||
|
import type { EmergencyCreateInput } from "@/lib/emergency/schemas";
|
||||||
|
import { btnPrimary, btnSecondary, card, chip, inputClass, noticeError, noticeWarn } from "@/components/field/ui";
|
||||||
|
import { listEmergencySitesAction, searchEmergencyCustomersAction } from "@/server/actions/emergency/capture";
|
||||||
|
import type { EmergencyCustomerHit, EmergencySiteHit, EmergencyTeamOption } from "@/server/services/emergency/lookup";
|
||||||
|
|
||||||
|
type Step = 1 | 2 | 3;
|
||||||
|
type NewCustomer = { companyName: string; firstName: string; lastName: string; phone: string; email: string; street: string; houseNumber: string; postalCode: string; city: string };
|
||||||
|
type Address = { name: string; street: string; houseNumber: string; postalCode: string; city: string };
|
||||||
|
|
||||||
|
const EMPTY_CUSTOMER: NewCustomer = { companyName: "", firstName: "", lastName: "", phone: "", email: "", street: "", houseNumber: "", postalCode: "", city: "" };
|
||||||
|
const EMPTY_ADDRESS: Address = { name: "", street: "", houseNumber: "", postalCode: "", city: "" };
|
||||||
|
const MAX_VOICE_SECONDS = 300;
|
||||||
|
|
||||||
|
function localNow(): string {
|
||||||
|
const d = new Date();
|
||||||
|
d.setMinutes(d.getMinutes() - d.getTimezoneOffset());
|
||||||
|
return d.toISOString().slice(0, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
function TextField({
|
||||||
|
id,
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
type = "text",
|
||||||
|
required,
|
||||||
|
autoComplete,
|
||||||
|
inputMode,
|
||||||
|
className,
|
||||||
|
invalid,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
value: string;
|
||||||
|
onChange: (v: string) => void;
|
||||||
|
type?: string;
|
||||||
|
required?: boolean;
|
||||||
|
autoComplete?: string;
|
||||||
|
inputMode?: React.HTMLAttributes<HTMLInputElement>["inputMode"];
|
||||||
|
className?: string;
|
||||||
|
invalid?: boolean;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className={className}>
|
||||||
|
<label htmlFor={id} className="mb-1 block text-[14px] font-semibold">
|
||||||
|
{label}
|
||||||
|
{required && <span aria-hidden> *</span>}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id={id}
|
||||||
|
type={type}
|
||||||
|
value={value}
|
||||||
|
onChange={(e) => onChange(e.target.value)}
|
||||||
|
required={required}
|
||||||
|
autoComplete={autoComplete}
|
||||||
|
inputMode={inputMode}
|
||||||
|
aria-invalid={invalid || undefined}
|
||||||
|
className={cn(inputClass, invalid && "border-[var(--risk)]")}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function EmergencyWizard({ teams, userId }: { teams: EmergencyTeamOption[]; userId: string }) {
|
||||||
|
const t = useTranslations("emergency.capture");
|
||||||
|
const router = useRouter();
|
||||||
|
const [step, setStep] = useState<Step>(1);
|
||||||
|
const [showErrors, setShowErrors] = useState(false);
|
||||||
|
|
||||||
|
// step 1 — customer
|
||||||
|
const [customerMode, setCustomerMode] = useState<"existing" | "new">("existing");
|
||||||
|
const [query, setQuery] = useState("");
|
||||||
|
const [hits, setHits] = useState<EmergencyCustomerHit[]>([]);
|
||||||
|
const [searching, startSearch] = useTransition();
|
||||||
|
const [searchFailed, setSearchFailed] = useState(false);
|
||||||
|
const [selected, setSelected] = useState<EmergencyCustomerHit | null>(null);
|
||||||
|
const [newCustomer, setNewCustomer] = useState<NewCustomer>(EMPTY_CUSTOMER);
|
||||||
|
|
||||||
|
// step 2 — site
|
||||||
|
const [sites, setSites] = useState<EmergencySiteHit[] | null>(null);
|
||||||
|
const [siteMode, setSiteMode] = useState<"existing" | "new">("new");
|
||||||
|
const [siteId, setSiteId] = useState<string>("");
|
||||||
|
const [address, setAddress] = useState<Address>(EMPTY_ADDRESS);
|
||||||
|
const [contact, setContact] = useState({ name: "", phone: "" });
|
||||||
|
|
||||||
|
// step 3 — reason / start / team
|
||||||
|
const [reason, setReason] = useState("");
|
||||||
|
const [startedAt, setStartedAt] = useState("");
|
||||||
|
const [teamId, setTeamId] = useState<string>(teams[0]?.id ?? "");
|
||||||
|
const [colleagues, setColleagues] = useState<string[]>([]);
|
||||||
|
|
||||||
|
// voice note (kept locally, uploaded after the call-out exists)
|
||||||
|
const [recState, setRecState] = useState<"idle" | "recording" | "recorded">("idle");
|
||||||
|
const [recSeconds, setRecSeconds] = useState(0);
|
||||||
|
const [clip, setClip] = useState<{ blob: Blob; url: string } | null>(null);
|
||||||
|
const recorder = useRef<MediaRecorder | null>(null);
|
||||||
|
const timer = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||||
|
|
||||||
|
// submit
|
||||||
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
// stable client ids → a retry after a network error is idempotent (same session client id)
|
||||||
|
const clientIds = useRef({ workOrder: newClientId(), session: newClientId(), customer: newClientId(), site: newClientId() });
|
||||||
|
|
||||||
|
const searchTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
|
const selectionSeq = useRef(0);
|
||||||
|
|
||||||
|
useEffect(
|
||||||
|
() => () => {
|
||||||
|
if (timer.current) clearInterval(timer.current);
|
||||||
|
if (searchTimer.current) clearTimeout(searchTimer.current);
|
||||||
|
recorder.current?.stream.getTracks().forEach((tr) => tr.stop());
|
||||||
|
},
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
useEffect(() => () => (clip ? URL.revokeObjectURL(clip.url) : undefined), [clip]);
|
||||||
|
|
||||||
|
/** Debounced customer search (event-driven, no state updates inside effects). */
|
||||||
|
function onQueryChange(value: string) {
|
||||||
|
setQuery(value);
|
||||||
|
if (searchTimer.current) clearTimeout(searchTimer.current);
|
||||||
|
const q = value.trim();
|
||||||
|
if (q.length < 2) {
|
||||||
|
setHits([]);
|
||||||
|
setSearchFailed(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
searchTimer.current = setTimeout(() => {
|
||||||
|
startSearch(async () => {
|
||||||
|
const res = await searchEmergencyCustomersAction(q);
|
||||||
|
setSearchFailed(!res.ok);
|
||||||
|
setHits(res.ok ? res.items : []);
|
||||||
|
});
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetSites() {
|
||||||
|
selectionSeq.current++;
|
||||||
|
setSites(null);
|
||||||
|
setSiteMode("new");
|
||||||
|
setSiteId("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Select a customer and load its sites for step 2. */
|
||||||
|
function selectCustomer(hit: EmergencyCustomerHit | null) {
|
||||||
|
setSelected(hit);
|
||||||
|
resetSites();
|
||||||
|
if (!hit) return;
|
||||||
|
const seq = selectionSeq.current;
|
||||||
|
listEmergencySitesAction(hit.id).then((res) => {
|
||||||
|
if (seq !== selectionSeq.current) return;
|
||||||
|
const items = res.ok ? res.items : [];
|
||||||
|
setSites(items);
|
||||||
|
if (items.length) {
|
||||||
|
setSiteMode("existing");
|
||||||
|
setSiteId(items[0].id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function switchCustomerMode(mode: "existing" | "new") {
|
||||||
|
setCustomerMode(mode);
|
||||||
|
selectCustomer(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
const team = useMemo(() => teams.find((x) => x.id === teamId) ?? null, [teams, teamId]);
|
||||||
|
|
||||||
|
const step1Valid =
|
||||||
|
customerMode === "existing" ? !!selected : !!(newCustomer.companyName.trim() || newCustomer.lastName.trim()) && !!newCustomer.phone.trim();
|
||||||
|
const step2Valid =
|
||||||
|
(siteMode === "existing" ? !!siteId : !!address.street.trim() && !!address.city.trim()) && !!contact.name.trim() && !!contact.phone.trim();
|
||||||
|
const step3Valid = !!reason.trim() && !!startedAt;
|
||||||
|
|
||||||
|
function go(next: Step) {
|
||||||
|
const valid = step === 1 ? step1Valid : step === 2 ? step2Valid : step3Valid;
|
||||||
|
if (next > step && !valid) {
|
||||||
|
setShowErrors(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setShowErrors(false);
|
||||||
|
setError(null);
|
||||||
|
if (next === 2 && customerMode === "new" && !contact.name && !contact.phone) {
|
||||||
|
const name = [newCustomer.firstName, newCustomer.lastName].filter((s) => s.trim()).join(" ") || newCustomer.companyName;
|
||||||
|
setContact({ name, phone: newCustomer.phone });
|
||||||
|
}
|
||||||
|
if (next === 3 && !startedAt) setStartedAt(localNow()); // default "now" when the step opens
|
||||||
|
setStep(next);
|
||||||
|
window.scrollTo({ top: 0 });
|
||||||
|
}
|
||||||
|
|
||||||
|
function useCustomerAddress() {
|
||||||
|
setAddress((a) => ({ ...a, street: newCustomer.street, houseNumber: newCustomer.houseNumber, postalCode: newCustomer.postalCode, city: newCustomer.city }));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function startRecording() {
|
||||||
|
try {
|
||||||
|
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||||
|
const types = ["audio/webm;codecs=opus", "audio/webm", "audio/mp4", "audio/ogg;codecs=opus"];
|
||||||
|
const mimeType = typeof MediaRecorder !== "undefined" ? types.find((x) => MediaRecorder.isTypeSupported(x)) : undefined;
|
||||||
|
const rec = new MediaRecorder(stream, mimeType ? { mimeType } : undefined);
|
||||||
|
const chunks: BlobPart[] = [];
|
||||||
|
rec.ondataavailable = (e) => e.data.size > 0 && chunks.push(e.data);
|
||||||
|
rec.onstop = () => {
|
||||||
|
stream.getTracks().forEach((tr) => tr.stop());
|
||||||
|
const blob = new Blob(chunks, { type: rec.mimeType || mimeType || "audio/webm" });
|
||||||
|
setClip({ blob, url: URL.createObjectURL(blob) });
|
||||||
|
setRecState("recorded");
|
||||||
|
};
|
||||||
|
recorder.current = rec;
|
||||||
|
rec.start(1000);
|
||||||
|
setRecSeconds(0);
|
||||||
|
setRecState("recording");
|
||||||
|
timer.current = setInterval(() => {
|
||||||
|
setRecSeconds((s) => {
|
||||||
|
if (s + 1 >= MAX_VOICE_SECONDS) stopRecording();
|
||||||
|
return Math.min(s + 1, MAX_VOICE_SECONDS);
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
} catch {
|
||||||
|
setError(t("reason.voiceDenied"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopRecording() {
|
||||||
|
if (timer.current) clearInterval(timer.current);
|
||||||
|
timer.current = null;
|
||||||
|
if (recorder.current?.state === "recording") recorder.current.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submit() {
|
||||||
|
if (!step3Valid) {
|
||||||
|
setShowErrors(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setSubmitting(true);
|
||||||
|
setError(null);
|
||||||
|
const payload: EmergencyCreateInput = {
|
||||||
|
clientIds: clientIds.current,
|
||||||
|
customer:
|
||||||
|
customerMode === "existing" && selected
|
||||||
|
? { mode: "existing", customerId: selected.id }
|
||||||
|
: { mode: "new", ...newCustomer },
|
||||||
|
site: siteMode === "existing" ? { mode: "existing", siteId } : { mode: "new", ...address },
|
||||||
|
onSiteContact: contact,
|
||||||
|
reason,
|
||||||
|
startedAt: new Date(startedAt).toISOString(),
|
||||||
|
teamId: teamId || null,
|
||||||
|
assigneeIds: colleagues.filter((c) => c !== userId),
|
||||||
|
offline: typeof navigator !== "undefined" && !navigator.onLine,
|
||||||
|
deviceInfo: typeof navigator !== "undefined" ? navigator.userAgent.slice(0, 200) : undefined,
|
||||||
|
};
|
||||||
|
const result = await submitOp({ opType: "emergency.create", payload });
|
||||||
|
const workOrderId = result.idMap?.[clientIds.current.workOrder];
|
||||||
|
if (!isSuccess(result) || !workOrderId) {
|
||||||
|
setSubmitting(false);
|
||||||
|
const key = isSuccess(result) ? "queued" : errorKey(result);
|
||||||
|
setError(key === "queued" ? t("queued") : t(`errors.${key}`));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (clip) {
|
||||||
|
const type = clip.blob.type || "audio/webm";
|
||||||
|
const ext = type.includes("mp4") ? "m4a" : type.includes("ogg") ? "ogg" : "webm";
|
||||||
|
const up = await uploadFieldFile({ workOrderId, kind: "voice_note", clientId: newClientId(), file: clip.blob, fileName: `notdienst.${ext}` });
|
||||||
|
if (up.ok) {
|
||||||
|
await submitOp({
|
||||||
|
opType: "voice.attach",
|
||||||
|
payload: { workOrderId, clientId: newClientId(), documentId: up.documentId, durationSeconds: recSeconds, recordedAt: new Date().toISOString(), kind: "problem" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
router.push(`/m/orders/${workOrderId}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const stepLabels = [t("steps.customer"), t("steps.site"), t("steps.reason")];
|
||||||
|
const err = (cond: boolean) => showErrors && cond;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-4">
|
||||||
|
<ol className="grid grid-cols-3 gap-2" aria-label={t("stepOf", { step })}>
|
||||||
|
{stepLabels.map((label, i) => {
|
||||||
|
const n = (i + 1) as Step;
|
||||||
|
const state = n < step ? "done" : n === step ? "current" : "todo";
|
||||||
|
return (
|
||||||
|
<li key={label} aria-current={state === "current" ? "step" : undefined} className="flex flex-col items-center gap-1 text-center">
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
"flex size-9 items-center justify-center rounded-full border-2 font-heading text-[15px] font-semibold",
|
||||||
|
state === "done" && "border-primary bg-primary text-primary-foreground",
|
||||||
|
state === "current" && "border-cta text-foreground",
|
||||||
|
state === "todo" && "border-border text-muted-foreground",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{state === "done" ? <Check className="size-5" aria-hidden /> : n}
|
||||||
|
</span>
|
||||||
|
<span className={cn("text-[13px]", state === "current" ? "font-semibold" : "text-muted-foreground")}>{label}</span>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ol>
|
||||||
|
<p className="sr-only" aria-live="polite">
|
||||||
|
{t("stepOf", { step })}: {stepLabels[step - 1]}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{step === 1 && (
|
||||||
|
<section className={cn(card, "space-y-4")}>
|
||||||
|
<h2 className="text-[19px]">{t("steps.customer")}</h2>
|
||||||
|
<div className="grid grid-cols-2 gap-2" role="group" aria-label={t("steps.customer")}>
|
||||||
|
<button type="button" className={chip(customerMode === "existing")} aria-pressed={customerMode === "existing"} onClick={() => switchCustomerMode("existing")}>
|
||||||
|
<Search className="size-4.5" aria-hidden />
|
||||||
|
{t("customer.existing")}
|
||||||
|
</button>
|
||||||
|
<button type="button" className={chip(customerMode === "new")} aria-pressed={customerMode === "new"} onClick={() => switchCustomerMode("new")}>
|
||||||
|
<UserPlus className="size-4.5" aria-hidden />
|
||||||
|
{t("customer.new")}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{customerMode === "existing" &&
|
||||||
|
(selected ? (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="flex items-center gap-3 rounded-xl border border-primary p-3">
|
||||||
|
<Check className="size-5 shrink-0 text-primary" aria-hidden />
|
||||||
|
<div className="min-w-0 flex-1">
|
||||||
|
<p className="font-semibold">{selected.name}</p>
|
||||||
|
<p className="text-[14px] text-muted-foreground">
|
||||||
|
{[selected.customerNumber, selected.city].filter(Boolean).join(" · ")}
|
||||||
|
{selected.provisional && ` · ${t("customer.provisional")}`}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="button" className={btnSecondary} onClick={() => selectCustomer(null)}>
|
||||||
|
{t("customer.change")}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="space-y-3">
|
||||||
|
<div>
|
||||||
|
<label htmlFor="em-search" className="mb-1 block text-[14px] font-semibold">
|
||||||
|
{t("customer.search")}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="em-search"
|
||||||
|
type="search"
|
||||||
|
value={query}
|
||||||
|
onChange={(e) => onQueryChange(e.target.value)}
|
||||||
|
placeholder={t("customer.searchPlaceholder")}
|
||||||
|
autoComplete="off"
|
||||||
|
className={inputClass}
|
||||||
|
/>
|
||||||
|
<p className="mt-1 text-[13px] text-muted-foreground">{t("customer.searchHint")}</p>
|
||||||
|
</div>
|
||||||
|
{searching && (
|
||||||
|
<p role="status" className="flex items-center gap-2 text-[14px]">
|
||||||
|
<LoaderCircle className="size-4.5 animate-spin" aria-hidden />
|
||||||
|
{t("customer.searching")}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{searchFailed && <p className={noticeWarn}>{t("customer.offline")}</p>}
|
||||||
|
{!searching && query.trim().length >= 2 && hits.length === 0 && !searchFailed && (
|
||||||
|
<p className="text-[14px] text-muted-foreground">{t("customer.noHits")}</p>
|
||||||
|
)}
|
||||||
|
<ul className="space-y-2">
|
||||||
|
{hits.map((h) => (
|
||||||
|
<li key={h.id}>
|
||||||
|
<button type="button" onClick={() => selectCustomer(h)} className="flex min-h-14 w-full items-center gap-3 rounded-xl border bg-card px-3.5 py-2 text-left hover:bg-muted">
|
||||||
|
<Building2 className="size-5 shrink-0 text-muted-foreground" aria-hidden />
|
||||||
|
<span className="min-w-0 flex-1">
|
||||||
|
<span className="block font-semibold">{h.name}</span>
|
||||||
|
<span className="block text-[14px] text-muted-foreground">
|
||||||
|
{[h.customerNumber, h.city].filter(Boolean).join(" · ")}
|
||||||
|
{h.provisional && ` · ${t("customer.provisional")}`}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<ChevronRight className="size-5 text-muted-foreground" aria-hidden />
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
{err(!selected) && <p className={noticeError}>{t("customer.selectRequired")}</p>}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
|
||||||
|
{customerMode === "new" && (
|
||||||
|
<div className="space-y-3">
|
||||||
|
<p className={noticeWarn}>{t("customer.newHint")}</p>
|
||||||
|
<TextField id="em-company" label={t("customer.companyName")} value={newCustomer.companyName} onChange={(v) => setNewCustomer({ ...newCustomer, companyName: v })} autoComplete="organization" />
|
||||||
|
<div className="grid grid-cols-2 gap-2">
|
||||||
|
<TextField id="em-first" label={t("customer.firstName")} value={newCustomer.firstName} onChange={(v) => setNewCustomer({ ...newCustomer, firstName: v })} autoComplete="given-name" />
|
||||||
|
<TextField
|
||||||
|
id="em-last"
|
||||||
|
label={t("customer.lastName")}
|
||||||
|
value={newCustomer.lastName}
|
||||||
|
onChange={(v) => setNewCustomer({ ...newCustomer, lastName: v })}
|
||||||
|
autoComplete="family-name"
|
||||||
|
invalid={err(!newCustomer.companyName.trim() && !newCustomer.lastName.trim())}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<p className="text-[13px] text-muted-foreground">{t("customer.nameHint")}</p>
|
||||||
|
<TextField id="em-phone" label={t("customer.phone")} type="tel" inputMode="tel" autoComplete="tel" required value={newCustomer.phone} onChange={(v) => setNewCustomer({ ...newCustomer, phone: v })} invalid={err(!newCustomer.phone.trim())} />
|
||||||
|
<TextField id="em-email" label={t("customer.email")} type="email" inputMode="email" autoComplete="email" value={newCustomer.email} onChange={(v) => setNewCustomer({ ...newCustomer, email: v })} />
|
||||||
|
<div className="grid grid-cols-[1fr_5.5rem] gap-2">
|
||||||
|
<TextField id="em-street" label={t("customer.street")} value={newCustomer.street} onChange={(v) => setNewCustomer({ ...newCustomer, street: v })} autoComplete="address-line1" />
|
||||||
|
<TextField id="em-no" label={t("customer.houseNumber")} value={newCustomer.houseNumber} onChange={(v) => setNewCustomer({ ...newCustomer, houseNumber: v })} />
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-[6.5rem_1fr] gap-2">
|
||||||
|
<TextField id="em-zip" label={t("customer.postalCode")} inputMode="numeric" autoComplete="postal-code" value={newCustomer.postalCode} onChange={(v) => setNewCustomer({ ...newCustomer, postalCode: v })} />
|
||||||
|
<TextField id="em-city" label={t("customer.city")} value={newCustomer.city} onChange={(v) => setNewCustomer({ ...newCustomer, city: v })} autoComplete="address-level2" />
|
||||||
|
</div>
|
||||||
|
{err(!step1Valid) && <p className={noticeError}>{t("required")}</p>}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<button type="button" className={btnPrimary} onClick={() => go(2)}>
|
||||||
|
{t("next")}
|
||||||
|
<ChevronRight className="size-5" aria-hidden />
|
||||||
|
</button>
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{step === 2 && (
|
||||||
|
<section className={cn(card, "space-y-4")}>
|
||||||
|
<h2 className="text-[19px]">{t("steps.site")}</h2>
|
||||||
|
{customerMode === "existing" && sites === null && (
|
||||||
|
<p role="status" className="flex items-center gap-2 text-[14px]">
|
||||||
|
<LoaderCircle className="size-4.5 animate-spin" aria-hidden />
|
||||||
|
{t("site.loading")}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{customerMode === "existing" && sites !== null && sites.length > 0 && (
|
||||||
|
<fieldset className="space-y-2">
|
||||||
|
<legend className="mb-1 text-[14px] font-semibold">{t("site.existing")}</legend>
|
||||||
|
{sites.map((s) => (
|
||||||
|
<label key={s.id} className={cn("flex min-h-14 cursor-pointer items-center gap-3 rounded-xl border px-3.5 py-2", siteMode === "existing" && siteId === s.id ? "border-primary" : "border-border")}>
|
||||||
|
<input type="radio" name="em-site" className="size-5 accent-[var(--ui-primary)]" checked={siteMode === "existing" && siteId === s.id} onChange={() => { setSiteMode("existing"); setSiteId(s.id); }} />
|
||||||
|
<span className="min-w-0 flex-1">
|
||||||
|
<span className="block font-semibold">{s.name}</span>
|
||||||
|
<span className="block text-[14px] text-muted-foreground">{s.address}</span>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
))}
|
||||||
|
<label className={cn("flex min-h-14 cursor-pointer items-center gap-3 rounded-xl border px-3.5 py-2", siteMode === "new" ? "border-primary" : "border-border")}>
|
||||||
|
<input type="radio" name="em-site" className="size-5 accent-[var(--ui-primary)]" checked={siteMode === "new"} onChange={() => setSiteMode("new")} />
|
||||||
|
<MapPin className="size-5 text-muted-foreground" aria-hidden />
|
||||||
|
<span className="font-semibold">{t("site.newAddress")}</span>
|
||||||
|
</label>
|
||||||
|
</fieldset>
|
||||||
|
)}
|
||||||
|
{customerMode === "existing" && sites !== null && sites.length === 0 && <p className="text-[14px] text-muted-foreground">{t("site.none")}</p>}
|
||||||
|
|
||||||
|
{siteMode === "new" && (sites !== null || customerMode === "new") && (
|
||||||
|
<div className="space-y-3">
|
||||||
|
<p className="text-[13px] text-muted-foreground">{t("site.newHint")}</p>
|
||||||
|
{customerMode === "new" && (newCustomer.street || newCustomer.city) && (
|
||||||
|
<button type="button" className={btnSecondary} onClick={useCustomerAddress}>
|
||||||
|
<MapPin className="size-5" aria-hidden />
|
||||||
|
{t("site.useCustomerAddress")}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
<div className="grid grid-cols-[1fr_5.5rem] gap-2">
|
||||||
|
<TextField id="em-s-street" label={t("customer.street")} required value={address.street} onChange={(v) => setAddress({ ...address, street: v })} autoComplete="address-line1" invalid={err(!address.street.trim())} />
|
||||||
|
<TextField id="em-s-no" label={t("customer.houseNumber")} value={address.houseNumber} onChange={(v) => setAddress({ ...address, houseNumber: v })} />
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-[6.5rem_1fr] gap-2">
|
||||||
|
<TextField id="em-s-zip" label={t("customer.postalCode")} inputMode="numeric" autoComplete="postal-code" value={address.postalCode} onChange={(v) => setAddress({ ...address, postalCode: v })} />
|
||||||
|
<TextField id="em-s-city" label={t("customer.city")} required value={address.city} onChange={(v) => setAddress({ ...address, city: v })} autoComplete="address-level2" invalid={err(!address.city.trim())} />
|
||||||
|
</div>
|
||||||
|
<TextField id="em-s-name" label={t("site.name")} value={address.name} onChange={(v) => setAddress({ ...address, name: v })} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<fieldset className="space-y-3">
|
||||||
|
<legend className="text-[16px] font-semibold">{t("site.contactTitle")}</legend>
|
||||||
|
<TextField id="em-c-name" label={t("site.contactName")} required value={contact.name} onChange={(v) => setContact({ ...contact, name: v })} autoComplete="name" invalid={err(!contact.name.trim())} />
|
||||||
|
<TextField id="em-c-phone" label={t("site.contactPhone")} type="tel" inputMode="tel" autoComplete="tel" required value={contact.phone} onChange={(v) => setContact({ ...contact, phone: v })} invalid={err(!contact.phone.trim())} />
|
||||||
|
</fieldset>
|
||||||
|
{err(!step2Valid) && <p className={noticeError}>{t("required")}</p>}
|
||||||
|
|
||||||
|
<div className="grid grid-cols-2 gap-2">
|
||||||
|
<button type="button" className={btnSecondary} onClick={() => go(1)}>
|
||||||
|
<ChevronLeft className="size-5" aria-hidden />
|
||||||
|
{t("back")}
|
||||||
|
</button>
|
||||||
|
<button type="button" className={cn(btnPrimary, "min-h-12")} onClick={() => go(3)}>
|
||||||
|
{t("next")}
|
||||||
|
<ChevronRight className="size-5" aria-hidden />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{step === 3 && (
|
||||||
|
<section className={cn(card, "space-y-4")}>
|
||||||
|
<h2 className="text-[19px]">{t("steps.reason")}</h2>
|
||||||
|
<div>
|
||||||
|
<label htmlFor="em-reason" className="mb-1 block text-[14px] font-semibold">
|
||||||
|
{t("reason.label")}
|
||||||
|
<span aria-hidden> *</span>
|
||||||
|
</label>
|
||||||
|
<textarea
|
||||||
|
id="em-reason"
|
||||||
|
value={reason}
|
||||||
|
onChange={(e) => setReason(e.target.value)}
|
||||||
|
required
|
||||||
|
rows={4}
|
||||||
|
maxLength={2000}
|
||||||
|
placeholder={t("reason.placeholder")}
|
||||||
|
aria-invalid={err(!reason.trim()) || undefined}
|
||||||
|
className={cn(inputClass, "py-3", err(!reason.trim()) && "border-[var(--risk)]")}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<p className="text-[14px] font-semibold">{t("reason.voice")}</p>
|
||||||
|
{recState === "idle" && (
|
||||||
|
<button type="button" className={btnSecondary} onClick={startRecording}>
|
||||||
|
<Mic className="size-5" aria-hidden />
|
||||||
|
{t("reason.voiceRecord")}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
{recState === "recording" && (
|
||||||
|
<>
|
||||||
|
<p role="status" aria-live="polite" className="flex items-center gap-2 text-[15px] font-semibold text-[var(--risk)]">
|
||||||
|
<span className="size-3 animate-pulse rounded-full bg-[var(--risk)]" aria-hidden />
|
||||||
|
{t("reason.voiceRecording", { seconds: recSeconds })}
|
||||||
|
</p>
|
||||||
|
<button type="button" className={btnSecondary} onClick={stopRecording}>
|
||||||
|
<Square className="size-5" aria-hidden />
|
||||||
|
{t("reason.voiceStop")}
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{recState === "recorded" && clip && (
|
||||||
|
<>
|
||||||
|
<audio controls src={clip.url} className="w-full" />
|
||||||
|
<button type="button" className={btnSecondary} onClick={() => { setClip(null); setRecState("idle"); }}>
|
||||||
|
{t("reason.voiceDiscard")}
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
<p className="text-[13px] text-muted-foreground">{t("reason.voiceHint")}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label htmlFor="em-start" className="mb-1 block text-[14px] font-semibold">
|
||||||
|
{t("reason.startedAt")}
|
||||||
|
<span aria-hidden> *</span>
|
||||||
|
</label>
|
||||||
|
<input id="em-start" type="datetime-local" value={startedAt} onChange={(e) => setStartedAt(e.target.value)} required className={inputClass} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label htmlFor="em-team" className="mb-1 block text-[14px] font-semibold">
|
||||||
|
{t("reason.team")}
|
||||||
|
</label>
|
||||||
|
<select id="em-team" value={teamId} onChange={(e) => { setTeamId(e.target.value); setColleagues([]); }} className={inputClass}>
|
||||||
|
{teams.map((x) => (
|
||||||
|
<option key={x.id} value={x.id}>
|
||||||
|
{x.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
<option value="">{t("reason.noTeam")}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<fieldset className="space-y-2">
|
||||||
|
<legend className="mb-1 flex items-center gap-2 text-[14px] font-semibold">
|
||||||
|
<Users className="size-4.5" aria-hidden />
|
||||||
|
{t("reason.technicians")}
|
||||||
|
</legend>
|
||||||
|
<label className="flex min-h-12 items-center gap-3 text-[15px]">
|
||||||
|
<input type="checkbox" checked disabled className="size-5 accent-[var(--ui-primary)]" />
|
||||||
|
{t("reason.me")}
|
||||||
|
</label>
|
||||||
|
{team?.members
|
||||||
|
.filter((m) => m.id !== userId)
|
||||||
|
.map((m) => (
|
||||||
|
<label key={m.id} className="flex min-h-12 cursor-pointer items-center gap-3 text-[15px]">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
className="size-5 accent-[var(--ui-primary)]"
|
||||||
|
checked={colleagues.includes(m.id)}
|
||||||
|
onChange={(e) => setColleagues(e.target.checked ? [...colleagues, m.id] : colleagues.filter((c) => c !== m.id))}
|
||||||
|
/>
|
||||||
|
{m.name}
|
||||||
|
</label>
|
||||||
|
))}
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
{err(!step3Valid) && <p className={noticeError}>{t("required")}</p>}
|
||||||
|
{error && (
|
||||||
|
<p className={noticeError} role="alert">
|
||||||
|
<TriangleAlert className="mt-0.5 size-4.5 shrink-0" aria-hidden />
|
||||||
|
{error}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<button type="button" className={btnPrimary} onClick={submit} disabled={submitting || recState === "recording"}>
|
||||||
|
{submitting ? <LoaderCircle className="size-5 animate-spin" aria-hidden /> : <Siren className="size-5" aria-hidden />}
|
||||||
|
{submitting ? t("starting") : t("start")}
|
||||||
|
</button>
|
||||||
|
<button type="button" className={btnSecondary} onClick={() => go(2)} disabled={submitting}>
|
||||||
|
<ChevronLeft className="size-5" aria-hidden />
|
||||||
|
{t("back")}
|
||||||
|
</button>
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { moduleGuard } from "@/server/action-guard";
|
||||||
|
import { toActionError } from "@/server/api/action-state";
|
||||||
|
import { ctxFromGuard } from "@/server/services/context";
|
||||||
|
import {
|
||||||
|
listSitesForEmergency,
|
||||||
|
searchCustomersForEmergency,
|
||||||
|
type EmergencyCustomerHit,
|
||||||
|
type EmergencySiteHit,
|
||||||
|
} from "@/server/services/emergency/lookup";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read lookups of the mobile emergency capture. They are server actions (not page reads) because
|
||||||
|
* the client wizard calls them interactively; both are audited in the service. The create itself
|
||||||
|
* goes through the sync op `emergency.create` (offline-capable, POST /api/v1/sync).
|
||||||
|
*/
|
||||||
|
const guard = moduleGuard("emergency");
|
||||||
|
|
||||||
|
export type LookupResult<T> = { ok: true; items: T[] } | { ok: false; code: string };
|
||||||
|
|
||||||
|
export async function searchEmergencyCustomersAction(query: string): Promise<LookupResult<EmergencyCustomerHit>> {
|
||||||
|
try {
|
||||||
|
const ctx = ctxFromGuard(await guard("emergency:create"));
|
||||||
|
return { ok: true, items: await searchCustomersForEmergency(ctx, String(query ?? "")) };
|
||||||
|
} catch (err) {
|
||||||
|
return { ok: false, code: toActionError(err).code };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function listEmergencySitesAction(customerId: string): Promise<LookupResult<EmergencySiteHit>> {
|
||||||
|
try {
|
||||||
|
const ctx = ctxFromGuard(await guard("emergency:create"));
|
||||||
|
return { ok: true, items: await listSitesForEmergency(ctx, String(customerId ?? "")) };
|
||||||
|
} catch (err) {
|
||||||
|
return { ok: false, code: toActionError(err).code };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { revalidatePath } from "next/cache";
|
||||||
|
import { moduleGuard } from "@/server/action-guard";
|
||||||
|
import { formObject, toActionError, type ActionState } from "@/server/api/action-state";
|
||||||
|
import { ctxFromGuard, type ServiceCtx } from "@/server/services/context";
|
||||||
|
import {
|
||||||
|
assignEmergencySite,
|
||||||
|
assignEmergencyToCustomer,
|
||||||
|
completeEmergencyOrderData,
|
||||||
|
confirmEmergencyCustomer,
|
||||||
|
correctEmergencySite,
|
||||||
|
mergeEmergencyCustomer,
|
||||||
|
releaseEmergencyForBilling,
|
||||||
|
} from "@/server/services/emergency/review";
|
||||||
|
|
||||||
|
/** Backoffice review of emergency call-outs (/work-orders/emergency-review/[id]). */
|
||||||
|
const guard = moduleGuard("emergency");
|
||||||
|
|
||||||
|
function done(workOrderId: string): ActionState {
|
||||||
|
revalidatePath("/work-orders/emergency-review");
|
||||||
|
revalidatePath(`/work-orders/emergency-review/${workOrderId}`);
|
||||||
|
revalidatePath(`/work-orders/${workOrderId}`);
|
||||||
|
return { status: "ok" };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function run(workOrderId: string, fn: () => Promise<unknown>): Promise<ActionState> {
|
||||||
|
try {
|
||||||
|
await fn();
|
||||||
|
} catch (err) {
|
||||||
|
return toActionError(err);
|
||||||
|
}
|
||||||
|
return done(workOrderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
const version = (fd: FormData) => {
|
||||||
|
const v = Number(fd.get("baseVersion"));
|
||||||
|
return Number.isInteger(v) && v > 0 ? v : undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function confirmCustomerAction(workOrderId: string): Promise<ActionState> {
|
||||||
|
let ctx: ServiceCtx;
|
||||||
|
try {
|
||||||
|
ctx = ctxFromGuard(await guard("emergency:review", "customer:write"));
|
||||||
|
} catch (err) {
|
||||||
|
return toActionError(err);
|
||||||
|
}
|
||||||
|
return run(workOrderId, () => confirmEmergencyCustomer(ctx, workOrderId));
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function assignCustomerAction(workOrderId: string, _prev: ActionState, fd: FormData): Promise<ActionState> {
|
||||||
|
let ctx: ServiceCtx;
|
||||||
|
try {
|
||||||
|
ctx = ctxFromGuard(await guard("emergency:review", "customer:write", "work_order:write"));
|
||||||
|
} catch (err) {
|
||||||
|
return toActionError(err);
|
||||||
|
}
|
||||||
|
return run(workOrderId, async () => assignEmergencyToCustomer(ctx, { workOrderId, targetCustomerId: await targetCustomer(ctx, fd) }));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Target from the candidate select or, as a fallback, from an entered customer number (tenant-bound lookup). */
|
||||||
|
async function targetCustomer(ctx: ServiceCtx, fd: FormData): Promise<string> {
|
||||||
|
const id = String(fd.get("targetCustomerId") ?? "").trim();
|
||||||
|
if (id) return id;
|
||||||
|
const customerNumber = String(fd.get("targetCustomerNumber") ?? "").trim();
|
||||||
|
if (!customerNumber) return "";
|
||||||
|
const c = await ctx.db.customer.findFirst({ where: { customerNumber, deletedAt: null }, select: { id: true } });
|
||||||
|
return c?.id ?? "__unknown__";
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function mergeCustomerAction(workOrderId: string, _prev: ActionState, fd: FormData): Promise<ActionState> {
|
||||||
|
let ctx: ServiceCtx;
|
||||||
|
try {
|
||||||
|
ctx = ctxFromGuard(await guard("emergency:review", "customer:merge"));
|
||||||
|
} catch (err) {
|
||||||
|
return toActionError(err);
|
||||||
|
}
|
||||||
|
const confirm = fd.get("confirm") === "on" || fd.get("confirm") === "1";
|
||||||
|
return run(workOrderId, async () => mergeEmergencyCustomer(ctx, { workOrderId, targetCustomerId: await targetCustomer(ctx, fd), confirm }));
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function correctSiteAction(workOrderId: string, _prev: ActionState, fd: FormData): Promise<ActionState> {
|
||||||
|
let ctx: ServiceCtx;
|
||||||
|
try {
|
||||||
|
ctx = ctxFromGuard(await guard("emergency:review", "site:write"));
|
||||||
|
} catch (err) {
|
||||||
|
return toActionError(err);
|
||||||
|
}
|
||||||
|
const values = formObject(fd, ["name", "street", "houseNumber", "postalCode", "city", "onSiteContact", "phone", "accessNotes"]);
|
||||||
|
const patch = { ...values, name: values.name ?? undefined };
|
||||||
|
const confirm = fd.get("confirm") === "on" || fd.get("confirm") === "1";
|
||||||
|
return run(workOrderId, () => correctEmergencySite(ctx, { workOrderId, patch, confirm }));
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function assignSiteAction(workOrderId: string, _prev: ActionState, fd: FormData): Promise<ActionState> {
|
||||||
|
let ctx: ServiceCtx;
|
||||||
|
try {
|
||||||
|
ctx = ctxFromGuard(await guard("emergency:review", "work_order:write"));
|
||||||
|
} catch (err) {
|
||||||
|
return toActionError(err);
|
||||||
|
}
|
||||||
|
const siteId = String(fd.get("siteId") ?? "");
|
||||||
|
return run(workOrderId, () => assignEmergencySite(ctx, { workOrderId, siteId }));
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function completeOrderAction(workOrderId: string, _prev: ActionState, fd: FormData): Promise<ActionState> {
|
||||||
|
let ctx: ServiceCtx;
|
||||||
|
try {
|
||||||
|
ctx = ctxFromGuard(await guard("emergency:review", "work_order:write"));
|
||||||
|
} catch (err) {
|
||||||
|
return toActionError(err);
|
||||||
|
}
|
||||||
|
const values = formObject(fd, ["title", "description", "orderTypeId", "billingType"]);
|
||||||
|
return run(workOrderId, () => completeEmergencyOrderData(ctx, { workOrderId, ...values, baseVersion: version(fd) }));
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function releaseBillingAction(workOrderId: string, _prev: ActionState, fd: FormData): Promise<ActionState> {
|
||||||
|
let ctx: ServiceCtx;
|
||||||
|
try {
|
||||||
|
ctx = ctxFromGuard(await guard("emergency:review", "work_order:release_billing"));
|
||||||
|
} catch (err) {
|
||||||
|
return toActionError(err);
|
||||||
|
}
|
||||||
|
return run(workOrderId, () => releaseEmergencyForBilling(ctx, { workOrderId, baseVersion: version(fd) }));
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user