From d2d9ef875d6b1d6cef8ee519092ca643659cfb6c Mon Sep 17 00:00:00 2001 From: Christoffer Bjelke <56649743+chribjel@users.noreply.github.com> Date: Tue, 12 Nov 2024 13:15:59 +0100 Subject: [PATCH] add support for order index (#110) --- src/config.ts | 11 ++++++++--- src/hooks/use-function.tsx | 1 + src/services/backend.ts | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/config.ts b/src/config.ts index ca86726..a0f3be8 100644 --- a/src/config.ts +++ b/src/config.ts @@ -9,12 +9,17 @@ export interface IConfig { } const defaultConfig: IConfig = { - clientId: "3e09bdb6-734c-473e-ab69-1238057dfc5d", + clientId: + import.meta.env.VITE_CLIENT_ID ?? "3e09bdb6-734c-473e-ab69-1238057dfc5d", authority: + import.meta.env.VITE_AUTHORITY ?? "https://login.microsoftonline.com/7531b79e-fd42-4826-bff2-131d82c7b557/v2.0", - redirect_uri: "http://localhost:5173", - backend_url: "https://frisk-backend.fly.dev", + redirect_uri: + import.meta.env.VITE_LOGIN_REDIRECT_URI ?? "http://localhost:5173", + backend_url: + import.meta.env.VITE_BACKEND_URL ?? "https://frisk-backend.fly.dev", regelrett_frontend_url: + import.meta.env.VITE_REGLERRETT_FRONTEND_URL ?? "https://regelrett-frontend-1024826672490.europe-north1.run.app", }; diff --git a/src/hooks/use-function.tsx b/src/hooks/use-function.tsx index 2f37fc4..53c4bf8 100644 --- a/src/hooks/use-function.tsx +++ b/src/hooks/use-function.tsx @@ -110,6 +110,7 @@ export function useFunction(functionId: number, opts?: UseFunctionOpts) { ..._newFunction.function, id: randomNegativeNumber, path: `${func.data?.path}.${randomNegativeNumber}`, + orderIndex: 999, }; await queryClient.cancelQueries({ queryKey: ["functions", newFunction.parentId, "children"], diff --git a/src/services/backend.ts b/src/services/backend.ts index 1f136d7..8434049 100644 --- a/src/services/backend.ts +++ b/src/services/backend.ts @@ -235,9 +235,13 @@ const BackendFunction = object({ description: string().nullable(), path: string(), parentId: number().int().nullable(), + orderIndex: number().int(), }); export type BackendFunction = z.infer; -type BackendFunctionCreate = Omit; +type BackendFunctionCreate = Omit< + BackendFunction, + "id" | "path" | "orderIndex" +>; export type BackendFunctionWithMetadataCreate = { function: BackendFunctionCreate; metadata: Omit[];