mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-24 21:11:53 +00:00
39 lines
988 B
TypeScript
39 lines
988 B
TypeScript
"use client";
|
|
|
|
import { useRouter } from "next/navigation";
|
|
import { useForm } from "react-hook-form";
|
|
|
|
import { Form } from "@/components/ui/form";
|
|
|
|
import { RadioGroupAWSViaCredentialsForm } from "../radio-group-aws-via-credentials-form";
|
|
|
|
interface SelectViaAWSProps {
|
|
initialVia?: string;
|
|
}
|
|
|
|
export const SelectViaAWS = ({ initialVia }: SelectViaAWSProps) => {
|
|
const router = useRouter();
|
|
const form = useForm({
|
|
defaultValues: {
|
|
awsCredentialsType: initialVia || "",
|
|
},
|
|
});
|
|
|
|
const handleSelectionChange = (value: string) => {
|
|
const url = new URL(window.location.href);
|
|
url.searchParams.set("via", value);
|
|
router.push(url.toString());
|
|
};
|
|
|
|
return (
|
|
<Form {...form}>
|
|
<RadioGroupAWSViaCredentialsForm
|
|
control={form.control}
|
|
isInvalid={!!form.formState.errors.awsCredentialsType}
|
|
errorMessage={form.formState.errors.awsCredentialsType?.message}
|
|
onChange={handleSelectionChange}
|
|
/>
|
|
</Form>
|
|
);
|
|
};
|