mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 12:38:36 +00:00
Add eslint rule and fix as many issues as possible
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useRouter } from 'next/router';
|
||||
import queryString from 'query-string';
|
||||
import { useEffect, useState } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
import queryString from "query-string";
|
||||
|
||||
import {
|
||||
Button,
|
||||
@@ -10,36 +10,36 @@ import {
|
||||
Input,
|
||||
Select,
|
||||
SelectItem
|
||||
} from '../../../components/v2';
|
||||
} from "../../../components/v2";
|
||||
import {
|
||||
useGetIntegrationAuthApps,
|
||||
useGetIntegrationAuthById,
|
||||
useGetIntegrationAuthVercelBranches
|
||||
} from '../../../hooks/api/integrationAuth';
|
||||
import { useGetWorkspaceById } from '../../../hooks/api/workspace';
|
||||
import createIntegration from '../../api/integrations/createIntegration';
|
||||
} from "../../../hooks/api/integrationAuth";
|
||||
import { useGetWorkspaceById } from "../../../hooks/api/workspace";
|
||||
import createIntegration from "../../api/integrations/createIntegration";
|
||||
|
||||
const vercelEnvironments = [
|
||||
{ name: 'Development', slug: 'development' },
|
||||
{ name: 'Preview', slug: 'preview' },
|
||||
{ name: 'Production', slug: 'production' }
|
||||
{ name: "Development", slug: "development" },
|
||||
{ name: "Preview", slug: "preview" },
|
||||
{ name: "Production", slug: "production" }
|
||||
];
|
||||
|
||||
export default function VercelCreateIntegrationPage() {
|
||||
const router = useRouter();
|
||||
|
||||
const [selectedSourceEnvironment, setSelectedSourceEnvironment] = useState('');
|
||||
const [secretPath, setSecretPath] = useState('/');
|
||||
const [targetAppId, setTargetAppId] = useState('');
|
||||
const [targetEnvironment, setTargetEnvironment] = useState('');
|
||||
const [targetBranch, setTargetBranch] = useState('');
|
||||
const [selectedSourceEnvironment, setSelectedSourceEnvironment] = useState("");
|
||||
const [secretPath, setSecretPath] = useState("/");
|
||||
const [targetAppId, setTargetAppId] = useState("");
|
||||
const [targetEnvironment, setTargetEnvironment] = useState("");
|
||||
const [targetBranch, setTargetBranch] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const { integrationAuthId } = queryString.parse(router.asPath.split('?')[1]);
|
||||
const { data: workspace } = useGetWorkspaceById(localStorage.getItem('projectData.id') ?? '');
|
||||
const { data: integrationAuth } = useGetIntegrationAuthById((integrationAuthId as string) ?? '');
|
||||
const { integrationAuthId } = queryString.parse(router.asPath.split("?")[1]);
|
||||
const { data: workspace } = useGetWorkspaceById(localStorage.getItem("projectData.id") ?? "");
|
||||
const { data: integrationAuth } = useGetIntegrationAuthById((integrationAuthId as string) ?? "");
|
||||
const { data: integrationAuthApps } = useGetIntegrationAuthApps({
|
||||
integrationAuthId: (integrationAuthId as string) ?? ''
|
||||
integrationAuthId: (integrationAuthId as string) ?? ""
|
||||
});
|
||||
|
||||
const { data: branches } = useGetIntegrationAuthVercelBranches({
|
||||
@@ -47,7 +47,7 @@ export default function VercelCreateIntegrationPage() {
|
||||
appId: targetAppId
|
||||
});
|
||||
|
||||
const filteredBranches = branches?.filter((branchName) => branchName !== 'main').concat('');
|
||||
const filteredBranches = branches?.filter((branchName) => branchName !== "main").concat("");
|
||||
|
||||
useEffect(() => {
|
||||
if (workspace) {
|
||||
@@ -61,7 +61,7 @@ export default function VercelCreateIntegrationPage() {
|
||||
setTargetAppId(integrationAuthApps[0].appId as string);
|
||||
setTargetEnvironment(vercelEnvironments[0].slug);
|
||||
} else {
|
||||
setTargetAppId('none');
|
||||
setTargetAppId("none");
|
||||
setTargetEnvironment(vercelEnvironments[0].slug);
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ export default function VercelCreateIntegrationPage() {
|
||||
|
||||
if (!targetApp || !targetApp.appId) return;
|
||||
|
||||
const path = targetEnvironment === 'preview' && targetBranch !== '' ? targetBranch : null;
|
||||
const path = targetEnvironment === "preview" && targetBranch !== "" ? targetBranch : null;
|
||||
|
||||
await createIntegration({
|
||||
integrationAuthId: integrationAuth?._id,
|
||||
@@ -98,7 +98,7 @@ export default function VercelCreateIntegrationPage() {
|
||||
});
|
||||
|
||||
setIsLoading(false);
|
||||
router.push(`/integrations/${localStorage.getItem('projectData.id')}`);
|
||||
router.push(`/integrations/${localStorage.getItem("projectData.id")}`);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
@@ -175,7 +175,7 @@ export default function VercelCreateIntegrationPage() {
|
||||
))}
|
||||
</Select>
|
||||
</FormControl>
|
||||
{targetEnvironment === 'preview' && filteredBranches && (
|
||||
{targetEnvironment === "preview" && filteredBranches && (
|
||||
<FormControl label="Vercel Preview Branch (Optional)">
|
||||
<Select
|
||||
value={targetBranch}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useRouter } from 'next/router';
|
||||
import queryString from 'query-string';
|
||||
import { useEffect } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
import queryString from "query-string";
|
||||
|
||||
import AuthorizeIntegration from '../../../api/integrations/authorizeIntegration';
|
||||
import AuthorizeIntegration from "../../../api/integrations/authorizeIntegration";
|
||||
|
||||
export default function VercelOAuth2CallbackPage() {
|
||||
const router = useRouter();
|
||||
|
||||
const { code, state } = queryString.parse(router.asPath.split('?')[1]);
|
||||
const { code, state } = queryString.parse(router.asPath.split("?")[1]);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
// validate state
|
||||
if (state !== localStorage.getItem('latestCSRFToken')) return;
|
||||
localStorage.removeItem('latestCSRFToken');
|
||||
if (state !== localStorage.getItem("latestCSRFToken")) return;
|
||||
localStorage.removeItem("latestCSRFToken");
|
||||
|
||||
const integrationAuth = await AuthorizeIntegration({
|
||||
workspaceId: localStorage.getItem('projectData.id') as string,
|
||||
workspaceId: localStorage.getItem("projectData.id") as string,
|
||||
code: code as string,
|
||||
integration: 'vercel'
|
||||
integration: "vercel"
|
||||
});
|
||||
|
||||
router.push(`/integrations/vercel/create?integrationAuthId=${integrationAuth._id}`);
|
||||
|
||||
Reference in New Issue
Block a user