Files
TREK/server/src/nest/tours/tour-drafts.controller.ts
T
Maurice 31859651d7 feat(help): rewrite the help center for v5 with a Tours section, new pictures in every language, and fix the tour planner bugs it surfaced
Every help screen checked against the v5 redesign. Tours is documented for
the first time, as a screen of its own with twelve screens under it, and
notifications get help of their own. All pictures are taken again on a
realistic demo trip, with short loops where a still cannot show the motion.
The English is plain and every language is written naturally rather than
word for word.

The switcher shows two levels at most, a screen's overview lists its
sub-screens as cards above its guides, each wiki page is linked once, and
the help sidebar is wider.

Fixes found along the way: Save to Collection keeps a tour's route, a track
dropped on the places column opens the Tours import, tour Share on desktop,
the unsaved tour draft lives on the account, a route click no longer adds
an end point, Trip places leaves the trip's tours out, Escape closes a
stage's day menu, confirms before destructive deletes, DWD warnings sharing
one id kept apart, a booking's date moves with it, and smaller fixes across
notifications, bookings, the day plan, stays, Atlas, Collections, Vacay and
the admin screens.
2026-10-22 22:29:35 +02:00

45 lines
2.0 KiB
TypeScript

import { ADDON_IDS } from '../../addons';
import type { User } from '../../types';
import { AddonGuard } from '../addons/addon.guard';
import { RequireAddon } from '../addons/require-addon.decorator';
import { CurrentUser } from '../auth-core/current-user.decorator';
import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';
import { ResponseContract } from '../common/response-contract';
import { RequirePermission, TripAccessGuard } from '../permissions/trip-access.guard';
import { TourDraftPutDto } from './dto/tour-draft.dto';
import { TourDraftsService } from './tour-drafts.service';
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Put, UseGuards } from '@nestjs/common';
import { successResponseSchema, tourDraftResponseSchema } from '@trek/shared';
/**
* /api/trips/:tripId/tour-draft: the caller's own unsaved draft of the Tours
* planner in this trip. Reading it and letting it go need the trip; keeping
* one needs 'place_edit', as saving the tour it becomes does. Every route
* names the signed-in user, so a traveller only ever reaches their own draft.
*/
@Controller('api/trips/:tripId/tour-draft')
@UseGuards(AddonGuard, JwtAuthGuard, TripAccessGuard)
@RequireAddon(ADDON_IDS.TOURS, 'Tours')
export class TourDraftsController {
constructor(private readonly drafts: TourDraftsService) {}
@Get()
@ResponseContract(tourDraftResponseSchema)
async read(@CurrentUser() user: User, @Param('tripId', ParseIntPipe) tripId: number) {
return await this.drafts.read(tripId, user.id);
}
@RequirePermission('place_edit')
@Put()
@ResponseContract(tourDraftResponseSchema)
async keep(@CurrentUser() user: User, @Param('tripId', ParseIntPipe) tripId: number, @Body() body: TourDraftPutDto) {
return await this.drafts.keep(tripId, user.id, body);
}
@Delete()
@ResponseContract(successResponseSchema)
async forget(@CurrentUser() user: User, @Param('tripId', ParseIntPipe) tripId: number) {
return await this.drafts.forget(tripId, user.id);
}
}