From 8a02972558e3a10354ab67a5c72467fb466a867e Mon Sep 17 00:00:00 2001 From: Julian Kepka Date: Mon, 13 Jul 2026 15:06:41 +0200 Subject: [PATCH 1/4] feat: github issue resolve --- src/components/OrgForm.tsx | 58 +++++++++++++++++++++++--------------- src/config.ts | 2 +- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/components/OrgForm.tsx b/src/components/OrgForm.tsx index 93bbcaff0..488ef7d95 100644 --- a/src/components/OrgForm.tsx +++ b/src/components/OrgForm.tsx @@ -2,31 +2,45 @@ import type { FunctionComponent } from "react"; import Section from "./common/Section"; import { FormControl, FormField, FormItem, FormLabel } from "./ui/form"; import { Input } from "./ui/input"; +import { InputWithButton } from "./ui/input-with-button"; +import { useActiveOrg } from "@/hooks/useActiveOrg"; interface OrgFormProps { forceVertical?: boolean; } - export const OrgForm: FunctionComponent = ({ forceVertical = true, -}) => ( -
-
- ( - - Organization name* - - - - - )} - /> -
-
-); +}) => { + const activeOrg = useActiveOrg(); + const orgID = activeOrg.id; + + return ( +
+
+ ( + + Organization name* + + + + + )} + /> + +
+
+ ); +}; diff --git a/src/config.ts b/src/config.ts index 690788e57..4dd9d8791 100644 --- a/src/config.ts +++ b/src/config.ts @@ -34,7 +34,7 @@ export const config = { "https://gitlab.com/l3montree/devguard/-/raw/main", devguardGithubAppUrl: process.env.DEVGUARD_API_URL_PUBLIC_INTERNET?.includes( "main.devguard.org", - ) + ) || process.env.DEVGUARD_API_URL_PUBLIC_INTERNET?.includes("localhost") ? "devguard-bot-dev" : "devguard-bot", enforceTheme: (process.env.ENFORCE_THEME || false) as From 67bfed037c583bfd5af19da548a14d205efa5343 Mon Sep 17 00:00:00 2001 From: Julian Kepka Date: Tue, 14 Jul 2026 15:22:23 +0200 Subject: [PATCH 2/4] fix: e2e test --- src/components/OrgForm.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/OrgForm.tsx b/src/components/OrgForm.tsx index 488ef7d95..c90ed5a86 100644 --- a/src/components/OrgForm.tsx +++ b/src/components/OrgForm.tsx @@ -12,7 +12,7 @@ export const OrgForm: FunctionComponent = ({ forceVertical = true, }) => { const activeOrg = useActiveOrg(); - const orgID = activeOrg.id; + const orgID = activeOrg?.id; return (
= ({ )} /> + {activeOrg && ( = ({ copyable copyToastDescription="The organization ID has been copied to your clipboard." /> + )}
); From da833b90a518170953c7e7e93cd76d8855783ab4 Mon Sep 17 00:00:00 2001 From: Julian Kepka Date: Tue, 14 Jul 2026 15:26:47 +0200 Subject: [PATCH 3/4] fix: gap --- src/components/AcceptInvitationForm.tsx | 102 ++++++++++++++++++++++++ src/components/OrgRegister.tsx | 2 +- 2 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 src/components/AcceptInvitationForm.tsx diff --git a/src/components/AcceptInvitationForm.tsx b/src/components/AcceptInvitationForm.tsx new file mode 100644 index 000000000..64bd36c4b --- /dev/null +++ b/src/components/AcceptInvitationForm.tsx @@ -0,0 +1,102 @@ +// Copyright (C) 2023 Sebastian Kawelke, l3montree UG (haftungsbeschraenkt) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +import { useRouter } from "next/navigation"; +import { useForm } from "react-hook-form"; +import type { OrganizationDTO, OrganizationDetailsDTO } from "../types/api/api"; + +import { browserApiClient } from "@/services/devGuardApi"; +import { Form } from "./ui/form"; + +import { OrgForm } from "./OrgForm"; +import { Button } from "./ui/button"; + +import { toast } from "@/lib/toast"; +import { useUpdateSession } from "@/context/SessionContext"; + +interface Props { + onHasInvitation?: () => void; +} + +export default function OrgRegisterForm({ onHasInvitation }: Props) { + const updateSession = useUpdateSession(); + const form = useForm(); + + const router = useRouter(); + const handleOrgCreation = async (data: OrganizationDTO) => { + const resp = await browserApiClient("/organizations/", { + method: "POST", + body: JSON.stringify({ + ...data, + numberOfEmployees: !!data.numberOfEmployees + ? Number(data.numberOfEmployees) + : undefined, + }), + }); + + if (resp.status !== 200) { + toast.error("Could not create organization", { + description: + "Organization creation is currently disabled or an error occurred. Please contact your administrator.", + }); + return; + } + + const orgDTO: OrganizationDetailsDTO = await resp.json(); + + updateSession((prev) => ({ + ...prev, + organizations: [...prev.organizations, orgDTO], + })); + + toast.success("Organization created successfully"); + + form.reset(); + + localStorage.setItem("lastActiveOrg", orgDTO.slug); + // move the user to the newly created organization + setTimeout(() => router.push(`/${orgDTO.slug}`), 0); + }; + + return ( +
+ + + +
+ +
+
+ +
+ + + ); +} diff --git a/src/components/OrgRegister.tsx b/src/components/OrgRegister.tsx index 4ffffa84b..3577427d8 100644 --- a/src/components/OrgRegister.tsx +++ b/src/components/OrgRegister.tsx @@ -75,7 +75,7 @@ export default function OrgRegisterForm(props: Props) { > -
+
-
-
- -
- - - ); -}