-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
185 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
"use client"; | ||
|
||
import { useState } from "react"; | ||
import { ISpace, initializeFlatfile } from "@flatfile/react"; | ||
import { Button } from "@/components/ui/button"; | ||
import { | ||
ArrowsPointingInIcon, | ||
ArrowsPointingOutIcon, | ||
} from "@heroicons/react/24/outline"; | ||
import HeaderContent from "@/app/(authenticated)/project-onboarding/header-content"; | ||
import { | ||
EMBEDDED_PORTAL_ITEM, | ||
EMBEDDED_PORTAL_INITIAL_STEPS, | ||
} from "@/lib/workflow-constants"; | ||
import { Step } from "@/components/shared/step-list"; | ||
|
||
export default function EmbeddedPortal({ | ||
flatfileSpaceId, | ||
flatfileSpaceAccessToken, | ||
}: { | ||
flatfileSpaceId: string; | ||
flatfileSpaceAccessToken: string; | ||
}) { | ||
const [showSpace, setShowSpace] = useState(false); | ||
const steps: Step[] = [ | ||
{ ...EMBEDDED_PORTAL_INITIAL_STEPS[0], status: "complete" }, | ||
{ ...EMBEDDED_PORTAL_INITIAL_STEPS[1], status: "current" }, | ||
]; | ||
|
||
const spaceProps: ISpace = { | ||
space: { | ||
id: flatfileSpaceId, | ||
accessToken: flatfileSpaceAccessToken, | ||
}, | ||
namespace: process.env.NEXT_PUBLIC_FLATFILE_NAMESPACE as string, | ||
environmentId: process.env.NEXT_PUBLIC_FLATFILE_ENVIRONMENT_ID as string, | ||
}; | ||
const { Space, OpenEmbed } = initializeFlatfile({ | ||
...spaceProps, | ||
closeSpace: { | ||
operation: "contacts:submit", | ||
onClose: () => setShowSpace(false), | ||
}, | ||
}); | ||
|
||
const onOpenSpace = async () => { | ||
setShowSpace(!showSpace); | ||
OpenEmbed(); | ||
}; | ||
|
||
return ( | ||
<div className="space-y-6"> | ||
<HeaderContent item={EMBEDDED_PORTAL_ITEM} steps={steps} /> | ||
<div className="text-white"> | ||
<p className="text-2xl mb-8 md:max-w-lg"> | ||
Your embedded Flatfile space is configured and ready for import. 🎉 | ||
</p> | ||
<div className="flex flex-col md:flex-row justify-between lg:justify-start lg:space-x-12 space-y-12 md:space-y-0"> | ||
<div className="md:max-w-md"> | ||
<p className="font-semibold mb-4">Launch Flatfile</p> | ||
<p>Launch Flatfile via the "Import" button below.</p> | ||
<p> | ||
Use the Sidebar in the embedded application to guide you through | ||
the import process! | ||
</p> | ||
<div className="mt-8"> | ||
<div className="content"> | ||
<div> | ||
<Button className="contrast" onClick={onOpenSpace}> | ||
{showSpace ? "Close Portal" : "Import Data"} | ||
{showSpace ? ( | ||
<ArrowsPointingInIcon className="w-4 h-4 ml-2" /> | ||
) : ( | ||
<ArrowsPointingOutIcon className="w-4 h-4 ml-2" /> | ||
)} | ||
</Button> | ||
{showSpace && <Space />} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
import { WorkflowType } from "@/lib/workflow-type"; | ||
import CreateSpaceForm from "@/components/shared/create-space-form"; | ||
import { SpaceService } from "@/lib/services/space"; | ||
import invariant from "ts-invariant"; | ||
import { getServerSession } from "@/lib/get-server-session"; | ||
import { redirect } from "next/navigation"; | ||
import SetupSpace from "@/components/shared/setup-space"; | ||
import { | ||
EMBEDDED_PORTAL_ITEM, | ||
EMBEDDED_PORTAL_STORAGE_KEY, | ||
} from "@/lib/workflow-constants"; | ||
|
||
export default async function Page() { | ||
const session = await getServerSession(); | ||
invariant(session?.user, "User must be logged in"); | ||
|
||
const space = await SpaceService.getSpaceForWorkflow({ | ||
userId: session.user.id, | ||
workflowType: WorkflowType.Embed, | ||
}); | ||
|
||
if (space) { | ||
redirect(`/embedded-portal/${space.id}`); | ||
} | ||
|
||
export default function Page() { | ||
return ( | ||
<div> | ||
<CreateSpaceForm | ||
workflowType={WorkflowType.Embed} | ||
spaceName={"Embedded Portal"} | ||
/> | ||
</div> | ||
<SetupSpace | ||
workflowType={WorkflowType.Embed} | ||
storageKey={EMBEDDED_PORTAL_STORAGE_KEY} | ||
item={EMBEDDED_PORTAL_ITEM} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters