feat: Equipment-System, Buchungsbearbeitung, Kundenadresse, LexOffice-Fix

- Vintage Modell hinzugefuegt
- Equipment Multi-Select (Neue Buchung + Bearbeitung)
- Kundenadresse in Formularen
- Bearbeiten-Seite fuer Buchungen
- Abbau-Zeiten in Formularen und Uebersicht
- Vertrag PDF nur bei Privatkunden
- LexOffice Kontakt-Erstellung Fix (BUSINESS)
- Zurueck-Pfeil auf Touren-Seite
This commit is contained in:
Julia Wehden
2026-03-19 16:21:55 +01:00
parent 0b6e429329
commit a2c95c70e7
79 changed files with 7396 additions and 538 deletions

View File

@@ -0,0 +1,76 @@
import { NextRequest, NextResponse } from 'next/server';
import { getServerSession } from 'next-auth';
import { authOptions } from '@/lib/auth';
import { prisma } from '@/lib/prisma';
export async function PATCH(
request: NextRequest,
{ params }: { params: { id: string } }
) {
try {
const session = await getServerSession(authOptions);
if (!session || session.user.role !== 'DRIVER') {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const body = await request.json();
const { status } = body;
if (!status) {
return NextResponse.json({ error: 'Status is required' }, { status: 400 });
}
const tourStop = await prisma.tourStop.findUnique({
where: { id: params.id },
include: {
tour: {
select: {
driverId: true,
},
},
},
});
if (!tourStop) {
return NextResponse.json({ error: 'Tour stop not found' }, { status: 404 });
}
if (tourStop.tour.driverId !== session.user.id) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 403 });
}
const updateData: any = { status };
switch (status) {
case 'ARRIVED':
updateData.arrivedAt = new Date();
break;
case 'SETUP_IN_PROGRESS':
updateData.setupStartedAt = new Date();
break;
case 'SETUP_COMPLETE':
updateData.setupCompleteAt = new Date();
break;
case 'PICKUP_IN_PROGRESS':
updateData.pickupStartedAt = new Date();
break;
case 'PICKUP_COMPLETE':
updateData.pickupCompleteAt = new Date();
break;
}
const updatedStop = await prisma.tourStop.update({
where: { id: params.id },
data: updateData,
});
return NextResponse.json({ tourStop: updatedStop });
} catch (error: any) {
console.error('Status update error:', error);
return NextResponse.json(
{ error: error.message || 'Failed to update status' },
{ status: 500 }
);
}
}

View File

@@ -0,0 +1,62 @@
import { NextRequest, NextResponse } from 'next/server';
import { getServerSession } from 'next-auth';
import { authOptions } from '@/lib/auth';
import { prisma } from '@/lib/prisma';
export async function GET(
request: NextRequest,
{ params }: { params: { id: string } }
) {
try {
const session = await getServerSession(authOptions);
if (!session || session.user.role !== 'DRIVER') {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const tour = await prisma.tour.findUnique({
where: {
id: params.id,
driverId: session.user.id,
},
include: {
tourStops: {
include: {
booking: {
include: {
photobox: {
select: {
model: true,
serialNumber: true,
},
},
},
},
photos: {
select: {
id: true,
photoType: true,
fileName: true,
},
},
},
orderBy: {
stopOrder: 'asc',
},
},
},
});
if (!tour) {
return NextResponse.json({ error: 'Tour not found' }, { status: 404 });
}
return NextResponse.json({ tour });
} catch (error: any) {
console.error('Tour fetch error:', error);
return NextResponse.json(
{ error: error.message || 'Failed to fetch tour' },
{ status: 500 }
);
}
}