Skip to content

Commit a46e6e8

Browse files
Allow toggling between Splitgraph/Seafowl embeds (once export has completed)
1 parent bd06807 commit a46e6e8

1 file changed

Lines changed: 40 additions & 3 deletions

File tree

  • examples/nextjs-import-airbyte-github-export-seafowl/components/ImportExportStepper

examples/nextjs-import-airbyte-github-export-seafowl/components/ImportExportStepper/ExportPanel.tsx

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// components/ImportExportStepper/ExportPanel.tsx
22

3-
import { ComponentProps, Fragment } from "react";
3+
import { ComponentProps, Fragment, useState } from "react";
44

55
import { useStepper } from "./StepperContext";
66
import styles from "./ExportPanel.module.css";
@@ -330,14 +330,51 @@ const ExportEmbedPreviewTableOrQuery = <
330330
? exportInput.table
331331
: `${exportInput.destinationSchema}.${exportInput.destinationTable}`;
332332

333+
const [selectedTab, setSelectedTab] = useState<"splitgraph" | "seafowl">(
334+
"splitgraph"
335+
);
336+
333337
return (
334338
<>
335339
<h4>
336340
<code>{heading}</code>
337341
</h4>
342+
<div style={{ display: "flex", flexDirection: "row" }}>
343+
<button
344+
onClick={() => setSelectedTab("splitgraph")}
345+
disabled={selectedTab === "splitgraph"}
346+
style={{ marginRight: "1rem" }}
347+
>
348+
Splitgraph Query
349+
</button>
350+
<button
351+
onClick={() => setSelectedTab("seafowl")}
352+
disabled={selectedTab === "seafowl" || !completed}
353+
>
354+
Seafowl Query
355+
</button>
356+
</div>
338357
<pre>{JSON.stringify({ completed, loading }, null, 2)}</pre>
339-
{(unstarted || loading) && <SplitgraphEmbeddedQuery {...embedProps} />}
340-
{completed && <SeafowlEmbeddedQuery {...embedProps} />}
358+
{
359+
<div
360+
style={{
361+
visibility: selectedTab === "splitgraph" ? "visible" : "hidden",
362+
display: selectedTab === "seafowl" ? "none" : "block",
363+
}}
364+
>
365+
<SplitgraphEmbeddedQuery {...embedProps} />
366+
</div>
367+
}
368+
{completed && (
369+
<div
370+
style={{
371+
visibility: selectedTab === "seafowl" ? "visible" : "hidden",
372+
display: selectedTab === "splitgraph" ? "none" : "block",
373+
}}
374+
>
375+
<SeafowlEmbeddedQuery {...embedProps} />
376+
</div>
377+
)}
341378
</>
342379
);
343380
};

0 commit comments

Comments
 (0)