From a4a5c82e346ebf3ece0639335ad4408edfc5df86 Mon Sep 17 00:00:00 2001 From: evermake Date: Sun, 24 Nov 2024 05:09:19 +0500 Subject: [PATCH] add random event --- frontend/src/api/types.ts | 68 ++++++++++++++++++++++++----------- frontend/src/routes/index.tsx | 12 ++++++- 2 files changed, 59 insertions(+), 21 deletions(-) diff --git a/frontend/src/api/types.ts b/frontend/src/api/types.ts index 59bc18f..be11bda 100644 --- a/frontend/src/api/types.ts +++ b/frontend/src/api/types.ts @@ -84,6 +84,23 @@ export interface paths { patch?: never; trace?: never; }; + "/events/random-event": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Get Random Event */ + get: operations["events_get_random_event"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; "/events/": { parameters: { query?: never; @@ -660,13 +677,6 @@ export interface components { /** Detail */ detail?: components["schemas"]["ValidationError"][]; }; - /** Keys */ - Keys: { - /** P256Dh */ - p256dh: string; - /** Auth */ - auth: string; - }; /** LocationFilter */ LocationFilter: { /** Country */ @@ -708,10 +718,8 @@ export interface components { sport_title: string | null; /** Sport Id */ sport_id: string | null; - /** Endpoint */ - endpoint: string; - /** Keys */ - keys: Record; + /** Subscription Info */ + subscription_info: Record; /** Event Dates */ event_dates: string[]; /** @@ -729,13 +737,8 @@ export interface components { NotificationCreateReq: { /** Notification Type */ notification_type: components["schemas"]["EventNotification"] | components["schemas"]["SportNotification"]; - notification_options: components["schemas"]["NotificationOption"]; - }; - /** NotificationOption */ - NotificationOption: { - /** Endpoint */ - endpoint: string; - keys: components["schemas"]["Keys"]; + /** Notification Options */ + notification_options: Record; }; /** * Order @@ -903,13 +906,11 @@ export type SchemaEventNotification = components['schemas']['EventNotification'] export type SchemaFilters = components['schemas']['Filters']; export type SchemaGender = components['schemas']['Gender']; export type SchemaHttpValidationError = components['schemas']['HTTPValidationError']; -export type SchemaKeys = components['schemas']['Keys']; export type SchemaLocationFilter = components['schemas']['LocationFilter']; export type SchemaLocationsFilterVariants = components['schemas']['LocationsFilterVariants']; export type SchemaMinMaxFilter = components['schemas']['MinMaxFilter']; export type SchemaNotification = components['schemas']['Notification']; export type SchemaNotificationCreateReq = components['schemas']['NotificationCreateReq']; -export type SchemaNotificationOption = components['schemas']['NotificationOption']; export type SchemaOrder = components['schemas']['Order']; export type SchemaPagination = components['schemas']['Pagination']; export type SchemaRegionsFilterVariants = components['schemas']['RegionsFilterVariants']; @@ -1055,6 +1056,33 @@ export interface operations { }; }; }; + events_get_random_event: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Successful Response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Event-Output"]; + }; + }; + /** @description Unable to verify credentials OR Credentials not provided */ + 401: { + headers: { + [name: string]: unknown; + }; + content?: never; + }; + }; + }; events_get_all_events: { parameters: { query?: never; diff --git a/frontend/src/routes/index.tsx b/frontend/src/routes/index.tsx index 0ca2eff..979e487 100644 --- a/frontend/src/routes/index.tsx +++ b/frontend/src/routes/index.tsx @@ -4,6 +4,7 @@ import { SportBadge } from "@/components/SportBadge"; import { Button } from "@/components/ui/button.tsx"; import { Input } from "@/components/ui/input.tsx"; import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; +import { Skeleton } from "@/components/ui/skeleton"; import { Filters, Sort } from "@/lib/types"; import { plainDatesForFilter } from "@/lib/utils"; import { createFileRoute, Link, useNavigate } from "@tanstack/react-router"; @@ -44,6 +45,7 @@ function RouteComponent() { const { data: eventsTotal } = $api.useQuery("post", "/events/search/count", { body: {}, }); + const { data: randomEvent } = $api.useQuery("get", "/events/random-event"); const [search, setSearch] = useState(""); const handleQuicklinkClick = (q: keyof typeof QUICKLINKS) => { @@ -214,8 +216,16 @@ function RouteComponent() { Temporal.PlainDate.from("2024-12-31"), ), }} - shuffle /> + +
+

"Мне повезёт"

+ {randomEvent ? ( + + ) : ( + + )} +
); }