mirror of
https://github.com/fosrl/pangolin.git
synced 2026-01-28 22:00:51 +00:00
🏷️fix types
This commit is contained in:
@@ -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 { internal } from "@app/lib/api";
|
||||
import { authCookieHeader } from "@app/lib/api/cookies";
|
||||
@@ -12,19 +12,6 @@ export interface ApprovalFeedPageProps {
|
||||
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) {
|
||||
const params = await props.params;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import AutoProvisionConfigWidget from "@app/components/private/AutoProvisionConfigWidget";
|
||||
import {
|
||||
SettingsContainer,
|
||||
SettingsSection,
|
||||
@@ -10,6 +11,10 @@ import {
|
||||
SettingsSectionHeader,
|
||||
SettingsSectionTitle
|
||||
} 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 {
|
||||
Form,
|
||||
FormControl,
|
||||
@@ -19,29 +24,21 @@ import {
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} 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 { Button } from "@app/components/ui/button";
|
||||
import { createApiClient, formatAxiosError } from "@app/lib/api";
|
||||
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 { 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 Image from "next/image";
|
||||
import AutoProvisionConfigWidget from "@app/components/private/AutoProvisionConfigWidget";
|
||||
import { AxiosResponse } from "axios";
|
||||
import { ListRolesResponse } from "@server/routers/role";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
|
||||
export default function Page() {
|
||||
const { env } = useEnvContext();
|
||||
|
||||
@@ -4,12 +4,7 @@ import { toast } from "@app/hooks/useToast";
|
||||
import { createApiClient, formatAxiosError } from "@app/lib/api";
|
||||
import { cn } from "@app/lib/cn";
|
||||
import { approvalFiltersSchema, approvalQueries } from "@app/lib/queries";
|
||||
import type {
|
||||
ListApprovalsResponse,
|
||||
ProcessApprovalResponse
|
||||
} from "@server/private/routers/approvals";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import type { AxiosResponse } from "axios";
|
||||
import { ArrowRight, Ban, Check, LaptopMinimal, RefreshCw } from "lucide-react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import Link from "next/link";
|
||||
@@ -28,6 +23,19 @@ import {
|
||||
} from "./ui/select";
|
||||
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 = {
|
||||
orgId: string;
|
||||
};
|
||||
@@ -140,9 +148,9 @@ export function ApprovalFeed({ orgId }: ApprovalFeedProps) {
|
||||
}
|
||||
|
||||
type ApprovalRequestProps = {
|
||||
approval: ListApprovalsResponse["approvals"][number];
|
||||
approval: ApprovalItem;
|
||||
orgId: string;
|
||||
onSuccess?: (data: ProcessApprovalResponse) => void;
|
||||
onSuccess?: () => void;
|
||||
};
|
||||
|
||||
function ApprovalRequest({ approval, orgId, onSuccess }: ApprovalRequestProps) {
|
||||
@@ -154,9 +162,7 @@ function ApprovalRequest({ approval, orgId, onSuccess }: ApprovalRequestProps) {
|
||||
async function onSubmit(_previousState: any, formData: FormData) {
|
||||
const decision = formData.get("decision");
|
||||
const res = await api
|
||||
.put<
|
||||
AxiosResponse<ProcessApprovalResponse>
|
||||
>(`/org/${orgId}/approvals/${approval.approvalId}`, { decision })
|
||||
.put(`/org/${orgId}/approvals/${approval.approvalId}`, { decision })
|
||||
.catch((e) => {
|
||||
toast({
|
||||
variant: "destructive",
|
||||
@@ -178,7 +184,7 @@ function ApprovalRequest({ approval, orgId, onSuccess }: ApprovalRequestProps) {
|
||||
: t("accessApprovalDeniedDescription")
|
||||
});
|
||||
|
||||
onSuccess?.(res.data.data);
|
||||
onSuccess?.();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user