mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
chore: journey type fields for the test typecheck, prettier on the new shared schemas
This commit is contained in:
@@ -387,6 +387,10 @@ export interface Journey {
|
||||
status: 'draft' | 'active' | 'completed' | 'archived';
|
||||
/** Draw the linked trips' GPX tracks on this journey's map (#2194). 0 by default. */
|
||||
show_trip_tracks?: number;
|
||||
/** The state the owner set by hand (#762); null follows the trip dates. */
|
||||
status_override?: 'draft' | 'live' | 'completed' | null;
|
||||
/** Entries without a place take the spot of their first geotagged photo (#1003). 0 by default. */
|
||||
photo_location?: number;
|
||||
created_at: number;
|
||||
updated_at: number;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { hasPlaceHours, parsePlaceHours, placeEmailField, placeOpeningHoursField } from './place-hours';
|
||||
import { placeCreateRequestSchema, placeUpdateRequestSchema } from './place.schema';
|
||||
|
||||
const WEEK = '[{"closed":false,"open":"09:00","close":"17:00"},{"closed":false},{"closed":false},{"closed":false},{"closed":false},{"closed":true},{"closed":true}]';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
const WEEK =
|
||||
'[{"closed":false,"open":"09:00","close":"17:00"},{"closed":false},{"closed":false},{"closed":false},{"closed":false},{"closed":true},{"closed":true}]';
|
||||
|
||||
describe('place hours and e-mail (#2472)', () => {
|
||||
it('parses seven days and refuses anything else', () => {
|
||||
|
||||
@@ -36,14 +36,14 @@ export function parsePlaceHours(raw: unknown): PlaceOpeningHours | null {
|
||||
|
||||
/** Whether a week says anything: a day that is closed or has a time. */
|
||||
export function hasPlaceHours(hours: PlaceOpeningHours | null): boolean {
|
||||
return !!hours && hours.some(d => d.closed || !!d.open || !!d.close);
|
||||
return !!hours && hours.some((d) => d.closed || !!d.open || !!d.close);
|
||||
}
|
||||
|
||||
/** The request field: the JSON text, empty or null to clear it. */
|
||||
export const placeOpeningHoursField = z
|
||||
.string()
|
||||
.max(1000)
|
||||
.refine(v => v === '' || parsePlaceHours(v) !== null, { message: 'opening_hours must be seven days, Monday first' })
|
||||
.refine((v) => v === '' || parsePlaceHours(v) !== null, { message: 'opening_hours must be seven days, Monday first' })
|
||||
.nullable()
|
||||
.optional();
|
||||
|
||||
@@ -53,6 +53,6 @@ const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
export const placeEmailField = z
|
||||
.string()
|
||||
.max(254)
|
||||
.refine(v => v === '' || EMAIL.test(v.trim()), { message: 'email must be an e-mail address' })
|
||||
.refine((v) => v === '' || EMAIL.test(v.trim()), { message: 'email must be an e-mail address' })
|
||||
.nullable()
|
||||
.optional();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { tagSchema } from '../tag/tag.schema';
|
||||
import { PLACE_WEBSITE_MAX_LENGTH, normalizePlaceWebsite } from './place-website';
|
||||
import { placeEmailField, placeOpeningHoursField } from './place-hours';
|
||||
import { PLACE_WEBSITE_MAX_LENGTH, normalizePlaceWebsite } from './place-website';
|
||||
|
||||
import { z } from 'zod';
|
||||
|
||||
|
||||
@@ -169,9 +169,11 @@ export type ActiveTripResponse = z.infer<typeof activeTripResponseSchema>;
|
||||
* along for the card; title and date matching stays on the client.
|
||||
*/
|
||||
export const tripSearchResponseSchema = z.object({
|
||||
matches: z.array(z.object({
|
||||
trip_id: z.number(),
|
||||
places: z.array(z.string()),
|
||||
})),
|
||||
matches: z.array(
|
||||
z.object({
|
||||
trip_id: z.number(),
|
||||
places: z.array(z.string()),
|
||||
}),
|
||||
),
|
||||
});
|
||||
export type TripSearchResponse = z.infer<typeof tripSearchResponseSchema>;
|
||||
|
||||
Reference in New Issue
Block a user