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:
62
app/api/driver/tours/[id]/route.ts
Normal file
62
app/api/driver/tours/[id]/route.ts
Normal 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 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user