mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-24 16:03:02 +00:00
2d0c0597b3
A ski tour with a discipline now sends its legs to the piste router and takes back runs, lifts and trails: each stretch is coloured by its grade in the area's scheme, links and lift rides down are dotted, and a leg the router cannot plan stays straight and unrouted with its reason and the one change that would plan it. Snowshoe and winter hike legs off the piste data follow summer paths instead, said so. The router's time and heights are used once every leg is planned, and the options, the build and the time are saved with the tour. - skiRouteRepo and api: one request per tour, batched, remembered unless the answer may change, offline legs failed as offline - planner: router options per discipline, leg steps and failure rows with fixes, a piste route summary, draft and reopen keep the options - admin: switch for the piste router under Tours - i18n: new ski keys in all 27 locales, ski info and time texts rewritten
165 lines
4.8 KiB
TypeScript
165 lines
4.8 KiB
TypeScript
import { http, HttpResponse } from 'msw';
|
|
import { buildUser, buildAdmin } from '../../factories';
|
|
|
|
export const adminHandlers = [
|
|
http.get('/api/admin/users', () => {
|
|
const user1 = buildUser({ username: 'alice', email: 'alice@example.com' });
|
|
const admin1 = buildAdmin({ username: 'admin', email: 'admin@example.com' });
|
|
return HttpResponse.json({ users: [admin1, user1] });
|
|
}),
|
|
|
|
http.post('/api/admin/users', async ({ request }) => {
|
|
const body = await request.json() as Record<string, unknown>;
|
|
const user = buildUser({ ...body });
|
|
return HttpResponse.json({ user });
|
|
}),
|
|
|
|
http.put('/api/admin/users/:id', async ({ params, request }) => {
|
|
const body = await request.json() as Record<string, unknown>;
|
|
const user = buildUser({ id: Number(params.id), ...body });
|
|
return HttpResponse.json({ user });
|
|
}),
|
|
|
|
http.delete('/api/admin/users/:id', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.get('/api/admin/stats', () => {
|
|
return HttpResponse.json({
|
|
totalUsers: 2,
|
|
totalTrips: 5,
|
|
totalPlaces: 42,
|
|
totalFiles: 8,
|
|
});
|
|
}),
|
|
|
|
http.get('/api/admin/invites', () => {
|
|
return HttpResponse.json({ invites: [] });
|
|
}),
|
|
|
|
http.post('/api/admin/invites', async ({ request }) => {
|
|
const body = await request.json() as Record<string, unknown>;
|
|
return HttpResponse.json({ invite: { id: 1, token: 'test-invite-token', ...body } });
|
|
}),
|
|
|
|
http.delete('/api/admin/invites/:id', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.get('/api/admin/oidc', () => {
|
|
return HttpResponse.json({
|
|
issuer: '',
|
|
client_id: '',
|
|
client_secret: '',
|
|
client_secret_set: false,
|
|
display_name: '',
|
|
oidc_only: false,
|
|
discovery_url: '',
|
|
});
|
|
}),
|
|
|
|
http.put('/api/admin/oidc', async ({ request }) => {
|
|
const body = await request.json() as Record<string, unknown>;
|
|
return HttpResponse.json({ ...body });
|
|
}),
|
|
|
|
http.get('/api/admin/version-check', () => {
|
|
return HttpResponse.json({ update_available: false, latest: '1.0.0', current: '1.0.0' });
|
|
}),
|
|
|
|
http.get('/api/admin/bag-tracking', () => {
|
|
return HttpResponse.json({ enabled: false });
|
|
}),
|
|
|
|
http.put('/api/admin/bag-tracking', async ({ request }) => {
|
|
const body = await request.json() as Record<string, unknown>;
|
|
return HttpResponse.json({ enabled: body.enabled });
|
|
}),
|
|
|
|
http.get('/api/admin/tours-wanderer', () => {
|
|
return HttpResponse.json({ enabled: false });
|
|
}),
|
|
|
|
http.put('/api/admin/tours-wanderer', async ({ request }) => {
|
|
const body = await request.json() as Record<string, unknown>;
|
|
return HttpResponse.json({ enabled: body.enabled });
|
|
}),
|
|
|
|
http.get('/api/admin/tours-hiking-map', () => {
|
|
return HttpResponse.json({ enabled: true });
|
|
}),
|
|
|
|
http.put('/api/admin/tours-hiking-map', async ({ request }) => {
|
|
const body = await request.json() as Record<string, unknown>;
|
|
return HttpResponse.json({ enabled: body.enabled });
|
|
}),
|
|
|
|
http.get('/api/admin/tours-ski-routing', () => {
|
|
return HttpResponse.json({ enabled: true });
|
|
}),
|
|
|
|
http.put('/api/admin/tours-ski-routing', async ({ request }) => {
|
|
const body = await request.json() as Record<string, unknown>;
|
|
return HttpResponse.json({ enabled: body.enabled });
|
|
}),
|
|
|
|
http.get('/api/admin/addons', () => {
|
|
return HttpResponse.json({ addons: [] });
|
|
}),
|
|
|
|
http.get('/api/admin/packing-templates', () => {
|
|
return HttpResponse.json({ templates: [] });
|
|
}),
|
|
|
|
http.get('/api/admin/audit-log', () => {
|
|
return HttpResponse.json({ logs: [], total: 0 });
|
|
}),
|
|
|
|
http.get('/api/admin/mcp-tokens', () => {
|
|
return HttpResponse.json({ tokens: [] });
|
|
}),
|
|
|
|
http.get('/api/admin/oauth-sessions', () => {
|
|
return HttpResponse.json({ sessions: [] });
|
|
}),
|
|
|
|
http.delete('/api/admin/oauth-sessions/:id', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.delete('/api/admin/mcp-tokens/:id', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.get('/api/admin/permissions', () => {
|
|
return HttpResponse.json({ permissions: {} });
|
|
}),
|
|
|
|
http.get('/api/admin/notification-preferences', () => {
|
|
return HttpResponse.json({
|
|
event_types: [],
|
|
available_channels: {},
|
|
implemented_combos: {},
|
|
preferences: {},
|
|
});
|
|
}),
|
|
|
|
// Auth settings endpoints used by AdminPage
|
|
http.get('/api/auth/app-settings', () => {
|
|
return HttpResponse.json({});
|
|
}),
|
|
|
|
http.put('/api/auth/app-settings', async ({ request }) => {
|
|
const body = await request.json() as Record<string, unknown>;
|
|
return HttpResponse.json({ ...body });
|
|
}),
|
|
|
|
http.get('/api/auth/me/settings', () => {
|
|
return HttpResponse.json({ settings: { maps_api_key: '', openweather_api_key: '' } });
|
|
}),
|
|
|
|
http.get('/api/auth/validate-keys', () => {
|
|
return HttpResponse.json({ maps: true, weather: true });
|
|
}),
|
|
];
|