diff --git a/frontend/app/(authenticated)/events/[id]/event-analysis.tsx b/frontend/app/(authenticated)/events/[id]/event-analysis.tsx index 3d31adc3..4646e154 100644 --- a/frontend/app/(authenticated)/events/[id]/event-analysis.tsx +++ b/frontend/app/(authenticated)/events/[id]/event-analysis.tsx @@ -3,7 +3,11 @@ import { useState } from "react"; import { SparklesIcon } from "lucide-react"; -import { EventDTO } from "@/client"; +import { + EventDTO, + src__events__schemas__AnalysisDTO as AnalysisDTO, +} from "@/client"; +import LikeButtons from "@/components/likes/like-buttons"; import { Accordion, AccordionContent, @@ -11,6 +15,8 @@ import { AccordionTrigger, } from "@/components/ui/accordion"; import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"; +import { useLikeEvent } from "@/queries/like"; +import { useUserStore } from "@/store/user/user-store-provider"; import { categoriesToDisplayName, categoriesToIconsMap, @@ -23,19 +29,25 @@ interface Props { } const EventAnalysis = ({ event }: Props) => { + const user = useUserStore((state) => state.user); + const eventCategories = event.categories.map((category) => getCategoryFor(category.name), ); - const [activeCategories, setActiveCategories] = useState([]); + const [activeCategories, setActiveCategories] = useState( + event.analysises.map((item) => getCategoryFor(item.category.name)), + ); // @ts-expect-error deadline doesnt give me time to bother with type errors - const analysis: { [key in Category]: string } = {}; + const analysis: { [key in Category]: AnalysisDTO } = {}; event.analysises.forEach( - (item) => (analysis[getCategoryFor(item.category.name)] = item.content), + (item) => (analysis[getCategoryFor(item.category.name)] = item), ); + const likeMutation = useLikeEvent(event.id); + return (
@@ -45,7 +57,7 @@ const EventAnalysis = ({ event }: Props) => {
setActiveCategories(value)} size="lg" type="multiple" @@ -80,6 +92,10 @@ const EventAnalysis = ({ event }: Props) => { > {Object.entries(analysis).map((item) => { const [category, analysis] = item; + const content = analysis.content; + const likes = analysis.likes; + const userLike = likes.filter((like) => like.user_id == user?.id)[0]; + const userLikeValue = userLike ? userLike.type : 0; const CategoryIcon = categoriesToIconsMap[category as Category]; return ( {
-
{analysis}
+
{content}
{/* Commenting out GP questions for now */} {/*
@@ -106,6 +122,15 @@ const EventAnalysis = ({ event }: Props) => { societal values and economies?
*/}
+ + likeMutation.mutate({ analysis_id: analysis.id, type: -1 }) + } + onLike={() => + likeMutation.mutate({ analysis_id: analysis.id, type: 1 }) + } + userLikeValue={userLikeValue} + />
); diff --git a/frontend/client/client.ts b/frontend/client/client.ts index 6d6722dd..7d794d27 100644 --- a/frontend/client/client.ts +++ b/frontend/client/client.ts @@ -1,4 +1,4 @@ -export { createClient } from "./core/"; +export { createClient } from './core/'; export type { Client, Config, @@ -6,10 +6,10 @@ export type { RequestOptions, RequestOptionsBase, RequestResult, -} from "./core/types"; +} from './core/types'; export { createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, -} from "./core/utils"; +} from './core/utils'; diff --git a/frontend/client/core/index.ts b/frontend/client/core/index.ts index d37e47f2..afe16e6a 100644 --- a/frontend/client/core/index.ts +++ b/frontend/client/core/index.ts @@ -1,8 +1,8 @@ -import type { AxiosError } from "axios"; -import axios from "axios"; +import type { AxiosError } from 'axios'; +import axios from 'axios'; -import type { Client, Config, RequestOptions } from "./types"; -import { createConfig, getUrl, mergeConfigs, mergeHeaders } from "./utils"; +import type { Client, Config, RequestOptions } from './types'; +import { createConfig, getUrl, mergeConfigs, mergeHeaders } from './utils'; export const createClient = (config: Config): Client => { let _config = mergeConfigs(createConfig(), config); @@ -23,7 +23,7 @@ export const createClient = (config: Config): Client => { }; // @ts-expect-error - const request: Client["request"] = async (options) => { + const request: Client['request'] = async (options) => { const opts: RequestOptions = { ..._config, ...options, @@ -51,7 +51,7 @@ export const createClient = (config: Config): Client => { let { data } = response; - if (opts.responseType === "json" && opts.responseTransformer) { + if (opts.responseType === 'json' && opts.responseTransformer) { data = await opts.responseTransformer(data); } @@ -71,15 +71,15 @@ export const createClient = (config: Config): Client => { }; return { - delete: (options) => request({ ...options, method: "delete" }), - get: (options) => request({ ...options, method: "get" }), + delete: (options) => request({ ...options, method: 'delete' }), + get: (options) => request({ ...options, method: 'get' }), getConfig, - head: (options) => request({ ...options, method: "head" }), + head: (options) => request({ ...options, method: 'head' }), instance, - options: (options) => request({ ...options, method: "options" }), - patch: (options) => request({ ...options, method: "patch" }), - post: (options) => request({ ...options, method: "post" }), - put: (options) => request({ ...options, method: "put" }), + options: (options) => request({ ...options, method: 'options' }), + patch: (options) => request({ ...options, method: 'patch' }), + post: (options) => request({ ...options, method: 'post' }), + put: (options) => request({ ...options, method: 'put' }), request, setConfig, } as Client; diff --git a/frontend/client/core/types.ts b/frontend/client/core/types.ts index ff774438..98db41f5 100644 --- a/frontend/client/core/types.ts +++ b/frontend/client/core/types.ts @@ -5,14 +5,14 @@ import type { AxiosResponse, AxiosStatic, CreateAxiosDefaults, -} from "axios"; +} from 'axios'; -import type { BodySerializer } from "./utils"; +import type { BodySerializer } from './utils'; type OmitKeys = Pick>; export interface Config - extends Omit { + extends Omit { /** * Axios implementation. You can use this option to provide a custom * Axios instance. @@ -37,7 +37,7 @@ export interface Config * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} */ headers?: - | CreateAxiosDefaults["headers"] + | CreateAxiosDefaults['headers'] | Record< string, | string @@ -54,15 +54,15 @@ export interface Config * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ method?: - | "connect" - | "delete" - | "get" - | "head" - | "options" - | "patch" - | "post" - | "put" - | "trace"; + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; /** * A function for transforming response data before it's returned to the * caller function. This is an ideal place to post-process server data, @@ -99,7 +99,7 @@ type MethodFn = < TError = unknown, ThrowOnError extends boolean = false, >( - options: Omit, "method">, + options: Omit, 'method'>, ) => RequestResult; type RequestFn = < @@ -107,8 +107,8 @@ type RequestFn = < TError = unknown, ThrowOnError extends boolean = false, >( - options: Omit, "method"> & - Pick>, "method">, + options: Omit, 'method'> & + Pick>, 'method'>, ) => RequestResult; export interface Client { @@ -127,12 +127,12 @@ export interface Client { export type RequestOptions = RequestOptionsBase & Config & { - headers: AxiosRequestConfig["headers"]; + headers: AxiosRequestConfig['headers']; }; type OptionsBase = Omit< RequestOptionsBase, - "url" + 'url' > & { /** * You can provide a client instance returned by `createClient()` instead of @@ -147,12 +147,12 @@ export type Options< ThrowOnError extends boolean = boolean, > = T extends { body?: any } ? T extends { headers?: any } - ? OmitKeys, "body" | "headers"> & T - : OmitKeys, "body"> & + ? OmitKeys, 'body' | 'headers'> & T + : OmitKeys, 'body'> & T & - Pick, "headers"> + Pick, 'headers'> : T extends { headers?: any } - ? OmitKeys, "headers"> & + ? OmitKeys, 'headers'> & T & - Pick, "body"> + Pick, 'body'> : OptionsBase & T; diff --git a/frontend/client/core/utils.ts b/frontend/client/core/utils.ts index 551198bc..2d3e8a8e 100644 --- a/frontend/client/core/utils.ts +++ b/frontend/client/core/utils.ts @@ -1,4 +1,4 @@ -import type { Config } from "./types"; +import type { Config } from './types'; interface PathSerializer { path: Record; @@ -7,10 +7,10 @@ interface PathSerializer { const PATH_PARAM_RE = /\{[^{}]+\}/g; -type ArrayStyle = "form" | "spaceDelimited" | "pipeDelimited"; -type MatrixStyle = "label" | "matrix" | "simple"; +type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +type MatrixStyle = 'label' | 'matrix' | 'simple'; type ArraySeparatorStyle = ArrayStyle | MatrixStyle; -type ObjectStyle = "form" | "deepObject"; +type ObjectStyle = 'form' | 'deepObject'; type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; export type BodySerializer = (body: any) => any; @@ -40,12 +40,12 @@ const serializePrimitiveParam = ({ value, }: SerializePrimitiveParam) => { if (value === undefined || value === null) { - return ""; + return ''; } - if (typeof value === "object") { + if (typeof value === 'object') { throw new Error( - "Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.", + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', ); } @@ -54,40 +54,40 @@ const serializePrimitiveParam = ({ const separatorArrayExplode = (style: ArraySeparatorStyle) => { switch (style) { - case "label": - return "."; - case "matrix": - return ";"; - case "simple": - return ","; + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; default: - return "&"; + return '&'; } }; const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { switch (style) { - case "form": - return ","; - case "pipeDelimited": - return "|"; - case "spaceDelimited": - return "%20"; + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; default: - return ","; + return ','; } }; const separatorObjectExplode = (style: ObjectSeparatorStyle) => { switch (style) { - case "label": - return "."; - case "matrix": - return ";"; - case "simple": - return ","; + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; default: - return "&"; + return '&'; } }; @@ -105,11 +105,11 @@ const serializeArrayParam = ({ allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) ).join(separatorArrayNoExplode(style)); switch (style) { - case "label": + case 'label': return `.${joinedValues}`; - case "matrix": + case 'matrix': return `;${name}=${joinedValues}`; - case "simple": + case 'simple': return joinedValues; default: return `${name}=${joinedValues}`; @@ -119,7 +119,7 @@ const serializeArrayParam = ({ const separator = separatorArrayExplode(style); const joinedValues = value .map((v) => { - if (style === "label" || style === "simple") { + if (style === 'label' || style === 'simple') { return allowReserved ? v : encodeURIComponent(v as string); } @@ -130,7 +130,7 @@ const serializeArrayParam = ({ }); }) .join(separator); - return style === "label" || style === "matrix" + return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues; }; @@ -144,7 +144,7 @@ const serializeObjectParam = ({ }: SerializeOptions & { value: Record; }) => { - if (style !== "deepObject" && !explode) { + if (style !== 'deepObject' && !explode) { let values: string[] = []; Object.entries(value).forEach(([key, v]) => { values = [ @@ -153,13 +153,13 @@ const serializeObjectParam = ({ allowReserved ? (v as string) : encodeURIComponent(v as string), ]; }); - const joinedValues = values.join(","); + const joinedValues = values.join(','); switch (style) { - case "form": + case 'form': return `${name}=${joinedValues}`; - case "label": + case 'label': return `.${joinedValues}`; - case "matrix": + case 'matrix': return `;${name}=${joinedValues}`; default: return joinedValues; @@ -171,12 +171,12 @@ const serializeObjectParam = ({ .map(([key, v]) => serializePrimitiveParam({ allowReserved, - name: style === "deepObject" ? `${name}[${key}]` : key, + name: style === 'deepObject' ? `${name}[${key}]` : key, value: v as string, }), ) .join(separator); - return style === "label" || style === "matrix" + return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues; }; @@ -188,19 +188,19 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { for (const match of matches) { let explode = false; let name = match.substring(1, match.length - 1); - let style: ArraySeparatorStyle = "simple"; + let style: ArraySeparatorStyle = 'simple'; - if (name.endsWith("*")) { + if (name.endsWith('*')) { explode = true; name = name.substring(0, name.length - 1); } - if (name.startsWith(".")) { + if (name.startsWith('.')) { name = name.substring(1); - style = "label"; - } else if (name.startsWith(";")) { + style = 'label'; + } else if (name.startsWith(';')) { name = name.substring(1); - style = "matrix"; + style = 'matrix'; } const value = path[name]; @@ -217,7 +217,7 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { continue; } - if (typeof value === "object") { + if (typeof value === 'object') { url = url.replace( match, serializeObjectParam({ @@ -230,7 +230,7 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { continue; } - if (style === "matrix") { + if (style === 'matrix') { url = url.replace( match, `;${serializePrimitiveParam({ @@ -242,7 +242,7 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { } const replaceValue = encodeURIComponent( - style === "label" ? `.${value as string}` : (value as string), + style === 'label' ? `.${value as string}` : (value as string), ); url = url.replace(match, replaceValue); } @@ -263,7 +263,7 @@ const serializeFormDataPair = ( key: string, value: unknown, ) => { - if (typeof value === "string" || value instanceof Blob) { + if (typeof value === 'string' || value instanceof Blob) { formData.append(key, value); } else { formData.append(key, JSON.stringify(value)); @@ -277,11 +277,11 @@ export const mergeConfigs = (a: Config, b: Config): Config => { }; export const mergeHeaders = ( - ...headers: Array["headers"] | undefined> -): Required["headers"] => { - const mergedHeaders: Required["headers"] = {}; + ...headers: Array['headers'] | undefined> +): Required['headers'] => { + const mergedHeaders: Required['headers'] = {}; for (const header of headers) { - if (!header || typeof header !== "object") { + if (!header || typeof header !== 'object') { continue; } @@ -301,7 +301,7 @@ export const mergeHeaders = ( // content value in OpenAPI specification is 'application/json' // @ts-expect-error mergedHeaders[key] = - typeof value === "object" ? JSON.stringify(value) : (value as string); + typeof value === 'object' ? JSON.stringify(value) : (value as string); } } } @@ -338,7 +338,7 @@ const serializeUrlSearchParamsPair = ( key: string, value: unknown, ) => { - if (typeof value === "string") { + if (typeof value === 'string') { data.append(key, value); } else { data.append(key, JSON.stringify(value)); @@ -367,6 +367,6 @@ export const urlSearchParamsBodySerializer = { }; export const createConfig = (override: Config = {}): Config => ({ - baseURL: "", + baseURL: '', ...override, }); diff --git a/frontend/client/index.ts b/frontend/client/index.ts index 1cb041de..0a2b84ba 100644 --- a/frontend/client/index.ts +++ b/frontend/client/index.ts @@ -1,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from "./schemas.gen"; -export * from "./services.gen"; -export * from "./types.gen"; +export * from './schemas.gen'; +export * from './services.gen'; +export * from './types.gen'; \ No newline at end of file diff --git a/frontend/client/schemas.gen.ts b/frontend/client/schemas.gen.ts index 3c7a4477..6f34b3b9 100644 --- a/frontend/client/schemas.gen.ts +++ b/frontend/client/schemas.gen.ts @@ -1,772 +1,790 @@ // This file is auto-generated by @hey-api/openapi-ts export const AnswerDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - points: { - items: { - $ref: "#/components/schemas/PointMiniDTO", - }, - type: "array", - title: "Points", - }, - }, - type: "object", - required: ["id", "points"], - title: "AnswerDTO", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + points: { + items: { + '$ref': '#/components/schemas/PointMiniDTO' + }, + type: 'array', + title: 'Points' + } + }, + type: 'object', + required: ['id', 'points'], + title: 'AnswerDTO' } as const; export const ArticleDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - title: { - type: "string", - title: "Title", - }, - summary: { - type: "string", - title: "Summary", - }, - url: { - type: "string", - title: "Url", - }, - source: { - $ref: "#/components/schemas/ArticleSource", - }, - date: { - type: "string", - format: "date-time", - title: "Date", - }, - image_url: { - type: "string", - title: "Image Url", - }, - }, - type: "object", - required: ["id", "title", "summary", "url", "source", "date", "image_url"], - title: "ArticleDTO", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + title: { + type: 'string', + title: 'Title' + }, + summary: { + type: 'string', + title: 'Summary' + }, + url: { + type: 'string', + title: 'Url' + }, + source: { + '$ref': '#/components/schemas/ArticleSource' + }, + date: { + type: 'string', + format: 'date-time', + title: 'Date' + }, + image_url: { + type: 'string', + title: 'Image Url' + } + }, + type: 'object', + required: ['id', 'title', 'summary', 'url', 'source', 'date', 'image_url'], + title: 'ArticleDTO' } as const; export const ArticleSourceSchema = { - type: "string", - enum: ["CNA", "GUARDIAN"], - title: "ArticleSource", + type: 'string', + enum: ['CNA', 'GUARDIAN'], + title: 'ArticleSource' } as const; export const Body_log_in_auth_login_postSchema = { - properties: { - grant_type: { - anyOf: [ - { - type: "string", - pattern: "password", - }, - { - type: "null", - }, - ], - title: "Grant Type", - }, - username: { - type: "string", - title: "Username", - }, - password: { - type: "string", - title: "Password", - }, - scope: { - type: "string", - title: "Scope", - default: "", - }, - client_id: { - anyOf: [ - { - type: "string", + properties: { + grant_type: { + anyOf: [ + { + type: 'string', + pattern: 'password' + }, + { + type: 'null' + } + ], + title: 'Grant Type' }, - { - type: "null", + username: { + type: 'string', + title: 'Username' }, - ], - title: "Client Id", - }, - client_secret: { - anyOf: [ - { - type: "string", + password: { + type: 'string', + title: 'Password' }, - { - type: "null", + scope: { + type: 'string', + title: 'Scope', + default: '' }, - ], - title: "Client Secret", - }, - }, - type: "object", - required: ["username", "password"], - title: "Body_log_in_auth_login_post", + client_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Client Id' + }, + client_secret: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Client Secret' + } + }, + type: 'object', + required: ['username', 'password'], + title: 'Body_log_in_auth_login_post' } as const; export const CategoryDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - name: { - type: "string", - title: "Name", - }, - }, - type: "object", - required: ["id", "name"], - title: "CategoryDTO", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + name: { + type: 'string', + title: 'Name' + } + }, + type: 'object', + required: ['id', 'name'], + title: 'CategoryDTO' } as const; export const CreateUserQuestionSchema = { - properties: { - question: { - type: "string", - title: "Question", - }, - }, - type: "object", - required: ["question"], - title: "CreateUserQuestion", + properties: { + question: { + type: 'string', + title: 'Question' + } + }, + type: 'object', + required: ['question'], + title: 'CreateUserQuestion' } as const; export const EventDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - title: { - type: "string", - title: "Title", - }, - description: { - type: "string", - title: "Description", - }, - is_singapore: { - type: "boolean", - title: "Is Singapore", - }, - date: { - type: "string", - format: "date-time", - title: "Date", - }, - categories: { - items: { - $ref: "#/components/schemas/CategoryDTO", - }, - type: "array", - title: "Categories", - }, - original_article: { - $ref: "#/components/schemas/ArticleDTO", - }, - reads: { - items: { - $ref: "#/components/schemas/ReadDTO", - }, - type: "array", - title: "Reads", - }, - analysises: { - items: { - $ref: "#/components/schemas/src__events__schemas__AnalysisDTO", - }, - type: "array", - title: "Analysises", - }, - gp_questions: { - items: { - $ref: "#/components/schemas/GPQuestionDTO", - }, - type: "array", - title: "Gp Questions", - }, - }, - type: "object", - required: [ - "id", - "title", - "description", - "is_singapore", - "date", - "categories", - "original_article", - "reads", - "analysises", - "gp_questions", - ], - title: "EventDTO", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + title: { + type: 'string', + title: 'Title' + }, + description: { + type: 'string', + title: 'Description' + }, + is_singapore: { + type: 'boolean', + title: 'Is Singapore' + }, + date: { + type: 'string', + format: 'date-time', + title: 'Date' + }, + categories: { + items: { + '$ref': '#/components/schemas/CategoryDTO' + }, + type: 'array', + title: 'Categories' + }, + original_article: { + '$ref': '#/components/schemas/ArticleDTO' + }, + reads: { + items: { + '$ref': '#/components/schemas/ReadDTO' + }, + type: 'array', + title: 'Reads' + }, + analysises: { + items: { + '$ref': '#/components/schemas/src__events__schemas__AnalysisDTO' + }, + type: 'array', + title: 'Analysises' + }, + gp_questions: { + items: { + '$ref': '#/components/schemas/GPQuestionDTO' + }, + type: 'array', + title: 'Gp Questions' + } + }, + type: 'object', + required: ['id', 'title', 'description', 'is_singapore', 'date', 'categories', 'original_article', 'reads', 'analysises', 'gp_questions'], + title: 'EventDTO' } as const; export const EventIndexResponseSchema = { - properties: { - total_count: { - type: "integer", - title: "Total Count", - }, - count: { - type: "integer", - title: "Count", - }, - data: { - items: { - $ref: "#/components/schemas/MiniEventDTO", - }, - type: "array", - title: "Data", - }, - }, - type: "object", - required: ["total_count", "count", "data"], - title: "EventIndexResponse", + properties: { + total_count: { + type: 'integer', + title: 'Total Count' + }, + count: { + type: 'integer', + title: 'Count' + }, + data: { + items: { + '$ref': '#/components/schemas/MiniEventDTO' + }, + type: 'array', + title: 'Data' + } + }, + type: 'object', + required: ['total_count', 'count', 'data'], + title: 'EventIndexResponse' +} as const; + +export const FallbackDTOSchema = { + properties: { + alt_approach: { + type: 'string', + title: 'Alt Approach' + }, + general_argument: { + type: 'string', + title: 'General Argument' + } + }, + type: 'object', + required: ['alt_approach', 'general_argument'], + title: 'FallbackDTO' } as const; export const GPQuestionDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - question: { - type: "string", - title: "Question", - }, - is_llm_generated: { - type: "boolean", - title: "Is Llm Generated", - }, - categories: { - items: { - $ref: "#/components/schemas/CategoryDTO", - }, - type: "array", - title: "Categories", - }, - }, - type: "object", - required: ["id", "question", "is_llm_generated", "categories"], - title: "GPQuestionDTO", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + question: { + type: 'string', + title: 'Question' + }, + is_llm_generated: { + type: 'boolean', + title: 'Is Llm Generated' + }, + categories: { + items: { + '$ref': '#/components/schemas/CategoryDTO' + }, + type: 'array', + title: 'Categories' + } + }, + type: 'object', + required: ['id', 'question', 'is_llm_generated', 'categories'], + title: 'GPQuestionDTO' } as const; export const HTTPValidationErrorSchema = { - properties: { - detail: { - items: { - $ref: "#/components/schemas/ValidationError", - }, - type: "array", - title: "Detail", - }, - }, - type: "object", - title: "HTTPValidationError", + properties: { + detail: { + items: { + '$ref': '#/components/schemas/ValidationError' + }, + type: 'array', + title: 'Detail' + } + }, + type: 'object', + title: 'HTTPValidationError' } as const; export const LikeDTOSchema = { - properties: { - point_id: { - anyOf: [ - { - type: "integer", + properties: { + point_id: { + anyOf: [ + { + type: 'integer' + }, + { + type: 'null' + } + ], + title: 'Point Id' }, - { - type: "null", + analysis_id: { + type: 'integer', + title: 'Analysis Id' }, - ], - title: "Point Id", - }, - analysis_id: { - type: "integer", - title: "Analysis Id", - }, - type: { - $ref: "#/components/schemas/LikeType", - }, - user_id: { - type: "integer", - title: "User Id", - }, - }, - type: "object", - required: ["analysis_id", "type", "user_id"], - title: "LikeDTO", + type: { + '$ref': '#/components/schemas/LikeType' + }, + user_id: { + type: 'integer', + title: 'User Id' + } + }, + type: 'object', + required: ['analysis_id', 'type', 'user_id'], + title: 'LikeDTO' } as const; export const LikeDataSchema = { - properties: { - point_id: { - anyOf: [ - { - type: "integer", + properties: { + point_id: { + anyOf: [ + { + type: 'integer' + }, + { + type: 'null' + } + ], + title: 'Point Id' }, - { - type: "null", + analysis_id: { + type: 'integer', + title: 'Analysis Id' }, - ], - title: "Point Id", - }, - analysis_id: { - type: "integer", - title: "Analysis Id", + type: { + '$ref': '#/components/schemas/LikeType' + } }, - type: { - $ref: "#/components/schemas/LikeType", - }, - }, - type: "object", - required: ["analysis_id", "type"], - title: "LikeData", + type: 'object', + required: ['analysis_id', 'type'], + title: 'LikeData' } as const; export const LikeTypeSchema = { - type: "integer", - enum: [1, -1], - title: "LikeType", + type: 'integer', + enum: [1, -1], + title: 'LikeType' } as const; export const MiniEventDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - title: { - type: "string", - title: "Title", - }, - description: { - type: "string", - title: "Description", - }, - is_singapore: { - type: "boolean", - title: "Is Singapore", - }, - date: { - type: "string", - format: "date-time", - title: "Date", - }, - categories: { - items: { - $ref: "#/components/schemas/CategoryDTO", - }, - type: "array", - title: "Categories", - }, - original_article: { - $ref: "#/components/schemas/ArticleDTO", - }, - reads: { - items: { - $ref: "#/components/schemas/ReadDTO", - }, - type: "array", - title: "Reads", - }, - }, - type: "object", - required: [ - "id", - "title", - "description", - "is_singapore", - "date", - "categories", - "original_article", - "reads", - ], - title: "MiniEventDTO", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + title: { + type: 'string', + title: 'Title' + }, + description: { + type: 'string', + title: 'Description' + }, + is_singapore: { + type: 'boolean', + title: 'Is Singapore' + }, + date: { + type: 'string', + format: 'date-time', + title: 'Date' + }, + categories: { + items: { + '$ref': '#/components/schemas/CategoryDTO' + }, + type: 'array', + title: 'Categories' + }, + original_article: { + '$ref': '#/components/schemas/ArticleDTO' + }, + reads: { + items: { + '$ref': '#/components/schemas/ReadDTO' + }, + type: 'array', + title: 'Reads' + } + }, + type: 'object', + required: ['id', 'title', 'description', 'is_singapore', 'date', 'categories', 'original_article', 'reads'], + title: 'MiniEventDTO' } as const; export const NoteCreateSchema = { - properties: { - content: { - type: "string", - title: "Content", - }, - start_index: { - type: "integer", - title: "Start Index", - }, - end_index: { - type: "integer", - title: "End Index", - }, - parent_id: { - type: "integer", - title: "Parent Id", - }, - parent_type: { - $ref: "#/components/schemas/NoteType", + properties: { + content: { + type: 'string', + title: 'Content' + }, + start_index: { + type: 'integer', + title: 'Start Index' + }, + end_index: { + type: 'integer', + title: 'End Index' + }, + parent_id: { + type: 'integer', + title: 'Parent Id' + }, + parent_type: { + '$ref': '#/components/schemas/NoteType' + } }, - }, - type: "object", - required: ["content", "start_index", "end_index", "parent_id", "parent_type"], - title: "NoteCreate", + type: 'object', + required: ['content', 'start_index', 'end_index', 'parent_id', 'parent_type'], + title: 'NoteCreate' } as const; export const NoteDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - content: { - type: "string", - title: "Content", - }, - start_index: { - type: "integer", - title: "Start Index", - }, - end_index: { - type: "integer", - title: "End Index", - }, - parent_id: { - type: "integer", - title: "Parent Id", - }, - parent_type: { - $ref: "#/components/schemas/NoteType", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + content: { + type: 'string', + title: 'Content' + }, + start_index: { + type: 'integer', + title: 'Start Index' + }, + end_index: { + type: 'integer', + title: 'End Index' + }, + parent_id: { + type: 'integer', + title: 'Parent Id' + }, + parent_type: { + '$ref': '#/components/schemas/NoteType' + } }, - }, - type: "object", - required: [ - "id", - "content", - "start_index", - "end_index", - "parent_id", - "parent_type", - ], - title: "NoteDTO", + type: 'object', + required: ['id', 'content', 'start_index', 'end_index', 'parent_id', 'parent_type'], + title: 'NoteDTO' } as const; export const NoteTypeSchema = { - type: "string", - enum: ["event", "article", "point"], - title: "NoteType", + type: 'string', + enum: ['event', 'article', 'point'], + title: 'NoteType' } as const; export const NoteUpdateSchema = { - properties: { - content: { - type: "string", - title: "Content", - }, - start_index: { - type: "integer", - title: "Start Index", - }, - end_index: { - type: "integer", - title: "End Index", - }, - }, - type: "object", - required: ["content", "start_index", "end_index"], - title: "NoteUpdate", + properties: { + content: { + type: 'string', + title: 'Content' + }, + start_index: { + type: 'integer', + title: 'Start Index' + }, + end_index: { + type: 'integer', + title: 'End Index' + } + }, + type: 'object', + required: ['content', 'start_index', 'end_index'], + title: 'NoteUpdate' } as const; export const PasswordResetCompleteDataSchema = { - properties: { - password: { - type: "string", - minLength: 6, - title: "Password", - }, - confirm_password: { - type: "string", - minLength: 6, - title: "Confirm Password", - }, - }, - type: "object", - required: ["password", "confirm_password"], - title: "PasswordResetCompleteData", + properties: { + password: { + type: 'string', + minLength: 6, + title: 'Password' + }, + confirm_password: { + type: 'string', + minLength: 6, + title: 'Confirm Password' + } + }, + type: 'object', + required: ['password', 'confirm_password'], + title: 'PasswordResetCompleteData' } as const; export const PasswordResetMoreCompleteDataSchema = { - properties: { - password: { - type: "string", - minLength: 6, - title: "Password", - }, - confirm_password: { - type: "string", - minLength: 6, - title: "Confirm Password", - }, - old_password: { - type: "string", - title: "Old Password", - }, - }, - type: "object", - required: ["password", "confirm_password", "old_password"], - title: "PasswordResetMoreCompleteData", + properties: { + password: { + type: 'string', + minLength: 6, + title: 'Password' + }, + confirm_password: { + type: 'string', + minLength: 6, + title: 'Confirm Password' + }, + old_password: { + type: 'string', + title: 'Old Password' + } + }, + type: 'object', + required: ['password', 'confirm_password', 'old_password'], + title: 'PasswordResetMoreCompleteData' } as const; export const PasswordResetRequestDataSchema = { - properties: { - email: { - type: "string", - format: "email", - title: "Email", - }, - }, - type: "object", - required: ["email"], - title: "PasswordResetRequestData", + properties: { + email: { + type: 'string', + format: 'email', + title: 'Email' + } + }, + type: 'object', + required: ['email'], + title: 'PasswordResetRequestData' +} as const; + +export const PointAnalysisDTOSchema = { + properties: { + analysis: { + '$ref': '#/components/schemas/src__user_questions__schemas__AnalysisDTO' + }, + elaboration: { + type: 'string', + title: 'Elaboration' + } + }, + type: 'object', + required: ['analysis', 'elaboration'], + title: 'PointAnalysisDTO' } as const; export const PointMiniDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - title: { - type: "string", - title: "Title", - }, - body: { - type: "string", - title: "Body", - }, - analysises: { - items: { - $ref: "#/components/schemas/src__user_questions__schemas__AnalysisDTO", - }, - type: "array", - title: "Analysises", - }, - }, - type: "object", - required: ["id", "title", "body", "analysises"], - title: "PointMiniDTO", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + title: { + type: 'string', + title: 'Title' + }, + body: { + type: 'string', + title: 'Body' + }, + point_analysises: { + items: { + '$ref': '#/components/schemas/PointAnalysisDTO' + }, + type: 'array', + title: 'Point Analysises' + }, + fallback: { + anyOf: [ + { + '$ref': '#/components/schemas/FallbackDTO' + }, + { + type: 'null' + } + ] + }, + positive: { + type: 'boolean', + title: 'Positive' + } + }, + type: 'object', + required: ['id', 'title', 'body', 'point_analysises', 'positive'], + title: 'PointMiniDTO' } as const; export const ProfileUpdateSchema = { - properties: { - category_ids: { - items: { - type: "integer", - }, - type: "array", - title: "Category Ids", - }, - top_events_period: { - type: "integer", - title: "Top Events Period", - default: 7, - }, - }, - type: "object", - title: "ProfileUpdate", + properties: { + category_ids: { + items: { + type: 'integer' + }, + type: 'array', + title: 'Category Ids' + }, + top_events_period: { + type: 'integer', + title: 'Top Events Period', + default: 7 + } + }, + type: 'object', + title: 'ProfileUpdate' } as const; export const ReadDTOSchema = { - properties: { - first_read: { - type: "string", - format: "date-time", - title: "First Read", - }, - last_read: { - type: "string", - format: "date-time", - title: "Last Read", - }, - }, - type: "object", - required: ["first_read", "last_read"], - title: "ReadDTO", + properties: { + first_read: { + type: 'string', + format: 'date-time', + title: 'First Read' + }, + last_read: { + type: 'string', + format: 'date-time', + title: 'Last Read' + } + }, + type: 'object', + required: ['first_read', 'last_read'], + title: 'ReadDTO' } as const; export const SignUpDataSchema = { - properties: { - email: { - type: "string", - format: "email", - title: "Email", - }, - password: { - type: "string", - minLength: 6, - title: "Password", - }, - }, - type: "object", - required: ["email", "password"], - title: "SignUpData", + properties: { + email: { + type: 'string', + format: 'email', + title: 'Email' + }, + password: { + type: 'string', + minLength: 6, + title: 'Password' + } + }, + type: 'object', + required: ['email', 'password'], + title: 'SignUpData' } as const; export const TokenSchema = { - properties: { - access_token: { - type: "string", - title: "Access Token", - }, - token_type: { - type: "string", - title: "Token Type", - }, - user: { - $ref: "#/components/schemas/UserPublic", + properties: { + access_token: { + type: 'string', + title: 'Access Token' + }, + token_type: { + type: 'string', + title: 'Token Type' + }, + user: { + '$ref': '#/components/schemas/UserPublic' + } }, - }, - type: "object", - required: ["access_token", "token_type", "user"], - title: "Token", + type: 'object', + required: ['access_token', 'token_type', 'user'], + title: 'Token' } as const; export const UserPublicSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - email: { - type: "string", - format: "email", - title: "Email", - }, - categories: { - items: { - $ref: "#/components/schemas/CategoryDTO", - }, - type: "array", - title: "Categories", - }, - top_events_period: { - type: "integer", - title: "Top Events Period", - default: 7, - }, - }, - type: "object", - required: ["id", "email", "categories"], - title: "UserPublic", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + email: { + type: 'string', + format: 'email', + title: 'Email' + }, + categories: { + items: { + '$ref': '#/components/schemas/CategoryDTO' + }, + type: 'array', + title: 'Categories' + }, + top_events_period: { + type: 'integer', + title: 'Top Events Period', + default: 7 + } + }, + type: 'object', + required: ['id', 'email', 'categories'], + title: 'UserPublic' } as const; export const UserQuestionMiniDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - question: { - type: "string", - title: "Question", - }, - answer: { - $ref: "#/components/schemas/AnswerDTO", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + question: { + type: 'string', + title: 'Question' + }, + answer: { + '$ref': '#/components/schemas/AnswerDTO' + } }, - }, - type: "object", - required: ["id", "question", "answer"], - title: "UserQuestionMiniDTO", + type: 'object', + required: ['id', 'question', 'answer'], + title: 'UserQuestionMiniDTO' } as const; export const ValidationErrorSchema = { - properties: { - loc: { - items: { - anyOf: [ - { - type: "string", - }, - { - type: "integer", - }, - ], - }, - type: "array", - title: "Location", - }, - msg: { - type: "string", - title: "Message", - }, - type: { - type: "string", - title: "Error Type", - }, - }, - type: "object", - required: ["loc", "msg", "type"], - title: "ValidationError", + properties: { + loc: { + items: { + anyOf: [ + { + type: 'string' + }, + { + type: 'integer' + } + ] + }, + type: 'array', + title: 'Location' + }, + msg: { + type: 'string', + title: 'Message' + }, + type: { + type: 'string', + title: 'Error Type' + } + }, + type: 'object', + required: ['loc', 'msg', 'type'], + title: 'ValidationError' } as const; export const src__events__schemas__AnalysisDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - category: { - $ref: "#/components/schemas/CategoryDTO", - }, - content: { - type: "string", - title: "Content", - }, - likes: { - items: { - $ref: "#/components/schemas/LikeDTO", - }, - type: "array", - title: "Likes", - }, - }, - type: "object", - required: ["id", "category", "content", "likes"], - title: "AnalysisDTO", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + category: { + '$ref': '#/components/schemas/CategoryDTO' + }, + content: { + type: 'string', + title: 'Content' + }, + likes: { + items: { + '$ref': '#/components/schemas/LikeDTO' + }, + type: 'array', + title: 'Likes' + } + }, + type: 'object', + required: ['id', 'category', 'content', 'likes'], + title: 'AnalysisDTO' } as const; export const src__user_questions__schemas__AnalysisDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - content: { - type: "string", - title: "Content", - }, - event: { - $ref: "#/components/schemas/MiniEventDTO", - }, - likes: { - items: { - $ref: "#/components/schemas/LikeDTO", - }, - type: "array", - title: "Likes", - }, - }, - type: "object", - required: ["id", "content", "event", "likes"], - title: "AnalysisDTO", -} as const; + properties: { + id: { + type: 'integer', + title: 'Id' + }, + content: { + type: 'string', + title: 'Content' + }, + event: { + '$ref': '#/components/schemas/MiniEventDTO' + }, + likes: { + items: { + '$ref': '#/components/schemas/LikeDTO' + }, + type: 'array', + title: 'Likes' + } + }, + type: 'object', + required: ['id', 'content', 'event', 'likes'], + title: 'AnalysisDTO' +} as const; \ No newline at end of file diff --git a/frontend/client/services.gen.ts b/frontend/client/services.gen.ts index 811dd332..b8641aad 100644 --- a/frontend/client/services.gen.ts +++ b/frontend/client/services.gen.ts @@ -1,535 +1,227 @@ // This file is auto-generated by @hey-api/openapi-ts -import { - createClient, - createConfig, - type Options, - urlSearchParamsBodySerializer, -} from "./client"; -import type { - SignUpAuthSignupPostData, - SignUpAuthSignupPostError, - SignUpAuthSignupPostResponse, - LogInAuthLoginPostData, - LogInAuthLoginPostError, - LogInAuthLoginPostResponse, - LoginGoogleAuthLoginGoogleGetError, - LoginGoogleAuthLoginGoogleGetResponse, - AuthGoogleAuthGoogleGetData, - AuthGoogleAuthGoogleGetError, - AuthGoogleAuthGoogleGetResponse, - GetUserAuthSessionGetData, - GetUserAuthSessionGetError, - GetUserAuthSessionGetResponse, - LogoutAuthLogoutGetError, - LogoutAuthLogoutGetResponse, - RequestPasswordResetAuthPasswordResetPostData, - RequestPasswordResetAuthPasswordResetPostError, - RequestPasswordResetAuthPasswordResetPostResponse, - CompletePasswordResetAuthPasswordResetPutData, - CompletePasswordResetAuthPasswordResetPutError, - CompletePasswordResetAuthPasswordResetPutResponse, - ChangePasswordAuthChangePasswordPutData, - ChangePasswordAuthChangePasswordPutError, - ChangePasswordAuthChangePasswordPutResponse, - GetCategoriesCategoriesGetError, - GetCategoriesCategoriesGetResponse, - UpdateProfileProfilePutData, - UpdateProfileProfilePutError, - UpdateProfileProfilePutResponse, - GetEventsEventsGetData, - GetEventsEventsGetError, - GetEventsEventsGetResponse, - GetEventEventsIdGetData, - GetEventEventsIdGetError, - GetEventEventsIdGetResponse, - GetEventNotesEventsIdNotesGetData, - GetEventNotesEventsIdNotesGetError, - GetEventNotesEventsIdNotesGetResponse, - ReadEventEventsIdReadPostData, - ReadEventEventsIdReadPostError, - ReadEventEventsIdReadPostResponse, - SearchWhateverEventsSearchGetData, - SearchWhateverEventsSearchGetError, - SearchWhateverEventsSearchGetResponse, - GetUserQuestionsUserQuestionsGetData, - GetUserQuestionsUserQuestionsGetError, - GetUserQuestionsUserQuestionsGetResponse, - CreateUserQuestionUserQuestionsPostData, - CreateUserQuestionUserQuestionsPostError, - CreateUserQuestionUserQuestionsPostResponse, - GetUserQuestionUserQuestionsIdGetData, - GetUserQuestionUserQuestionsIdGetError, - GetUserQuestionUserQuestionsIdGetResponse, - AskGpQuestionUserQuestionsAskGpQuestionGetData, - AskGpQuestionUserQuestionsAskGpQuestionGetError, - AskGpQuestionUserQuestionsAskGpQuestionGetResponse, - GetAllNotesNotesGetData, - GetAllNotesNotesGetError, - GetAllNotesNotesGetResponse, - CreateNoteNotesPostData, - CreateNoteNotesPostError, - CreateNoteNotesPostResponse, - UpdateNoteNotesIdPutData, - UpdateNoteNotesIdPutError, - UpdateNoteNotesIdPutResponse, - DeleteNoteNotesIdDeleteData, - DeleteNoteNotesIdDeleteError, - DeleteNoteNotesIdDeleteResponse, - GetPointNotesPointsIdNotesGetData, - GetPointNotesPointsIdNotesGetError, - GetPointNotesPointsIdNotesGetResponse, - UpsertLikeLikesPostData, - UpsertLikeLikesPostError, - UpsertLikeLikesPostResponse, -} from "./types.gen"; +import { createClient, createConfig, type Options, urlSearchParamsBodySerializer } from './client'; +import type { SignUpAuthSignupPostData, SignUpAuthSignupPostError, SignUpAuthSignupPostResponse, LogInAuthLoginPostData, LogInAuthLoginPostError, LogInAuthLoginPostResponse, LoginGoogleAuthLoginGoogleGetError, LoginGoogleAuthLoginGoogleGetResponse, AuthGoogleAuthGoogleGetData, AuthGoogleAuthGoogleGetError, AuthGoogleAuthGoogleGetResponse, GetUserAuthSessionGetData, GetUserAuthSessionGetError, GetUserAuthSessionGetResponse, LogoutAuthLogoutGetError, LogoutAuthLogoutGetResponse, RequestPasswordResetAuthPasswordResetPostData, RequestPasswordResetAuthPasswordResetPostError, RequestPasswordResetAuthPasswordResetPostResponse, CompletePasswordResetAuthPasswordResetPutData, CompletePasswordResetAuthPasswordResetPutError, CompletePasswordResetAuthPasswordResetPutResponse, ChangePasswordAuthChangePasswordPutData, ChangePasswordAuthChangePasswordPutError, ChangePasswordAuthChangePasswordPutResponse, GetCategoriesCategoriesGetError, GetCategoriesCategoriesGetResponse, UpdateProfileProfilePutData, UpdateProfileProfilePutError, UpdateProfileProfilePutResponse, GetEventsEventsGetData, GetEventsEventsGetError, GetEventsEventsGetResponse, GetEventEventsIdGetData, GetEventEventsIdGetError, GetEventEventsIdGetResponse, GetEventNotesEventsIdNotesGetData, GetEventNotesEventsIdNotesGetError, GetEventNotesEventsIdNotesGetResponse, ReadEventEventsIdReadPostData, ReadEventEventsIdReadPostError, ReadEventEventsIdReadPostResponse, SearchWhateverEventsSearchGetData, SearchWhateverEventsSearchGetError, SearchWhateverEventsSearchGetResponse, GetUserQuestionsUserQuestionsGetData, GetUserQuestionsUserQuestionsGetError, GetUserQuestionsUserQuestionsGetResponse, CreateUserQuestionUserQuestionsPostData, CreateUserQuestionUserQuestionsPostError, CreateUserQuestionUserQuestionsPostResponse, AskGpQuestionUserQuestionsAskGpQuestionGetData, AskGpQuestionUserQuestionsAskGpQuestionGetError, AskGpQuestionUserQuestionsAskGpQuestionGetResponse, GenPointsUserQuestionsGenPointsGetData, GenPointsUserQuestionsGenPointsGetError, GenPointsUserQuestionsGenPointsGetResponse, GetUserQuestionUserQuestionsIdGetData, GetUserQuestionUserQuestionsIdGetError, GetUserQuestionUserQuestionsIdGetResponse, GetAllNotesNotesGetData, GetAllNotesNotesGetError, GetAllNotesNotesGetResponse, CreateNoteNotesPostData, CreateNoteNotesPostError, CreateNoteNotesPostResponse, UpdateNoteNotesIdPutData, UpdateNoteNotesIdPutError, UpdateNoteNotesIdPutResponse, DeleteNoteNotesIdDeleteData, DeleteNoteNotesIdDeleteError, DeleteNoteNotesIdDeleteResponse, GetPointNotesPointsIdNotesGetData, GetPointNotesPointsIdNotesGetError, GetPointNotesPointsIdNotesGetResponse, UpsertLikeLikesPostData, UpsertLikeLikesPostError, UpsertLikeLikesPostResponse } from './types.gen'; export const client = createClient(createConfig()); /** * Sign Up */ -export const signUpAuthSignupPost = ( - options: Options, -) => { - return (options?.client ?? client).post< - SignUpAuthSignupPostResponse, - SignUpAuthSignupPostError, - ThrowOnError - >({ +export const signUpAuthSignupPost = (options: Options) => { return (options?.client ?? client).post({ ...options, - url: "/auth/signup", - }); -}; + url: '/auth/signup' +}); }; /** * Log In */ -export const logInAuthLoginPost = ( - options: Options, -) => { - return (options?.client ?? client).post< - LogInAuthLoginPostResponse, - LogInAuthLoginPostError, - ThrowOnError - >({ +export const logInAuthLoginPost = (options: Options) => { return (options?.client ?? client).post({ ...options, ...urlSearchParamsBodySerializer, headers: { - "Content-Type": "application/x-www-form-urlencoded", - ...options?.headers, + 'Content-Type': 'application/x-www-form-urlencoded', + ...options?.headers }, - url: "/auth/login", - }); -}; + url: '/auth/login' +}); }; /** * Login Google */ -export const loginGoogleAuthLoginGoogleGet = < - ThrowOnError extends boolean = false, ->( - options?: Options, -) => { - return (options?.client ?? client).get< - LoginGoogleAuthLoginGoogleGetResponse, - LoginGoogleAuthLoginGoogleGetError, - ThrowOnError - >({ +export const loginGoogleAuthLoginGoogleGet = (options?: Options) => { return (options?.client ?? client).get({ ...options, - url: "/auth/login/google", - }); -}; + url: '/auth/login/google' +}); }; /** * Auth Google */ -export const authGoogleAuthGoogleGet = ( - options: Options, -) => { - return (options?.client ?? client).get< - AuthGoogleAuthGoogleGetResponse, - AuthGoogleAuthGoogleGetError, - ThrowOnError - >({ +export const authGoogleAuthGoogleGet = (options: Options) => { return (options?.client ?? client).get({ ...options, - url: "/auth/google", - }); -}; + url: '/auth/google' +}); }; /** * Get User */ -export const getUserAuthSessionGet = ( - options?: Options, -) => { - return (options?.client ?? client).get< - GetUserAuthSessionGetResponse, - GetUserAuthSessionGetError, - ThrowOnError - >({ +export const getUserAuthSessionGet = (options?: Options) => { return (options?.client ?? client).get({ ...options, - url: "/auth/session", - }); -}; + url: '/auth/session' +}); }; /** * Logout */ -export const logoutAuthLogoutGet = ( - options?: Options, -) => { - return (options?.client ?? client).get< - LogoutAuthLogoutGetResponse, - LogoutAuthLogoutGetError, - ThrowOnError - >({ +export const logoutAuthLogoutGet = (options?: Options) => { return (options?.client ?? client).get({ ...options, - url: "/auth/logout", - }); -}; + url: '/auth/logout' +}); }; /** * Request Password Reset */ -export const requestPasswordResetAuthPasswordResetPost = < - ThrowOnError extends boolean = false, ->( - options: Options, -) => { - return (options?.client ?? client).post< - RequestPasswordResetAuthPasswordResetPostResponse, - RequestPasswordResetAuthPasswordResetPostError, - ThrowOnError - >({ +export const requestPasswordResetAuthPasswordResetPost = (options: Options) => { return (options?.client ?? client).post({ ...options, - url: "/auth/password-reset", - }); -}; + url: '/auth/password-reset' +}); }; /** * Complete Password Reset */ -export const completePasswordResetAuthPasswordResetPut = < - ThrowOnError extends boolean = false, ->( - options: Options, -) => { - return (options?.client ?? client).put< - CompletePasswordResetAuthPasswordResetPutResponse, - CompletePasswordResetAuthPasswordResetPutError, - ThrowOnError - >({ +export const completePasswordResetAuthPasswordResetPut = (options: Options) => { return (options?.client ?? client).put({ ...options, - url: "/auth/password-reset", - }); -}; + url: '/auth/password-reset' +}); }; /** * Change Password */ -export const changePasswordAuthChangePasswordPut = < - ThrowOnError extends boolean = false, ->( - options: Options, -) => { - return (options?.client ?? client).put< - ChangePasswordAuthChangePasswordPutResponse, - ChangePasswordAuthChangePasswordPutError, - ThrowOnError - >({ +export const changePasswordAuthChangePasswordPut = (options: Options) => { return (options?.client ?? client).put({ ...options, - url: "/auth/change-password", - }); -}; + url: '/auth/change-password' +}); }; /** * Get Categories */ -export const getCategoriesCategoriesGet = < - ThrowOnError extends boolean = false, ->( - options?: Options, -) => { - return (options?.client ?? client).get< - GetCategoriesCategoriesGetResponse, - GetCategoriesCategoriesGetError, - ThrowOnError - >({ +export const getCategoriesCategoriesGet = (options?: Options) => { return (options?.client ?? client).get({ ...options, - url: "/categories/", - }); -}; + url: '/categories/' +}); }; /** * Update Profile */ -export const updateProfileProfilePut = ( - options: Options, -) => { - return (options?.client ?? client).put< - UpdateProfileProfilePutResponse, - UpdateProfileProfilePutError, - ThrowOnError - >({ +export const updateProfileProfilePut = (options: Options) => { return (options?.client ?? client).put({ ...options, - url: "/profile/", - }); -}; + url: '/profile/' +}); }; /** * Get Events */ -export const getEventsEventsGet = ( - options?: Options, -) => { - return (options?.client ?? client).get< - GetEventsEventsGetResponse, - GetEventsEventsGetError, - ThrowOnError - >({ +export const getEventsEventsGet = (options?: Options) => { return (options?.client ?? client).get({ ...options, - url: "/events/", - }); -}; + url: '/events/' +}); }; /** * Get Event */ -export const getEventEventsIdGet = ( - options: Options, -) => { - return (options?.client ?? client).get< - GetEventEventsIdGetResponse, - GetEventEventsIdGetError, - ThrowOnError - >({ +export const getEventEventsIdGet = (options: Options) => { return (options?.client ?? client).get({ ...options, - url: "/events/{id}", - }); -}; + url: '/events/{id}' +}); }; /** * Get Event Notes */ -export const getEventNotesEventsIdNotesGet = < - ThrowOnError extends boolean = false, ->( - options: Options, -) => { - return (options?.client ?? client).get< - GetEventNotesEventsIdNotesGetResponse, - GetEventNotesEventsIdNotesGetError, - ThrowOnError - >({ +export const getEventNotesEventsIdNotesGet = (options: Options) => { return (options?.client ?? client).get({ ...options, - url: "/events/{id}/notes", - }); -}; + url: '/events/{id}/notes' +}); }; /** * Read Event */ -export const readEventEventsIdReadPost = ( - options: Options, -) => { - return (options?.client ?? client).post< - ReadEventEventsIdReadPostResponse, - ReadEventEventsIdReadPostError, - ThrowOnError - >({ +export const readEventEventsIdReadPost = (options: Options) => { return (options?.client ?? client).post({ ...options, - url: "/events/{id}/read", - }); -}; + url: '/events/{id}/read' +}); }; /** * Search Whatever */ -export const searchWhateverEventsSearchGet = < - ThrowOnError extends boolean = false, ->( - options: Options, -) => { - return (options?.client ?? client).get< - SearchWhateverEventsSearchGetResponse, - SearchWhateverEventsSearchGetError, - ThrowOnError - >({ +export const searchWhateverEventsSearchGet = (options: Options) => { return (options?.client ?? client).get({ ...options, - url: "/events/search", - }); -}; + url: '/events/search' +}); }; /** * Get User Questions */ -export const getUserQuestionsUserQuestionsGet = < - ThrowOnError extends boolean = false, ->( - options?: Options, -) => { - return (options?.client ?? client).get< - GetUserQuestionsUserQuestionsGetResponse, - GetUserQuestionsUserQuestionsGetError, - ThrowOnError - >({ +export const getUserQuestionsUserQuestionsGet = (options?: Options) => { return (options?.client ?? client).get({ ...options, - url: "/user-questions/", - }); -}; + url: '/user-questions/' +}); }; /** * Create User Question */ -export const createUserQuestionUserQuestionsPost = < - ThrowOnError extends boolean = false, ->( - options: Options, -) => { - return (options?.client ?? client).post< - CreateUserQuestionUserQuestionsPostResponse, - CreateUserQuestionUserQuestionsPostError, - ThrowOnError - >({ +export const createUserQuestionUserQuestionsPost = (options: Options) => { return (options?.client ?? client).post({ ...options, - url: "/user-questions/", - }); -}; + url: '/user-questions/' +}); }; /** - * Get User Question + * Ask Gp Question */ -export const getUserQuestionUserQuestionsIdGet = < - ThrowOnError extends boolean = false, ->( - options: Options, -) => { - return (options?.client ?? client).get< - GetUserQuestionUserQuestionsIdGetResponse, - GetUserQuestionUserQuestionsIdGetError, - ThrowOnError - >({ +export const askGpQuestionUserQuestionsAskGpQuestionGet = (options: Options) => { return (options?.client ?? client).get({ ...options, - url: "/user-questions/{id}", - }); -}; + url: '/user-questions/ask-gp-question' +}); }; /** - * Ask Gp Question + * Gen Points + */ +export const genPointsUserQuestionsGenPointsGet = (options: Options) => { return (options?.client ?? client).get({ + ...options, + url: '/user-questions/gen-points' +}); }; + +/** + * Get User Question */ -export const askGpQuestionUserQuestionsAskGpQuestionGet = < - ThrowOnError extends boolean = false, ->( - options: Options< - AskGpQuestionUserQuestionsAskGpQuestionGetData, - ThrowOnError - >, -) => { - return (options?.client ?? client).get< - AskGpQuestionUserQuestionsAskGpQuestionGetResponse, - AskGpQuestionUserQuestionsAskGpQuestionGetError, - ThrowOnError - >({ +export const getUserQuestionUserQuestionsIdGet = (options: Options) => { return (options?.client ?? client).get({ ...options, - url: "/user-questions/ask-gp-question", - }); -}; + url: '/user-questions/{id}' +}); }; /** * Get All Notes */ -export const getAllNotesNotesGet = ( - options?: Options, -) => { - return (options?.client ?? client).get< - GetAllNotesNotesGetResponse, - GetAllNotesNotesGetError, - ThrowOnError - >({ +export const getAllNotesNotesGet = (options?: Options) => { return (options?.client ?? client).get({ ...options, - url: "/notes/", - }); -}; + url: '/notes/' +}); }; /** * Create Note */ -export const createNoteNotesPost = ( - options: Options, -) => { - return (options?.client ?? client).post< - CreateNoteNotesPostResponse, - CreateNoteNotesPostError, - ThrowOnError - >({ +export const createNoteNotesPost = (options: Options) => { return (options?.client ?? client).post({ ...options, - url: "/notes/", - }); -}; + url: '/notes/' +}); }; /** * Update Note */ -export const updateNoteNotesIdPut = ( - options: Options, -) => { - return (options?.client ?? client).put< - UpdateNoteNotesIdPutResponse, - UpdateNoteNotesIdPutError, - ThrowOnError - >({ +export const updateNoteNotesIdPut = (options: Options) => { return (options?.client ?? client).put({ ...options, - url: "/notes/{id}", - }); -}; + url: '/notes/{id}' +}); }; /** * Delete Note */ -export const deleteNoteNotesIdDelete = ( - options: Options, -) => { - return (options?.client ?? client).delete< - DeleteNoteNotesIdDeleteResponse, - DeleteNoteNotesIdDeleteError, - ThrowOnError - >({ +export const deleteNoteNotesIdDelete = (options: Options) => { return (options?.client ?? client).delete({ ...options, - url: "/notes/{id}", - }); -}; + url: '/notes/{id}' +}); }; /** * Get Point Notes */ -export const getPointNotesPointsIdNotesGet = < - ThrowOnError extends boolean = false, ->( - options?: Options, -) => { - return (options?.client ?? client).get< - GetPointNotesPointsIdNotesGetResponse, - GetPointNotesPointsIdNotesGetError, - ThrowOnError - >({ +export const getPointNotesPointsIdNotesGet = (options?: Options) => { return (options?.client ?? client).get({ ...options, - url: "/points/{id}/notes", - }); -}; + url: '/points/{id}/notes' +}); }; /** * Upsert Like */ -export const upsertLikeLikesPost = ( - options: Options, -) => { - return (options?.client ?? client).post< - UpsertLikeLikesPostResponse, - UpsertLikeLikesPostError, - ThrowOnError - >({ +export const upsertLikeLikesPost = (options: Options) => { return (options?.client ?? client).post({ ...options, - url: "/likes/", - }); -}; + url: '/likes/' +}); }; \ No newline at end of file diff --git a/frontend/client/types.gen.ts b/frontend/client/types.gen.ts index 40b88a11..28f658e1 100644 --- a/frontend/client/types.gen.ts +++ b/frontend/client/types.gen.ts @@ -1,413 +1,431 @@ // This file is auto-generated by @hey-api/openapi-ts export type AnswerDTO = { - id: number; - points: Array; + id: number; + points: Array; }; export type ArticleDTO = { - id: number; - title: string; - summary: string; - url: string; - source: ArticleSource; - date: string; - image_url: string; + id: number; + title: string; + summary: string; + url: string; + source: ArticleSource; + date: string; + image_url: string; }; -export type ArticleSource = "CNA" | "GUARDIAN"; +export type ArticleSource = 'CNA' | 'GUARDIAN'; export type Body_log_in_auth_login_post = { - grant_type?: string | null; - username: string; - password: string; - scope?: string; - client_id?: string | null; - client_secret?: string | null; + grant_type?: (string | null); + username: string; + password: string; + scope?: string; + client_id?: (string | null); + client_secret?: (string | null); }; export type CategoryDTO = { - id: number; - name: string; + id: number; + name: string; }; export type CreateUserQuestion = { - question: string; + question: string; }; export type EventDTO = { - id: number; - title: string; - description: string; - is_singapore: boolean; - date: string; - categories: Array; - original_article: ArticleDTO; - reads: Array; - analysises: Array; - gp_questions: Array; + id: number; + title: string; + description: string; + is_singapore: boolean; + date: string; + categories: Array; + original_article: ArticleDTO; + reads: Array; + analysises: Array; + gp_questions: Array; }; export type EventIndexResponse = { - total_count: number; - count: number; - data: Array; + total_count: number; + count: number; + data: Array; +}; + +export type FallbackDTO = { + alt_approach: string; + general_argument: string; }; export type GPQuestionDTO = { - id: number; - question: string; - is_llm_generated: boolean; - categories: Array; + id: number; + question: string; + is_llm_generated: boolean; + categories: Array; }; export type HTTPValidationError = { - detail?: Array; + detail?: Array; }; export type LikeDTO = { - point_id?: number | null; - analysis_id: number; - type: LikeType; - user_id: number; + point_id?: (number | null); + analysis_id: number; + type: LikeType; + user_id: number; }; export type LikeData = { - point_id?: number | null; - analysis_id: number; - type: LikeType; + point_id?: (number | null); + analysis_id: number; + type: LikeType; }; export type LikeType = 1 | -1; export type MiniEventDTO = { - id: number; - title: string; - description: string; - is_singapore: boolean; - date: string; - categories: Array; - original_article: ArticleDTO; - reads: Array; + id: number; + title: string; + description: string; + is_singapore: boolean; + date: string; + categories: Array; + original_article: ArticleDTO; + reads: Array; }; export type NoteCreate = { - content: string; - start_index: number; - end_index: number; - parent_id: number; - parent_type: NoteType; + content: string; + start_index: number; + end_index: number; + parent_id: number; + parent_type: NoteType; }; export type NoteDTO = { - id: number; - content: string; - start_index: number; - end_index: number; - parent_id: number; - parent_type: NoteType; + id: number; + content: string; + start_index: number; + end_index: number; + parent_id: number; + parent_type: NoteType; }; -export type NoteType = "event" | "article" | "point"; +export type NoteType = 'event' | 'article' | 'point'; export type NoteUpdate = { - content: string; - start_index: number; - end_index: number; + content: string; + start_index: number; + end_index: number; }; export type PasswordResetCompleteData = { - password: string; - confirm_password: string; + password: string; + confirm_password: string; }; export type PasswordResetMoreCompleteData = { - password: string; - confirm_password: string; - old_password: string; + password: string; + confirm_password: string; + old_password: string; }; export type PasswordResetRequestData = { - email: string; + email: string; +}; + +export type PointAnalysisDTO = { + analysis: src__user_questions__schemas__AnalysisDTO; + elaboration: string; }; export type PointMiniDTO = { - id: number; - title: string; - body: string; - analysises: Array; + id: number; + title: string; + body: string; + point_analysises: Array; + fallback?: (FallbackDTO | null); + positive: boolean; }; export type ProfileUpdate = { - category_ids?: Array; - top_events_period?: number; + category_ids?: Array<(number)>; + top_events_period?: number; }; export type ReadDTO = { - first_read: string; - last_read: string; + first_read: string; + last_read: string; }; export type SignUpData = { - email: string; - password: string; + email: string; + password: string; }; export type Token = { - access_token: string; - token_type: string; - user: UserPublic; + access_token: string; + token_type: string; + user: UserPublic; }; export type UserPublic = { - id: number; - email: string; - categories: Array; - top_events_period?: number; + id: number; + email: string; + categories: Array; + top_events_period?: number; }; export type UserQuestionMiniDTO = { - id: number; - question: string; - answer: AnswerDTO; + id: number; + question: string; + answer: AnswerDTO; }; export type ValidationError = { - loc: Array; - msg: string; - type: string; + loc: Array<(string | number)>; + msg: string; + type: string; }; export type src__events__schemas__AnalysisDTO = { - id: number; - category: CategoryDTO; - content: string; - likes: Array; + id: number; + category: CategoryDTO; + content: string; + likes: Array; }; export type src__user_questions__schemas__AnalysisDTO = { - id: number; - content: string; - event: MiniEventDTO; - likes: Array; + id: number; + content: string; + event: MiniEventDTO; + likes: Array; }; export type SignUpAuthSignupPostData = { - body: SignUpData; + body: SignUpData; }; -export type SignUpAuthSignupPostResponse = Token; +export type SignUpAuthSignupPostResponse = (Token); -export type SignUpAuthSignupPostError = HTTPValidationError; +export type SignUpAuthSignupPostError = (HTTPValidationError); export type LogInAuthLoginPostData = { - body: Body_log_in_auth_login_post; + body: Body_log_in_auth_login_post; }; -export type LogInAuthLoginPostResponse = Token; +export type LogInAuthLoginPostResponse = (Token); -export type LogInAuthLoginPostError = HTTPValidationError; +export type LogInAuthLoginPostError = (HTTPValidationError); -export type LoginGoogleAuthLoginGoogleGetResponse = unknown; +export type LoginGoogleAuthLoginGoogleGetResponse = (unknown); export type LoginGoogleAuthLoginGoogleGetError = unknown; export type AuthGoogleAuthGoogleGetData = { - query: { - code: string; - }; + query: { + code: string; + }; }; -export type AuthGoogleAuthGoogleGetResponse = Token; +export type AuthGoogleAuthGoogleGetResponse = (Token); -export type AuthGoogleAuthGoogleGetError = HTTPValidationError; +export type AuthGoogleAuthGoogleGetError = (HTTPValidationError); export type GetUserAuthSessionGetData = unknown; -export type GetUserAuthSessionGetResponse = UserPublic; +export type GetUserAuthSessionGetResponse = (UserPublic); -export type GetUserAuthSessionGetError = HTTPValidationError; +export type GetUserAuthSessionGetError = (HTTPValidationError); -export type LogoutAuthLogoutGetResponse = unknown; +export type LogoutAuthLogoutGetResponse = (unknown); export type LogoutAuthLogoutGetError = unknown; export type RequestPasswordResetAuthPasswordResetPostData = { - body: PasswordResetRequestData; + body: PasswordResetRequestData; }; -export type RequestPasswordResetAuthPasswordResetPostResponse = unknown; +export type RequestPasswordResetAuthPasswordResetPostResponse = (unknown); -export type RequestPasswordResetAuthPasswordResetPostError = - HTTPValidationError; +export type RequestPasswordResetAuthPasswordResetPostError = (HTTPValidationError); export type CompletePasswordResetAuthPasswordResetPutData = { - body: PasswordResetCompleteData; - query: { - code: string; - }; + body: PasswordResetCompleteData; + query: { + code: string; + }; }; -export type CompletePasswordResetAuthPasswordResetPutResponse = unknown; +export type CompletePasswordResetAuthPasswordResetPutResponse = (unknown); -export type CompletePasswordResetAuthPasswordResetPutError = - HTTPValidationError; +export type CompletePasswordResetAuthPasswordResetPutError = (HTTPValidationError); export type ChangePasswordAuthChangePasswordPutData = { - body: PasswordResetMoreCompleteData; + body: PasswordResetMoreCompleteData; }; -export type ChangePasswordAuthChangePasswordPutResponse = unknown; +export type ChangePasswordAuthChangePasswordPutResponse = (unknown); -export type ChangePasswordAuthChangePasswordPutError = HTTPValidationError; +export type ChangePasswordAuthChangePasswordPutError = (HTTPValidationError); -export type GetCategoriesCategoriesGetResponse = Array; +export type GetCategoriesCategoriesGetResponse = (Array); export type GetCategoriesCategoriesGetError = unknown; export type UpdateProfileProfilePutData = { - body: ProfileUpdate; + body: ProfileUpdate; }; -export type UpdateProfileProfilePutResponse = UserPublic; +export type UpdateProfileProfilePutResponse = (UserPublic); -export type UpdateProfileProfilePutError = HTTPValidationError; +export type UpdateProfileProfilePutError = (HTTPValidationError); export type GetEventsEventsGetData = { - query?: { - category_ids?: Array | null; - end_date?: string | null; - limit?: number | null; - offset?: number | null; - start_date?: string | null; - }; + query?: { + category_ids?: (Array<(number)> | null); + end_date?: (string | null); + limit?: (number | null); + offset?: (number | null); + start_date?: (string | null); + }; }; -export type GetEventsEventsGetResponse = EventIndexResponse; +export type GetEventsEventsGetResponse = (EventIndexResponse); -export type GetEventsEventsGetError = HTTPValidationError; +export type GetEventsEventsGetError = (HTTPValidationError); export type GetEventEventsIdGetData = { - path: { - id: number; - }; + path: { + id: number; + }; }; -export type GetEventEventsIdGetResponse = EventDTO; +export type GetEventEventsIdGetResponse = (EventDTO); -export type GetEventEventsIdGetError = HTTPValidationError; +export type GetEventEventsIdGetError = (HTTPValidationError); export type GetEventNotesEventsIdNotesGetData = { - path: { - id: number; - }; + path: { + id: number; + }; }; -export type GetEventNotesEventsIdNotesGetResponse = Array; +export type GetEventNotesEventsIdNotesGetResponse = (Array); -export type GetEventNotesEventsIdNotesGetError = HTTPValidationError; +export type GetEventNotesEventsIdNotesGetError = (HTTPValidationError); export type ReadEventEventsIdReadPostData = { - path: { - id: number; - }; + path: { + id: number; + }; }; -export type ReadEventEventsIdReadPostResponse = unknown; +export type ReadEventEventsIdReadPostResponse = (unknown); -export type ReadEventEventsIdReadPostError = HTTPValidationError; +export type ReadEventEventsIdReadPostError = (HTTPValidationError); export type SearchWhateverEventsSearchGetData = { - query: { - query: string; - }; + query: { + query: string; + }; }; -export type SearchWhateverEventsSearchGetResponse = unknown; +export type SearchWhateverEventsSearchGetResponse = (unknown); -export type SearchWhateverEventsSearchGetError = HTTPValidationError; +export type SearchWhateverEventsSearchGetError = (HTTPValidationError); export type GetUserQuestionsUserQuestionsGetData = unknown; -export type GetUserQuestionsUserQuestionsGetResponse = - Array; +export type GetUserQuestionsUserQuestionsGetResponse = (Array); -export type GetUserQuestionsUserQuestionsGetError = HTTPValidationError; +export type GetUserQuestionsUserQuestionsGetError = (HTTPValidationError); export type CreateUserQuestionUserQuestionsPostData = { - body: CreateUserQuestion; + body: CreateUserQuestion; }; -export type CreateUserQuestionUserQuestionsPostResponse = UserQuestionMiniDTO; +export type CreateUserQuestionUserQuestionsPostResponse = (UserQuestionMiniDTO); -export type CreateUserQuestionUserQuestionsPostError = HTTPValidationError; +export type CreateUserQuestionUserQuestionsPostError = (HTTPValidationError); -export type GetUserQuestionUserQuestionsIdGetData = { - path: { - id: number; - }; +export type AskGpQuestionUserQuestionsAskGpQuestionGetData = { + query: { + question: string; + }; }; -export type GetUserQuestionUserQuestionsIdGetResponse = UserQuestionMiniDTO; +export type AskGpQuestionUserQuestionsAskGpQuestionGetResponse = (unknown); -export type GetUserQuestionUserQuestionsIdGetError = HTTPValidationError; +export type AskGpQuestionUserQuestionsAskGpQuestionGetError = (HTTPValidationError); -export type AskGpQuestionUserQuestionsAskGpQuestionGetData = { - query: { - question: string; - }; +export type GenPointsUserQuestionsGenPointsGetData = { + query: { + question: string; + }; +}; + +export type GenPointsUserQuestionsGenPointsGetResponse = (unknown); + +export type GenPointsUserQuestionsGenPointsGetError = (HTTPValidationError); + +export type GetUserQuestionUserQuestionsIdGetData = { + path: { + id: number; + }; }; -export type AskGpQuestionUserQuestionsAskGpQuestionGetResponse = unknown; +export type GetUserQuestionUserQuestionsIdGetResponse = (UserQuestionMiniDTO); -export type AskGpQuestionUserQuestionsAskGpQuestionGetError = - HTTPValidationError; +export type GetUserQuestionUserQuestionsIdGetError = (HTTPValidationError); export type GetAllNotesNotesGetData = unknown; -export type GetAllNotesNotesGetResponse = Array; +export type GetAllNotesNotesGetResponse = (Array); -export type GetAllNotesNotesGetError = HTTPValidationError; +export type GetAllNotesNotesGetError = (HTTPValidationError); export type CreateNoteNotesPostData = { - body: NoteCreate; + body: NoteCreate; }; -export type CreateNoteNotesPostResponse = NoteDTO; +export type CreateNoteNotesPostResponse = (NoteDTO); -export type CreateNoteNotesPostError = HTTPValidationError; +export type CreateNoteNotesPostError = (HTTPValidationError); export type UpdateNoteNotesIdPutData = { - body: NoteUpdate; - path: { - id: number; - }; + body: NoteUpdate; + path: { + id: number; + }; }; -export type UpdateNoteNotesIdPutResponse = NoteDTO; +export type UpdateNoteNotesIdPutResponse = (NoteDTO); -export type UpdateNoteNotesIdPutError = HTTPValidationError; +export type UpdateNoteNotesIdPutError = (HTTPValidationError); export type DeleteNoteNotesIdDeleteData = { - path: { - id: number; - }; + path: { + id: number; + }; }; -export type DeleteNoteNotesIdDeleteResponse = unknown; +export type DeleteNoteNotesIdDeleteResponse = (unknown); -export type DeleteNoteNotesIdDeleteError = HTTPValidationError; +export type DeleteNoteNotesIdDeleteError = (HTTPValidationError); export type GetPointNotesPointsIdNotesGetData = unknown; -export type GetPointNotesPointsIdNotesGetResponse = unknown; +export type GetPointNotesPointsIdNotesGetResponse = (unknown); -export type GetPointNotesPointsIdNotesGetError = HTTPValidationError; +export type GetPointNotesPointsIdNotesGetError = (HTTPValidationError); export type UpsertLikeLikesPostData = { - body: LikeData; + body: LikeData; }; -export type UpsertLikeLikesPostResponse = unknown; +export type UpsertLikeLikesPostResponse = (unknown); -export type UpsertLikeLikesPostError = HTTPValidationError; +export type UpsertLikeLikesPostError = (HTTPValidationError); \ No newline at end of file diff --git a/frontend/components/likes/like-buttons.tsx b/frontend/components/likes/like-buttons.tsx new file mode 100644 index 00000000..26807ce8 --- /dev/null +++ b/frontend/components/likes/like-buttons.tsx @@ -0,0 +1,36 @@ +import { LucideThumbsDown, LucideThumbsUp } from "lucide-react"; + +import { Button } from "@/components/ui/button"; +import { cn } from "@/lib/utils"; + +interface Props { + onLike: () => void; + onDislike: () => void; + userLikeValue: 0 | 1 | -1; +} + +function LikeButtons({ onLike, onDislike, userLikeValue }: Props) { + return ( +
+

Is this helpful?

+
+ + +
+
+ ); +} + +export default LikeButtons; diff --git a/frontend/components/ui/toggle-group.tsx b/frontend/components/ui/toggle-group.tsx index 3a5547f8..9a51e08b 100644 --- a/frontend/components/ui/toggle-group.tsx +++ b/frontend/components/ui/toggle-group.tsx @@ -20,7 +20,7 @@ const ToggleGroup = React.forwardRef< VariantProps >(({ className, variant, size, children, ...props }, ref) => ( diff --git a/frontend/queries/like.ts b/frontend/queries/like.ts new file mode 100644 index 00000000..91e18346 --- /dev/null +++ b/frontend/queries/like.ts @@ -0,0 +1,28 @@ +import { useMutation, useQueryClient } from "@tanstack/react-query"; + +import { LikeType, upsertLikeLikesPost } from "@/client"; + +import { QueryKeys } from "./utils/query-keys"; + +export const useLikeEvent = (event_id: number) => { + const queryClient = useQueryClient(); + return useMutation({ + mutationFn: ({ + analysis_id, + type, + }: { + analysis_id: number; + type: LikeType; + }) => { + return upsertLikeLikesPost({ + body: { + analysis_id, + type, + }, + }); + }, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: [QueryKeys.Events, event_id] }); + }, + }); +};