mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 01:44:13 +00:00
3678761a2d
* 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)
31 lines
1.2 KiB
TypeScript
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 });
|
|
}),
|
|
];
|