Files
TREK/client/tests/helpers/msw/handlers/places.ts
T
Maurice 3678761a2d feat(places): custom place image (#1136) (#1641)
* feat(places): upload a custom place image on the server (#1136)

* i18n(places): custom place image labels

* feat(places): click a place thumbnail to set a custom image

* feat(places): custom place image on mobile place and collection sheets

* test(places): cover custom place and collection image upload

* docs(places): document custom place images

* fix(places): carry osm_id on the embedded place so day-plan thumbnails auto-fetch (#1136)

* feat(places): custom tooltip on the place image controls

* fix(places): show a custom place image on map markers, skip the redundant photo fetch (#1136)
2026-07-21 15:33:31 +02:00

31 lines
1.2 KiB
TypeScript

import { http, HttpResponse } from 'msw';
import { buildPlace } from '../../factories';
export const placesHandlers = [
http.get('/api/trips/:id/places', ({ params }) => {
const tripId = Number(params.id);
return HttpResponse.json({ places: [buildPlace({ trip_id: tripId }), buildPlace({ trip_id: tripId })] });
}),
http.post('/api/trips/:id/places', async ({ params, request }) => {
const body = await request.json() as Record<string, unknown>;
const place = buildPlace({ trip_id: Number(params.id), ...body });
return HttpResponse.json({ place });
}),
http.put('/api/trips/:id/places/:placeId', async ({ params, request }) => {
const body = await request.json() as Record<string, unknown>;
const place = buildPlace({ id: Number(params.placeId), trip_id: Number(params.id), ...body });
return HttpResponse.json({ place });
}),
http.post('/api/trips/:id/places/:placeId/image', ({ params }) => {
const place = buildPlace({ id: Number(params.placeId), trip_id: Number(params.id), image_url: '/uploads/places/mock.jpg' });
return HttpResponse.json({ place });
}),
http.delete('/api/trips/:id/places/:placeId', () => {
return HttpResponse.json({ success: true });
}),
];