import { FC, useState } from "react"; // next imports import Link from "next/link"; import Image from "next/image"; // icons import GithubLogo from "public/logos/github-square.png"; import { CogIcon, CloudUploadIcon, UsersIcon, ImportLayersIcon, CheckIcon } from "components/icons"; import { ArrowLeftIcon } from "@heroicons/react/24/outline"; // components import { GithubConfigure, GithubImportData, GithubIssuesSelect, GithubUsersSelect, GithubConfirm, } from "components/integration"; // types import { IAppIntegrations } from "types"; type Props = { workspaceSlug: string | undefined; provider: string | undefined; allIntegrations: IAppIntegrations[] | undefined; allIntegrationsError: Error | undefined; allWorkspaceIntegrations: any | undefined; allWorkspaceIntegrationsError: Error | undefined; allIntegrationImporters: any | undefined; allIntegrationImportersError: Error | undefined; }; export interface IIntegrationData { state: string; } export const GithubIntegrationRoot: FC = ({ workspaceSlug, provider, allIntegrations, allIntegrationsError, allWorkspaceIntegrations, allWorkspaceIntegrationsError, allIntegrationImporters, allIntegrationImportersError, }) => { const integrationWorkflowData = [ { title: "Configure", key: "import-configure", icon: CogIcon, }, { title: "Import Data", key: "import-import-data", icon: CloudUploadIcon, }, { title: "Issues", key: "migrate-issues", icon: UsersIcon }, { title: "Users", key: "migrate-users", icon: ImportLayersIcon, }, { title: "Confirm", key: "migrate-confirm", icon: CheckIcon, }, ]; const activeIntegrationState = () => { const currentElementIndex = integrationWorkflowData.findIndex( (_item) => _item?.key === integrationData?.state ); return currentElementIndex; }; const [integrationData, setIntegrationData] = useState({ state: "import-configure", }); const handleIntegrationData = (key: string = "state", value: string) => { setIntegrationData((previousData) => ({ ...previousData, [key]: value })); }; return (
Back
GithubLogo
{integrationWorkflowData.map((_integration, _idx) => ( <>
<_integration.icon width={`18px`} height={`18px`} color={_idx <= activeIntegrationState() ? "#ffffff" : "#d1d5db"} />
{_idx < integrationWorkflowData.length - 1 && (
{" "}
)} ))}
{integrationData?.state === "import-configure" && ( )} {integrationData?.state === "import-import-data" && ( )} {integrationData?.state === "migrate-issues" && ( )} {integrationData?.state === "migrate-users" && ( )} {integrationData?.state === "migrate-confirm" && ( )}
); };