mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-18 09:00:35 +00:00
103 lines
3.5 KiB
TypeScript
103 lines
3.5 KiB
TypeScript
import { useState } from "react";
|
|
import Head from "next/head";
|
|
import Image from "next/image";
|
|
import Link from "next/link";
|
|
import { useRouter } from "next/router";
|
|
import { faArrowUpRightFromSquare, faBookOpen } from "@fortawesome/free-solid-svg-icons";
|
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
|
|
import { useSaveIntegrationAccessToken } from "@app/hooks/api";
|
|
|
|
import { Button, Card, CardTitle, FormControl, Input } from "../../../components/v2";
|
|
|
|
export default function RenderCreateIntegrationPage() {
|
|
const router = useRouter();
|
|
const { mutateAsync } = useSaveIntegrationAccessToken();
|
|
|
|
const [apiKey, setApiKey] = useState("");
|
|
const [apiKeyErrorText, setApiKeyErrorText] = useState("");
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
|
|
const handleButtonClick = async () => {
|
|
try {
|
|
setApiKeyErrorText("");
|
|
if (apiKey.length === 0) {
|
|
setApiKeyErrorText("API Key cannot be blank");
|
|
return;
|
|
}
|
|
|
|
setIsLoading(true);
|
|
|
|
const integrationAuth = await mutateAsync({
|
|
workspaceId: localStorage.getItem("projectData.id"),
|
|
integration: "render",
|
|
accessToken: apiKey
|
|
});
|
|
|
|
setIsLoading(false);
|
|
|
|
router.push(`/integrations/render/create?integrationAuthId=${integrationAuth.id}`);
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className="flex h-full w-full items-center justify-center">
|
|
<Head>
|
|
<title>Authorize Render Integration</title>
|
|
<link rel="icon" href="/infisical.ico" />
|
|
</Head>
|
|
<Card className="mb-12 max-w-lg rounded-md border border-mineshaft-600">
|
|
<CardTitle
|
|
className="px-6 text-left text-xl"
|
|
subTitle="After adding your API key, you will be prompted to set up an integration for a particular Infisical project and environment."
|
|
>
|
|
<div className="flex flex-row items-center">
|
|
<div className="inline flex items-center pb-0.5">
|
|
<Image
|
|
src="/images/integrations/Render.png"
|
|
height={30}
|
|
width={30}
|
|
alt="Render logo"
|
|
/>
|
|
</div>
|
|
<span className="ml-2.5">Render Integration </span>
|
|
<Link href="https://infisical.com/docs/integrations/cloud/render" passHref>
|
|
<a target="_blank" rel="noopener noreferrer">
|
|
<div className="ml-2 mb-1 inline-block cursor-default rounded-md bg-yellow/20 px-1.5 pb-[0.03rem] pt-[0.04rem] text-sm text-yellow opacity-80 hover:opacity-100">
|
|
<FontAwesomeIcon icon={faBookOpen} className="mr-1.5" />
|
|
Docs
|
|
<FontAwesomeIcon
|
|
icon={faArrowUpRightFromSquare}
|
|
className="ml-1.5 mb-[0.07rem] text-xxs"
|
|
/>
|
|
</div>
|
|
</a>
|
|
</Link>
|
|
</div>
|
|
</CardTitle>
|
|
<FormControl
|
|
label="Render API Key"
|
|
errorText={apiKeyErrorText}
|
|
isError={apiKeyErrorText !== "" ?? false}
|
|
className="px-6"
|
|
>
|
|
<Input placeholder="rnd_xxx" value={apiKey} onChange={(e) => setApiKey(e.target.value)} />
|
|
</FormControl>
|
|
<Button
|
|
onClick={handleButtonClick}
|
|
colorSchema="primary"
|
|
variant="outline_bg"
|
|
className="mb-6 mt-2 ml-auto mr-6 w-min"
|
|
isLoading={isLoading}
|
|
>
|
|
Connect to Render
|
|
</Button>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
RenderCreateIntegrationPage.requireAuth = true;
|