🏷️fix types

This commit is contained in:
Fred KISSIE
2026-01-15 03:46:25 +01:00
parent b76a50238e
commit 9749a272ec
3 changed files with 33 additions and 43 deletions

View File

@@ -1,4 +1,4 @@
import { ApprovalFeed } from "@app/components/ApprovalFeed"; import { ApprovalFeed, type ApprovalItem } from "@app/components/ApprovalFeed";
import SettingsSectionTitle from "@app/components/SettingsSectionTitle"; import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
import { internal } from "@app/lib/api"; import { internal } from "@app/lib/api";
import { authCookieHeader } from "@app/lib/api/cookies"; import { authCookieHeader } from "@app/lib/api/cookies";
@@ -12,19 +12,6 @@ export interface ApprovalFeedPageProps {
params: Promise<{ orgId: string }>; params: Promise<{ orgId: string }>;
} }
type ApprovalItem = {
approvalId: number;
orgId: string;
clientId: number | null;
decision: "pending" | "approved" | "denied";
type: "user_device";
user: {
name: string | null;
userId: string;
username: string;
};
};
export default async function ApprovalFeedPage(props: ApprovalFeedPageProps) { export default async function ApprovalFeedPage(props: ApprovalFeedPageProps) {
const params = await props.params; const params = await props.params;

View File

@@ -1,5 +1,6 @@
"use client"; "use client";
import AutoProvisionConfigWidget from "@app/components/private/AutoProvisionConfigWidget";
import { import {
SettingsContainer, SettingsContainer,
SettingsSection, SettingsSection,
@@ -10,6 +11,10 @@ import {
SettingsSectionHeader, SettingsSectionHeader,
SettingsSectionTitle SettingsSectionTitle
} from "@app/components/Settings"; } from "@app/components/Settings";
import HeaderTitle from "@app/components/SettingsSectionTitle";
import { StrategySelect } from "@app/components/StrategySelect";
import { Alert, AlertDescription, AlertTitle } from "@app/components/ui/alert";
import { Button } from "@app/components/ui/button";
import { import {
Form, Form,
FormControl, FormControl,
@@ -19,29 +24,21 @@ import {
FormLabel, FormLabel,
FormMessage FormMessage
} from "@app/components/ui/form"; } from "@app/components/ui/form";
import HeaderTitle from "@app/components/SettingsSectionTitle";
import { z } from "zod";
import { createElement, useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { Input } from "@app/components/ui/input"; import { Input } from "@app/components/ui/input";
import { Button } from "@app/components/ui/button";
import { createApiClient, formatAxiosError } from "@app/lib/api";
import { useEnvContext } from "@app/hooks/useEnvContext"; import { useEnvContext } from "@app/hooks/useEnvContext";
import { toast } from "@app/hooks/useToast";
import { useParams, useRouter } from "next/navigation";
import { Checkbox } from "@app/components/ui/checkbox";
import { Alert, AlertDescription, AlertTitle } from "@app/components/ui/alert";
import { InfoIcon, ExternalLink } from "lucide-react";
import { StrategySelect } from "@app/components/StrategySelect";
import { SwitchInput } from "@app/components/SwitchInput";
import { Badge } from "@app/components/ui/badge";
import { useLicenseStatusContext } from "@app/hooks/useLicenseStatusContext"; import { useLicenseStatusContext } from "@app/hooks/useLicenseStatusContext";
import { toast } from "@app/hooks/useToast";
import { createApiClient, formatAxiosError } from "@app/lib/api";
import { zodResolver } from "@hookform/resolvers/zod";
import { ListRolesResponse } from "@server/routers/role";
import { AxiosResponse } from "axios";
import { InfoIcon } from "lucide-react";
import { useTranslations } from "next-intl"; import { useTranslations } from "next-intl";
import Image from "next/image"; import Image from "next/image";
import AutoProvisionConfigWidget from "@app/components/private/AutoProvisionConfigWidget"; import { useParams, useRouter } from "next/navigation";
import { AxiosResponse } from "axios"; import { useEffect, useState } from "react";
import { ListRolesResponse } from "@server/routers/role"; import { useForm } from "react-hook-form";
import { z } from "zod";
export default function Page() { export default function Page() {
const { env } = useEnvContext(); const { env } = useEnvContext();

View File

@@ -4,12 +4,7 @@ import { toast } from "@app/hooks/useToast";
import { createApiClient, formatAxiosError } from "@app/lib/api"; import { createApiClient, formatAxiosError } from "@app/lib/api";
import { cn } from "@app/lib/cn"; import { cn } from "@app/lib/cn";
import { approvalFiltersSchema, approvalQueries } from "@app/lib/queries"; import { approvalFiltersSchema, approvalQueries } from "@app/lib/queries";
import type {
ListApprovalsResponse,
ProcessApprovalResponse
} from "@server/private/routers/approvals";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import type { AxiosResponse } from "axios";
import { ArrowRight, Ban, Check, LaptopMinimal, RefreshCw } from "lucide-react"; import { ArrowRight, Ban, Check, LaptopMinimal, RefreshCw } from "lucide-react";
import { useTranslations } from "next-intl"; import { useTranslations } from "next-intl";
import Link from "next/link"; import Link from "next/link";
@@ -28,6 +23,19 @@ import {
} from "./ui/select"; } from "./ui/select";
import { Separator } from "./ui/separator"; import { Separator } from "./ui/separator";
export type ApprovalItem = {
approvalId: number;
orgId: string;
clientId: number | null;
decision: "pending" | "approved" | "denied";
type: "user_device";
user: {
name: string | null;
userId: string;
username: string;
};
};
export type ApprovalFeedProps = { export type ApprovalFeedProps = {
orgId: string; orgId: string;
}; };
@@ -140,9 +148,9 @@ export function ApprovalFeed({ orgId }: ApprovalFeedProps) {
} }
type ApprovalRequestProps = { type ApprovalRequestProps = {
approval: ListApprovalsResponse["approvals"][number]; approval: ApprovalItem;
orgId: string; orgId: string;
onSuccess?: (data: ProcessApprovalResponse) => void; onSuccess?: () => void;
}; };
function ApprovalRequest({ approval, orgId, onSuccess }: ApprovalRequestProps) { function ApprovalRequest({ approval, orgId, onSuccess }: ApprovalRequestProps) {
@@ -154,9 +162,7 @@ function ApprovalRequest({ approval, orgId, onSuccess }: ApprovalRequestProps) {
async function onSubmit(_previousState: any, formData: FormData) { async function onSubmit(_previousState: any, formData: FormData) {
const decision = formData.get("decision"); const decision = formData.get("decision");
const res = await api const res = await api
.put< .put(`/org/${orgId}/approvals/${approval.approvalId}`, { decision })
AxiosResponse<ProcessApprovalResponse>
>(`/org/${orgId}/approvals/${approval.approvalId}`, { decision })
.catch((e) => { .catch((e) => {
toast({ toast({
variant: "destructive", variant: "destructive",
@@ -178,7 +184,7 @@ function ApprovalRequest({ approval, orgId, onSuccess }: ApprovalRequestProps) {
: t("accessApprovalDeniedDescription") : t("accessApprovalDeniedDescription")
}); });
onSuccess?.(res.data.data); onSuccess?.();
} }
} }