Merge branch 'hp-multi-client' into auth-providers-clients

This commit is contained in:
miloschwartz
2025-04-20 16:15:40 -04:00
70 changed files with 27368 additions and 159 deletions

View File

@@ -1,5 +1,4 @@
"use client";
import ConfirmDeleteDialog from "@app/components/ConfirmDeleteDialog";
import { Button } from "@app/components/ui/button";
import { useOrgContext } from "@app/hooks/useOrgContext";
@@ -22,17 +21,9 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { createApiClient } from "@app/lib/api";
import { useEnvContext } from "@app/hooks/useEnvContext";
import { formatAxiosError } from "@app/lib/api";
import { AlertTriangle, Trash2 } from "lucide-react";
import {
Card,
CardContent,
CardFooter,
CardHeader,
CardTitle
} from "@/components/ui/card";
import { AxiosResponse } from "axios";
import { DeleteOrgResponse, ListUserOrgsResponse } from "@server/routers/org";
import { redirect, useRouter } from "next/navigation";
import { useRouter } from "next/navigation";
import {
SettingsContainer,
SettingsSection,
@@ -45,15 +36,16 @@ import {
} from "@app/components/Settings";
import { useUserContext } from "@app/hooks/useUserContext";
// Updated schema to include subnet field
const GeneralFormSchema = z.object({
name: z.string()
name: z.string(),
subnet: z.string().optional()
});
type GeneralFormValues = z.infer<typeof GeneralFormSchema>;
export default function GeneralPage() {
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
const { orgUser } = userOrgUserContext();
const router = useRouter();
const { org } = useOrgContext();
@@ -66,7 +58,8 @@ export default function GeneralPage() {
const form = useForm<GeneralFormValues>({
resolver: zodResolver(GeneralFormSchema),
defaultValues: {
name: org?.org.name
name: org?.org.name,
subnet: org?.org.subnet || "" // Add default value for subnet
},
mode: "onChange"
});
@@ -77,12 +70,10 @@ export default function GeneralPage() {
const res = await api.delete<AxiosResponse<DeleteOrgResponse>>(
`/org/${org?.org.orgId}`
);
toast({
title: "Organization deleted",
description: "The organization and its data has been deleted."
});
if (res.status === 200) {
pickNewOrgAndNavigate();
}
@@ -134,14 +125,14 @@ export default function GeneralPage() {
setLoadingSave(true);
await api
.post(`/org/${org?.org.orgId}`, {
name: data.name
name: data.name,
subnet: data.subnet // Include subnet in the API request
})
.then(() => {
toast({
title: "Organization updated",
description: "The organization has been updated."
});
router.refresh();
})
.catch((e) => {
@@ -186,7 +177,6 @@ export default function GeneralPage() {
string={org?.org.name || ""}
title="Delete Organization"
/>
<SettingsSection>
<SettingsSectionHeader>
<SettingsSectionTitle>
@@ -196,7 +186,6 @@ export default function GeneralPage() {
Manage your organization details and configuration
</SettingsSectionDescription>
</SettingsSectionHeader>
<SettingsSectionBody>
<SettingsSectionForm>
<Form {...form}>
@@ -222,11 +211,30 @@ export default function GeneralPage() {
</FormItem>
)}
/>
<FormField
control={form.control}
name="subnet"
render={({ field }) => (
<FormItem>
<FormLabel>Subnet</FormLabel>
<FormControl>
<Input
{...field}
disabled={true}
/>
</FormControl>
<FormMessage />
<FormDescription>
The subnet for this organization's network configuration.
</FormDescription>
</FormItem>
)}
/>
</form>
</Form>
</SettingsSectionForm>
</SettingsSectionBody>
<SettingsSectionFooter>
<Button
type="submit"
@@ -238,7 +246,6 @@ export default function GeneralPage() {
</Button>
</SettingsSectionFooter>
</SettingsSection>
<SettingsSection>
<SettingsSectionHeader>
<SettingsSectionTitle>Danger Zone</SettingsSectionTitle>
@@ -247,7 +254,6 @@ export default function GeneralPage() {
be certain.
</SettingsSectionDescription>
</SettingsSectionHeader>
<SettingsSectionFooter>
<Button
variant="destructive"