diff --git a/frontend/app/(authenticated)/template.tsx b/frontend/app/(authenticated)/template.tsx index d8af8d4f..08b27507 100644 --- a/frontend/app/(authenticated)/template.tsx +++ b/frontend/app/(authenticated)/template.tsx @@ -21,7 +21,6 @@ export default function RedirectIfNotAuthenticated({ } = useQuery(getUserProfile()); useEffect(() => { - console.log({ isUserProfileSuccess, userProfile }); if (!isFetching) { if (!userProfile) { if (!isLoggedIn) { diff --git a/frontend/app/home.tsx b/frontend/app/home.tsx index 31d68b32..01fa5b28 100644 --- a/frontend/app/home.tsx +++ b/frontend/app/home.tsx @@ -2,6 +2,7 @@ import { useEffect, useMemo, useState } from "react"; import { useRouter } from "next/navigation"; import { getEventsEventsGet, MiniEventDTO } from "@/client"; +import ScrollToTopButton from "@/components/navigation/scroll-to-top-button"; import ArticleLoading from "@/components/news/article-loading"; import NewsArticle from "@/components/news/news-article"; import { useUserStore } from "@/store/user/user-store-provider"; @@ -64,32 +65,42 @@ const Home = () => { }, [user, eventStartDate]); return ( -
-
- {/* TODO: x-padding here is tied to the news article */} -
-

- What happened this week -

- - {parseDate(eventStartDate)} - {parseDate(new Date())} - -
+
+
+
+ {/* TODO: x-padding here is tied to the news article */} +
+

+ What happened this week +

+ + {parseDate(eventStartDate)} - {parseDate(new Date())} + +
-
- {!isLoaded ? ( - <> - - - - - ) : ( - topEvents.map((newsEvent: MiniEventDTO, index: number) => ( - - )) - )} +
+ {!isLoaded ? ( + <> + + + + + ) : ( + topEvents.map((newsEvent: MiniEventDTO, index: number) => ( + + )) + )} +
+
); }; diff --git a/frontend/client/client.ts b/frontend/client/client.ts index 7d794d27..6d6722dd 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 afe16e6a..d37e47f2 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 98db41f5..ff774438 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 2d3e8a8e..551198bc 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 0a2b84ba..1cb041de 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'; \ No newline at end of file +export * from "./schemas.gen"; +export * from "./services.gen"; +export * from "./types.gen"; diff --git a/frontend/client/schemas.gen.ts b/frontend/client/schemas.gen.ts index 0ff684ad..b314fa65 100644 --- a/frontend/client/schemas.gen.ts +++ b/frontend/client/schemas.gen.ts @@ -1,736 +1,763 @@ // 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' + 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", }, - password: { - type: 'string', - title: 'Password' + { + type: "null", }, - scope: { - type: 'string', - title: 'Scope', - default: '' + ], + title: "Client Id", + }, + client_secret: { + anyOf: [ + { + type: "string", }, - client_id: { - anyOf: [ - { - type: 'string' - }, - { - type: 'null' - } - ], - title: 'Client Id' + { + type: "null", }, - client_secret: { - anyOf: [ - { - type: 'string' - }, - { - type: 'null' - } - ], - title: 'Client Secret' - } - }, - type: 'object', - required: ['username', 'password'], - title: 'Body_log_in_auth_login_post' + ], + 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 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' - }, - { - type: 'null' - } - ], - title: 'Point Id' - }, - analysis_id: { - type: 'integer', - title: 'Analysis Id' + properties: { + point_id: { + anyOf: [ + { + type: "integer", }, - type: { - '$ref': '#/components/schemas/LikeType' + { + type: "null", }, - user_id: { - type: 'integer', - title: 'User Id' - } - }, - type: 'object', - required: ['analysis_id', 'type', 'user_id'], - title: 'LikeDTO' + ], + 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", } as const; export const LikeDataSchema = { - properties: { - point_id: { - anyOf: [ - { - type: 'integer' - }, - { - type: 'null' - } - ], - title: 'Point Id' + properties: { + point_id: { + anyOf: [ + { + type: "integer", }, - analysis_id: { - type: 'integer', - title: 'Analysis Id' + { + type: "null", }, - type: { - '$ref': '#/components/schemas/LikeType' - } + ], + title: "Point Id", + }, + analysis_id: { + type: "integer", + title: "Analysis Id", }, - type: 'object', - required: ['analysis_id', 'type'], - title: 'LikeData' + type: { + $ref: "#/components/schemas/LikeType", + }, + }, + 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", }, - type: 'object', - required: ['content', 'start_index', 'end_index', 'parent_id', 'parent_type'], - title: 'NoteCreate' + 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", } 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", }, - type: 'object', - required: ['id', 'content', 'start_index', 'end_index', 'parent_id', 'parent_type'], - title: 'NoteDTO' + 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", } 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 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", + }, + analysises: { + items: { + $ref: "#/components/schemas/src__user_questions__schemas__AnalysisDTO", + }, + type: "array", + title: "Analysises", + }, + }, + type: "object", + required: ["id", "title", "body", "analysises"], + title: "PointMiniDTO", } as const; export const ProfileUpdateSchema = { - properties: { - category_ids: { - items: { - type: 'integer' - }, - type: 'array', - title: 'Category Ids' - } - }, - type: 'object', - required: ['category_ids'], - title: 'ProfileUpdate' + properties: { + category_ids: { + items: { + type: "integer", + }, + type: "array", + title: "Category Ids", + }, + }, + type: "object", + required: ["category_ids"], + 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", }, - type: 'object', - required: ['access_token', 'token_type', 'user'], - title: 'Token' + user: { + $ref: "#/components/schemas/UserPublic", + }, + }, + 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' - } - }, - 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", + }, + }, + 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; \ No newline at end of file + 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; diff --git a/frontend/client/services.gen.ts b/frontend/client/services.gen.ts index b4bbfb46..811dd332 100644 --- a/frontend/client/services.gen.ts +++ b/frontend/client/services.gen.ts @@ -1,219 +1,535 @@ // 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, + 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"; export const client = createClient(createConfig()); /** * Sign Up */ -export const signUpAuthSignupPost = (options: Options) => { return (options?.client ?? client).post({ +export const signUpAuthSignupPost = ( + options: Options, +) => { + return (options?.client ?? client).post< + SignUpAuthSignupPostResponse, + SignUpAuthSignupPostError, + ThrowOnError + >({ ...options, - url: '/auth/signup' -}); }; + url: "/auth/signup", + }); +}; /** * Log In */ -export const logInAuthLoginPost = (options: Options) => { return (options?.client ?? client).post({ +export const logInAuthLoginPost = ( + options: Options, +) => { + return (options?.client ?? client).post< + LogInAuthLoginPostResponse, + LogInAuthLoginPostError, + ThrowOnError + >({ ...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 = (options?: Options) => { return (options?.client ?? client).get({ +export const loginGoogleAuthLoginGoogleGet = < + ThrowOnError extends boolean = false, +>( + options?: Options, +) => { + return (options?.client ?? client).get< + LoginGoogleAuthLoginGoogleGetResponse, + LoginGoogleAuthLoginGoogleGetError, + ThrowOnError + >({ ...options, - url: '/auth/login/google' -}); }; + url: "/auth/login/google", + }); +}; /** * Auth Google */ -export const authGoogleAuthGoogleGet = (options: Options) => { return (options?.client ?? client).get({ +export const authGoogleAuthGoogleGet = ( + options: Options, +) => { + return (options?.client ?? client).get< + AuthGoogleAuthGoogleGetResponse, + AuthGoogleAuthGoogleGetError, + ThrowOnError + >({ ...options, - url: '/auth/google' -}); }; + url: "/auth/google", + }); +}; /** * Get User */ -export const getUserAuthSessionGet = (options?: Options) => { return (options?.client ?? client).get({ +export const getUserAuthSessionGet = ( + options?: Options, +) => { + return (options?.client ?? client).get< + GetUserAuthSessionGetResponse, + GetUserAuthSessionGetError, + ThrowOnError + >({ ...options, - url: '/auth/session' -}); }; + url: "/auth/session", + }); +}; /** * Logout */ -export const logoutAuthLogoutGet = (options?: Options) => { return (options?.client ?? client).get({ +export const logoutAuthLogoutGet = ( + options?: Options, +) => { + return (options?.client ?? client).get< + LogoutAuthLogoutGetResponse, + LogoutAuthLogoutGetError, + ThrowOnError + >({ ...options, - url: '/auth/logout' -}); }; + url: "/auth/logout", + }); +}; /** * Request Password Reset */ -export const requestPasswordResetAuthPasswordResetPost = (options: Options) => { return (options?.client ?? client).post({ +export const requestPasswordResetAuthPasswordResetPost = < + ThrowOnError extends boolean = false, +>( + options: Options, +) => { + return (options?.client ?? client).post< + RequestPasswordResetAuthPasswordResetPostResponse, + RequestPasswordResetAuthPasswordResetPostError, + ThrowOnError + >({ ...options, - url: '/auth/password-reset' -}); }; + url: "/auth/password-reset", + }); +}; /** * Complete Password Reset */ -export const completePasswordResetAuthPasswordResetPut = (options: Options) => { return (options?.client ?? client).put({ +export const completePasswordResetAuthPasswordResetPut = < + ThrowOnError extends boolean = false, +>( + options: Options, +) => { + return (options?.client ?? client).put< + CompletePasswordResetAuthPasswordResetPutResponse, + CompletePasswordResetAuthPasswordResetPutError, + ThrowOnError + >({ ...options, - url: '/auth/password-reset' -}); }; + url: "/auth/password-reset", + }); +}; /** * Change Password */ -export const changePasswordAuthChangePasswordPut = (options: Options) => { return (options?.client ?? client).put({ +export const changePasswordAuthChangePasswordPut = < + ThrowOnError extends boolean = false, +>( + options: Options, +) => { + return (options?.client ?? client).put< + ChangePasswordAuthChangePasswordPutResponse, + ChangePasswordAuthChangePasswordPutError, + ThrowOnError + >({ ...options, - url: '/auth/change-password' -}); }; + url: "/auth/change-password", + }); +}; /** * Get Categories */ -export const getCategoriesCategoriesGet = (options?: Options) => { return (options?.client ?? client).get({ +export const getCategoriesCategoriesGet = < + ThrowOnError extends boolean = false, +>( + options?: Options, +) => { + return (options?.client ?? client).get< + GetCategoriesCategoriesGetResponse, + GetCategoriesCategoriesGetError, + ThrowOnError + >({ ...options, - url: '/categories/' -}); }; + url: "/categories/", + }); +}; /** * Update Profile */ -export const updateProfileProfilePut = (options: Options) => { return (options?.client ?? client).put({ +export const updateProfileProfilePut = ( + options: Options, +) => { + return (options?.client ?? client).put< + UpdateProfileProfilePutResponse, + UpdateProfileProfilePutError, + ThrowOnError + >({ ...options, - url: '/profile/' -}); }; + url: "/profile/", + }); +}; /** * Get Events */ -export const getEventsEventsGet = (options?: Options) => { return (options?.client ?? client).get({ +export const getEventsEventsGet = ( + options?: Options, +) => { + return (options?.client ?? client).get< + GetEventsEventsGetResponse, + GetEventsEventsGetError, + ThrowOnError + >({ ...options, - url: '/events/' -}); }; + url: "/events/", + }); +}; /** * Get Event */ -export const getEventEventsIdGet = (options: Options) => { return (options?.client ?? client).get({ +export const getEventEventsIdGet = ( + options: Options, +) => { + return (options?.client ?? client).get< + GetEventEventsIdGetResponse, + GetEventEventsIdGetError, + ThrowOnError + >({ ...options, - url: '/events/{id}' -}); }; + url: "/events/{id}", + }); +}; /** * Get Event Notes */ -export const getEventNotesEventsIdNotesGet = (options: Options) => { return (options?.client ?? client).get({ +export const getEventNotesEventsIdNotesGet = < + ThrowOnError extends boolean = false, +>( + options: Options, +) => { + return (options?.client ?? client).get< + GetEventNotesEventsIdNotesGetResponse, + GetEventNotesEventsIdNotesGetError, + ThrowOnError + >({ ...options, - url: '/events/{id}/notes' -}); }; + url: "/events/{id}/notes", + }); +}; /** * Read Event */ -export const readEventEventsIdReadPost = (options: Options) => { return (options?.client ?? client).post({ +export const readEventEventsIdReadPost = ( + options: Options, +) => { + return (options?.client ?? client).post< + ReadEventEventsIdReadPostResponse, + ReadEventEventsIdReadPostError, + ThrowOnError + >({ ...options, - url: '/events/{id}/read' -}); }; + url: "/events/{id}/read", + }); +}; /** * Search Whatever */ -export const searchWhateverEventsSearchGet = (options: Options) => { return (options?.client ?? client).get({ +export const searchWhateverEventsSearchGet = < + ThrowOnError extends boolean = false, +>( + options: Options, +) => { + return (options?.client ?? client).get< + SearchWhateverEventsSearchGetResponse, + SearchWhateverEventsSearchGetError, + ThrowOnError + >({ ...options, - url: '/events/search' -}); }; + url: "/events/search", + }); +}; /** * Get User Questions */ -export const getUserQuestionsUserQuestionsGet = (options?: Options) => { return (options?.client ?? client).get({ +export const getUserQuestionsUserQuestionsGet = < + ThrowOnError extends boolean = false, +>( + options?: Options, +) => { + return (options?.client ?? client).get< + GetUserQuestionsUserQuestionsGetResponse, + GetUserQuestionsUserQuestionsGetError, + ThrowOnError + >({ ...options, - url: '/user-questions/' -}); }; + url: "/user-questions/", + }); +}; /** * Create User Question */ -export const createUserQuestionUserQuestionsPost = (options: Options) => { return (options?.client ?? client).post({ +export const createUserQuestionUserQuestionsPost = < + ThrowOnError extends boolean = false, +>( + options: Options, +) => { + return (options?.client ?? client).post< + CreateUserQuestionUserQuestionsPostResponse, + CreateUserQuestionUserQuestionsPostError, + ThrowOnError + >({ ...options, - url: '/user-questions/' -}); }; + url: "/user-questions/", + }); +}; /** * Get User Question */ -export const getUserQuestionUserQuestionsIdGet = (options: Options) => { return (options?.client ?? client).get({ +export const getUserQuestionUserQuestionsIdGet = < + ThrowOnError extends boolean = false, +>( + options: Options, +) => { + return (options?.client ?? client).get< + GetUserQuestionUserQuestionsIdGetResponse, + GetUserQuestionUserQuestionsIdGetError, + ThrowOnError + >({ ...options, - url: '/user-questions/{id}' -}); }; + url: "/user-questions/{id}", + }); +}; /** * Ask Gp Question */ -export const askGpQuestionUserQuestionsAskGpQuestionGet = (options: Options) => { return (options?.client ?? client).get({ +export const askGpQuestionUserQuestionsAskGpQuestionGet = < + ThrowOnError extends boolean = false, +>( + options: Options< + AskGpQuestionUserQuestionsAskGpQuestionGetData, + ThrowOnError + >, +) => { + return (options?.client ?? client).get< + AskGpQuestionUserQuestionsAskGpQuestionGetResponse, + AskGpQuestionUserQuestionsAskGpQuestionGetError, + ThrowOnError + >({ ...options, - url: '/user-questions/ask-gp-question' -}); }; + url: "/user-questions/ask-gp-question", + }); +}; /** * Get All Notes */ -export const getAllNotesNotesGet = (options?: Options) => { return (options?.client ?? client).get({ +export const getAllNotesNotesGet = ( + options?: Options, +) => { + return (options?.client ?? client).get< + GetAllNotesNotesGetResponse, + GetAllNotesNotesGetError, + ThrowOnError + >({ ...options, - url: '/notes/' -}); }; + url: "/notes/", + }); +}; /** * Create Note */ -export const createNoteNotesPost = (options: Options) => { return (options?.client ?? client).post({ +export const createNoteNotesPost = ( + options: Options, +) => { + return (options?.client ?? client).post< + CreateNoteNotesPostResponse, + CreateNoteNotesPostError, + ThrowOnError + >({ ...options, - url: '/notes/' -}); }; + url: "/notes/", + }); +}; /** * Update Note */ -export const updateNoteNotesIdPut = (options: Options) => { return (options?.client ?? client).put({ +export const updateNoteNotesIdPut = ( + options: Options, +) => { + return (options?.client ?? client).put< + UpdateNoteNotesIdPutResponse, + UpdateNoteNotesIdPutError, + ThrowOnError + >({ ...options, - url: '/notes/{id}' -}); }; + url: "/notes/{id}", + }); +}; /** * Delete Note */ -export const deleteNoteNotesIdDelete = (options: Options) => { return (options?.client ?? client).delete({ +export const deleteNoteNotesIdDelete = ( + options: Options, +) => { + return (options?.client ?? client).delete< + DeleteNoteNotesIdDeleteResponse, + DeleteNoteNotesIdDeleteError, + ThrowOnError + >({ ...options, - url: '/notes/{id}' -}); }; + url: "/notes/{id}", + }); +}; /** * Get Point Notes */ -export const getPointNotesPointsIdNotesGet = (options?: Options) => { return (options?.client ?? client).get({ +export const getPointNotesPointsIdNotesGet = < + ThrowOnError extends boolean = false, +>( + options?: Options, +) => { + return (options?.client ?? client).get< + GetPointNotesPointsIdNotesGetResponse, + GetPointNotesPointsIdNotesGetError, + ThrowOnError + >({ ...options, - url: '/points/{id}/notes' -}); }; + url: "/points/{id}/notes", + }); +}; /** * Upsert Like */ -export const upsertLikeLikesPost = (options: Options) => { return (options?.client ?? client).post({ +export const upsertLikeLikesPost = ( + options: Options, +) => { + return (options?.client ?? client).post< + UpsertLikeLikesPostResponse, + UpsertLikeLikesPostError, + ThrowOnError + >({ ...options, - url: '/likes/' -}); }; \ No newline at end of file + url: "/likes/", + }); +}; diff --git a/frontend/client/types.gen.ts b/frontend/client/types.gen.ts index b3230e7b..41937891 100644 --- a/frontend/client/types.gen.ts +++ b/frontend/client/types.gen.ts @@ -1,407 +1,411 @@ // 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 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 PointMiniDTO = { - id: number; - title: string; - body: string; - analysises: Array; + id: number; + title: string; + body: string; + analysises: Array; }; export type ProfileUpdate = { - category_ids: Array<(number)>; + category_ids: Array; }; 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; + id: number; + email: string; + categories: Array; }; export type UserQuestionMiniDTO = { - id: number; - question: string; - answer: AnswerDTO; + id: number; + question: string; + answer: AnswerDTO; }; export type ValidationError = { - loc: Array<(string | number)>; - msg: string; - type: string; + loc: Array; + 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<(number)> | null); - end_date?: (string | null); - limit?: (number | null); - offset?: (number | null); - start_date?: (string | null); - }; + query?: { + category_ids?: Array | 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; - }; + path: { + id: number; + }; }; -export type GetUserQuestionUserQuestionsIdGetResponse = (UserQuestionMiniDTO); +export type GetUserQuestionUserQuestionsIdGetResponse = UserQuestionMiniDTO; -export type GetUserQuestionUserQuestionsIdGetError = (HTTPValidationError); +export type GetUserQuestionUserQuestionsIdGetError = HTTPValidationError; export type AskGpQuestionUserQuestionsAskGpQuestionGetData = { - query: { - question: string; - }; + query: { + question: string; + }; }; -export type AskGpQuestionUserQuestionsAskGpQuestionGetResponse = (unknown); +export type AskGpQuestionUserQuestionsAskGpQuestionGetResponse = unknown; -export type AskGpQuestionUserQuestionsAskGpQuestionGetError = (HTTPValidationError); +export type AskGpQuestionUserQuestionsAskGpQuestionGetError = + 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); \ No newline at end of file +export type UpsertLikeLikesPostError = HTTPValidationError; diff --git a/frontend/components/layout/app-layout.tsx b/frontend/components/layout/app-layout.tsx index 1114f20e..0b064bf7 100644 --- a/frontend/components/layout/app-layout.tsx +++ b/frontend/components/layout/app-layout.tsx @@ -86,20 +86,20 @@ const AppLayout = ({ children }: { children: ReactNode }) => { const isOnboarding = pathname === "/onboarding"; return ( -
+
-
+
{isOnboarding ? ( children ) : ( {isLoggedIn && ( <> setIsCollapsed(true)} onExpand={() => setIsCollapsed(false)} @@ -111,10 +111,12 @@ const AppLayout = ({ children }: { children: ReactNode }) => { )} - -
- {children} -
+ + {children}
)} diff --git a/frontend/components/navigation/navbar.tsx b/frontend/components/navigation/navbar.tsx index 64652a4c..88e29c5a 100644 --- a/frontend/components/navigation/navbar.tsx +++ b/frontend/components/navigation/navbar.tsx @@ -35,8 +35,8 @@ function Navbar() { }, [userProfile, isUserProfileSuccess, setLoggedIn, setNotLoggedIn]); return ( -
-
+
+
diff --git a/frontend/components/navigation/scroll-to-top-button.tsx b/frontend/components/navigation/scroll-to-top-button.tsx new file mode 100644 index 00000000..dc69fef3 --- /dev/null +++ b/frontend/components/navigation/scroll-to-top-button.tsx @@ -0,0 +1,62 @@ +import { useEffect, useState } from "react"; +import { ArrowUpIcon } from "lucide-react"; + +import { Button, ButtonProps } from "@/components/ui/button"; +import { cn } from "@/lib/utils"; + +interface ScrollToTopButtonProps extends Omit { + scrollElementId: string; + minHeight?: number; + scrollTo?: number; +} + +// Adapted fom https://github.com/shadcn-ui/ui/issues/4048 +const ScrollToTopButton = ({ + scrollElementId, + className, + minHeight = 0, // Height to go on scroll to top + scrollTo = 0, + ...props +}: ScrollToTopButtonProps) => { + const scrollElement = document.querySelector(`#${scrollElementId}`); + const [visible, setVisible] = useState(false); + + const onScrollBack = () => + scrollElement?.scrollTo({ top: scrollTo, behavior: "smooth" }); + + useEffect(() => { + if (scrollElement === null) return; + if (scrollElement.scrollTop === undefined) return; + + const onScroll = () => setVisible(scrollElement.scrollTop >= minHeight); + onScroll(); + scrollElement.addEventListener("scroll", onScroll); + return () => scrollElement.removeEventListener("scroll", onScroll); + }, [scrollElement, minHeight]); + + return ( + <> + {visible && ( + + )} + + ); +}; + +export default ScrollToTopButton; diff --git a/frontend/components/navigation/sidebar/sidebar-item-with-icon.tsx b/frontend/components/navigation/sidebar/sidebar-item-with-icon.tsx index d829e378..d796b841 100644 --- a/frontend/components/navigation/sidebar/sidebar-item-with-icon.tsx +++ b/frontend/components/navigation/sidebar/sidebar-item-with-icon.tsx @@ -1,5 +1,4 @@ import { LucideIcon } from "lucide-react"; - interface SidebarItemWithIconProps { Icon: LucideIcon; label: string; @@ -15,19 +14,15 @@ const SidebarItemWithIcon = ({ }: SidebarItemWithIconProps) => { return (
- - {label} - + {label}
); }; diff --git a/frontend/components/navigation/sidebar/sidebar-other-topics.tsx b/frontend/components/navigation/sidebar/sidebar-other-topics.tsx index 7f03a34b..b05c4040 100644 --- a/frontend/components/navigation/sidebar/sidebar-other-topics.tsx +++ b/frontend/components/navigation/sidebar/sidebar-other-topics.tsx @@ -1,7 +1,7 @@ "use client"; import { createElement, useState } from "react"; -import { useRouter } from "next/navigation"; +import { usePathname, useRouter } from "next/navigation"; import { useQuery } from "@tanstack/react-query"; import { ChevronsDownUpIcon, ChevronsUpDownIcon } from "lucide-react"; @@ -16,6 +16,11 @@ const SidebarOtherTopics = () => { const [isExpanded, setIsExpanded] = useState(true); const numTopics = categories?.length; + const pathname = usePathname(); + const segments = pathname.slice(1).split("/"); + const isCategoryUrl = segments[0] === "categories"; + const activeCategoryId = segments[1]; + return (
@@ -37,6 +42,9 @@ const SidebarOtherTopics = () => { // TODO: active category { const router = useRouter(); + const pathname = usePathname(); + return (
{/* TODO: active category */} router.push("/")} /> diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 89a830d6..8d8726cf 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -38,6 +38,7 @@ "react-resizable-panels": "^2.1.3", "tailwind-merge": "^2.5.2", "tailwindcss-animate": "^1.0.7", + "tailwindcss-animated": "^1.1.2", "usehooks-ts": "^3.1.0", "zod": "^3.23.8", "zustand": "^5.0.0-rc.2" @@ -7521,6 +7522,15 @@ "tailwindcss": ">=3.0.0 || insiders" } }, + "node_modules/tailwindcss-animated": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/tailwindcss-animated/-/tailwindcss-animated-1.1.2.tgz", + "integrity": "sha512-SI4owS5ojserhgEYIZA/uFVdNjU2GMB2P3sjtjmFA52VxoUi+Hht6oR5+RdT+CxrX9cNNYEa+vbTWHvN9zbj3w==", + "license": "MIT", + "peerDependencies": { + "tailwindcss": ">=3.1.0" + } + }, "node_modules/tapable": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", diff --git a/frontend/package.json b/frontend/package.json index 4533ba14..62bb2acd 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -40,6 +40,7 @@ "react-resizable-panels": "^2.1.3", "tailwind-merge": "^2.5.2", "tailwindcss-animate": "^1.0.7", + "tailwindcss-animated": "^1.1.2", "usehooks-ts": "^3.1.0", "zod": "^3.23.8", "zustand": "^5.0.0-rc.2" diff --git a/frontend/tailwind.config.ts b/frontend/tailwind.config.ts index e340d01c..fb079f58 100644 --- a/frontend/tailwind.config.ts +++ b/frontend/tailwind.config.ts @@ -162,6 +162,6 @@ const config: Config = { }, }, // eslint-disable-next-line @typescript-eslint/no-require-imports - plugins: [require("tailwindcss-animate")], + plugins: [require("tailwindcss-animate"), require("tailwindcss-animated")], }; export default config;