Skip to content
This repository has been archived by the owner on Dec 15, 2024. It is now read-only.

Commit

Permalink
add random event
Browse files Browse the repository at this point in the history
  • Loading branch information
evermake committed Nov 24, 2024
1 parent fb0ae28 commit a4a5c82
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 21 deletions.
68 changes: 48 additions & 20 deletions frontend/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -660,13 +677,6 @@ export interface components {
/** Detail */
detail?: components["schemas"]["ValidationError"][];
};
/** Keys */
Keys: {
/** P256Dh */
p256dh: string;
/** Auth */
auth: string;
};
/** LocationFilter */
LocationFilter: {
/** Country */
Expand Down Expand Up @@ -708,10 +718,8 @@ export interface components {
sport_title: string | null;
/** Sport Id */
sport_id: string | null;
/** Endpoint */
endpoint: string;
/** Keys */
keys: Record<string, never>;
/** Subscription Info */
subscription_info: Record<string, never>;
/** Event Dates */
event_dates: string[];
/**
Expand All @@ -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<string, never>;
};
/**
* Order
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 11 additions & 1 deletion frontend/src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -214,8 +216,16 @@ function RouteComponent() {
Temporal.PlainDate.from("2024-12-31"),
),
}}
shuffle
/>

<section className="my-[64px]">
<h2 className="mb-6 text-center text-2xl font-medium">"Мне повезёт"</h2>
{randomEvent ? (
<EventCard event={randomEvent} className="mx-auto w-[900px]" />
) : (
<Skeleton className="mx-auto h-[225px] w-[900px]" />
)}
</section>
</main>
);
}
Expand Down

0 comments on commit a4a5c82

Please sign in to comment.