forked from fahrPool/fahrPool
fix: fahrtBeginnen lehnt erneutes Absenden ausserhalb des Status zugewiesen ab
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
906b822250
commit
6e4b784bf9
|
|
@ -64,6 +64,11 @@ export async function fahrtBeginnen(auftragId: string, formData: FormData): Prom
|
||||||
}
|
}
|
||||||
|
|
||||||
const auftragFuerFin = await loadAuftrag(auftragId);
|
const auftragFuerFin = await loadAuftrag(auftragId);
|
||||||
|
// Frueh abbrechen (vor FIN-RPC und Foto-Uploads), falls ein erster Versuch
|
||||||
|
// schon angekommen ist, z.B. nach Netzausfall und erneutem Absenden.
|
||||||
|
if (!auftragFuerFin || auftragFuerFin.status !== "zugewiesen") {
|
||||||
|
redirect(`/auftraege/${auftragId}?error=${encodeURIComponent("Fahrt konnte nicht begonnen werden (keine Berechtigung oder Auftrag nicht mehr im Status zugewiesen).")}`);
|
||||||
|
}
|
||||||
// Ist die Abweichung schon vermerkt (sticky, siehe RPC), wird nicht erneut
|
// Ist die Abweichung schon vermerkt (sticky, siehe RPC), wird nicht erneut
|
||||||
// geprueft; der Disponent klaert das.
|
// geprueft; der Disponent klaert das.
|
||||||
const finBereitsAbweichend = auftragFuerFin?.start_fin_status === "abweichend";
|
const finBereitsAbweichend = auftragFuerFin?.start_fin_status === "abweichend";
|
||||||
|
|
@ -155,6 +160,7 @@ export async function fahrtBeginnen(auftragId: string, formData: FormData): Prom
|
||||||
.from("auftraege")
|
.from("auftraege")
|
||||||
.update({ status: "unterwegs", start_km: validation.startKm })
|
.update({ status: "unterwegs", start_km: validation.startKm })
|
||||||
.eq("id", auftragId)
|
.eq("id", auftragId)
|
||||||
|
.eq("status", "zugewiesen")
|
||||||
.select("id");
|
.select("id");
|
||||||
|
|
||||||
if (error || !data || data.length === 0) {
|
if (error || !data || data.length === 0) {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import { useState, useTransition } from "react";
|
import { useState, useTransition } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { kommen, gehen } from "@/app/zeiterfassung/actions";
|
import { kommen, gehen, type MutationResult } from "@/app/zeiterfassung/actions";
|
||||||
import { Button } from "@/components/ui/Button";
|
import { Button } from "@/components/ui/Button";
|
||||||
import { Alert } from "@/components/ui/Alert";
|
import { Alert } from "@/components/ui/Alert";
|
||||||
import { istNetzwerkFehler, NETZ_FEHLER_TEXT } from "@/lib/pwa/netzwerk-fehler";
|
import { istNetzwerkFehler, NETZ_FEHLER_TEXT } from "@/lib/pwa/netzwerk-fehler";
|
||||||
|
|
@ -14,7 +14,7 @@ export function KommenGehenButton({ offeneSchichtId }: { offeneSchichtId: string
|
||||||
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
startTransition(async () => {
|
startTransition(async () => {
|
||||||
let ergebnis;
|
let ergebnis: MutationResult;
|
||||||
try {
|
try {
|
||||||
ergebnis = offeneSchichtId ? await gehen(offeneSchichtId) : await kommen();
|
ergebnis = offeneSchichtId ? await gehen(offeneSchichtId) : await kommen();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import { useState, useTransition } from "react";
|
import { useState, useTransition } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { schichtKorrigieren } from "@/app/zeiterfassung/actions";
|
import { schichtKorrigieren, type MutationResult } from "@/app/zeiterfassung/actions";
|
||||||
import { Button } from "@/components/ui/Button";
|
import { Button } from "@/components/ui/Button";
|
||||||
import { Alert } from "@/components/ui/Alert";
|
import { Alert } from "@/components/ui/Alert";
|
||||||
import { istNetzwerkFehler, NETZ_FEHLER_TEXT } from "@/lib/pwa/netzwerk-fehler";
|
import { istNetzwerkFehler, NETZ_FEHLER_TEXT } from "@/lib/pwa/netzwerk-fehler";
|
||||||
|
|
@ -17,7 +17,7 @@ export function KorrekturFormular({ schichtId }: { schichtId: string }) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const formData = new FormData(event.currentTarget);
|
const formData = new FormData(event.currentTarget);
|
||||||
startTransition(async () => {
|
startTransition(async () => {
|
||||||
let ergebnis;
|
let ergebnis: MutationResult;
|
||||||
try {
|
try {
|
||||||
ergebnis = await schichtKorrigieren(schichtId, formData);
|
ergebnis = await schichtKorrigieren(schichtId, formData);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue