adds tags
This commit is contained in:
15
web/src/lib/models/api/tag_schema.ts
Normal file
15
web/src/lib/models/api/tag_schema.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { z, ZodType } from "zod";
|
||||
import type { SummitLog } from "../summit_log";
|
||||
import type { Tag } from "../tag";
|
||||
|
||||
|
||||
const TagCreateSchema = z.object({
|
||||
id: z.string().length(15).optional(),
|
||||
name: z.string()
|
||||
}) satisfies ZodType<Tag>
|
||||
|
||||
const TagUpdateSchema = z.object({
|
||||
name: z.string().optional()
|
||||
}) satisfies ZodType<Partial<Tag>>
|
||||
|
||||
export { TagCreateSchema, TagUpdateSchema };
|
||||
@@ -21,6 +21,7 @@ const TrailCreateSchema = z.object({
|
||||
waypoints: z.array(z.string()).default([]),
|
||||
summit_logs: z.array(z.string()).default([]),
|
||||
category: z.string().length(15).optional().or(z.literal('')),
|
||||
tags: z.array(z.string()).default([]),
|
||||
gpx: z.string().optional(),
|
||||
author: z.string().length(15),
|
||||
|
||||
@@ -46,6 +47,7 @@ const TrailUpdateSchema = z.object({
|
||||
waypoints: z.array(z.string()).optional(),
|
||||
summit_logs: z.array(z.string()).optional(),
|
||||
category: z.string().optional(),
|
||||
tags: z.array(z.string()).optional(),
|
||||
gpx: z.string().optional(),
|
||||
}) satisfies ZodType<Partial<Trail>>
|
||||
|
||||
|
||||
21
web/src/lib/models/tag.ts
Normal file
21
web/src/lib/models/tag.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import type { Trail } from "./trail";
|
||||
|
||||
export class Tag {
|
||||
id?: string;
|
||||
name: string;
|
||||
|
||||
constructor(name: string) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
export class TrailTag {
|
||||
id?: string;
|
||||
tag: Tag;
|
||||
trail: Trail;
|
||||
|
||||
constructor(tag: Tag, trail: Trail) {
|
||||
this.tag = tag;
|
||||
this.trail = trail;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { Category } from "./category";
|
||||
import type { Comment } from "./comment";
|
||||
import type { SummitLog } from "./summit_log";
|
||||
import type { Tag } from "./tag";
|
||||
import type { TrailShare } from "./trail_share";
|
||||
import type { UserAnonymous } from "./user";
|
||||
import type { Waypoint } from "./waypoint";
|
||||
@@ -23,9 +24,11 @@ class Trail {
|
||||
gpx?: string;
|
||||
created?: string;
|
||||
category?: string;
|
||||
tags: string[];
|
||||
waypoints: string[];
|
||||
summit_logs: string[];
|
||||
expand?: {
|
||||
tags?: Tag[]
|
||||
category?: Category;
|
||||
waypoints?: Waypoint[]
|
||||
summit_logs?: SummitLog[]
|
||||
@@ -34,7 +37,6 @@ class Trail {
|
||||
gpx_data?: string
|
||||
trail_share_via_trail?: TrailShare[]
|
||||
}
|
||||
tags?: string[];
|
||||
description?: string;
|
||||
author: string;
|
||||
|
||||
@@ -81,6 +83,7 @@ class Trail {
|
||||
this.photos = params?.photos ?? [];
|
||||
this.waypoints = [];
|
||||
this.summit_logs = [];
|
||||
this.tags = []
|
||||
this.gpx = params?.gpx;
|
||||
this.expand = {
|
||||
category: params?.category,
|
||||
@@ -89,7 +92,6 @@ class Trail {
|
||||
comments_via_trail: params?.comments ?? [],
|
||||
trail_share_via_trail: params?.shares ?? []
|
||||
}
|
||||
this.tags = params?.tags ?? []
|
||||
this.description = params?.description ?? "";
|
||||
this.created = params?.created;
|
||||
this.author = "000000000000000"
|
||||
@@ -99,6 +101,7 @@ class Trail {
|
||||
interface TrailFilter {
|
||||
q: string,
|
||||
category: string[],
|
||||
tags: string[],
|
||||
difficulty: ("easy" | "moderate" | "difficult")[]
|
||||
author?: string;
|
||||
public?: boolean;
|
||||
@@ -163,6 +166,7 @@ interface TrailSearchResult {
|
||||
public: boolean;
|
||||
thumbnail: string;
|
||||
shares?: string[];
|
||||
tags?: string[]
|
||||
gpx: string;
|
||||
_geo: {
|
||||
lat: number,
|
||||
|
||||
Reference in New Issue
Block a user