Skip to content

Commit fc85d25

Browse files
authored
Revert examples (#110)
We'll introduce this with release 0.0.3
1 parent 58cc2d3 commit fc85d25

File tree

4 files changed

+148
-434
lines changed

4 files changed

+148
-434
lines changed

frontend/app/components/ExampleEditor.tsx

-183
This file was deleted.

frontend/app/components/Extractor.tsx

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
"use client";
2+
3+
import {
4+
Tab,
5+
TabList,
6+
TabPanel,
7+
TabPanels,
8+
Tabs,
9+
Text,
10+
} from "@chakra-ui/react";
11+
import Form from "@rjsf/chakra-ui";
12+
import validator from "@rjsf/validator-ajv8";
13+
import { docco } from "react-syntax-highlighter/dist/esm/styles/hljs";
14+
15+
import SyntaxHighlighter from "react-syntax-highlighter";
16+
import { useGetExtractor } from "../utils/api";
17+
18+
type ExtractorProps = {
19+
extractorId: string;
20+
isShared: boolean;
21+
};
22+
23+
export const Extractor = ({ extractorId, isShared }: ExtractorProps) => {
24+
const { data, isLoading, isError } = useGetExtractor(extractorId, isShared);
25+
if (isLoading) {
26+
return <div>Loading...</div>;
27+
}
28+
if (isError) {
29+
return <div>Unable to load extractor with ID: {extractorId}</div>;
30+
}
31+
32+
if (data === undefined) {
33+
throw new Error("Data is undefined");
34+
}
35+
36+
return (
37+
<div className="mr-auto">
38+
<Tabs className="mt-5" variant={"enclosed"} colorScheme="blue" size="sm">
39+
<TabList>
40+
<Tab>Form</Tab>
41+
<Tab>Code</Tab>
42+
</TabList>
43+
<TabPanels>
44+
<TabPanel>
45+
<Form schema={data.schema} validator={validator}>
46+
{true} {/* Disables the submit button */}
47+
</Form>
48+
</TabPanel>
49+
<TabPanel>
50+
<Text className="mt-1 mb-5">
51+
This shows the raw JSON Schema that describes what information the
52+
extractor will be extracting from the content.
53+
</Text>
54+
<SyntaxHighlighter language="json" style={docco}>
55+
{JSON.stringify(data.schema, null, 2)}
56+
</SyntaxHighlighter>
57+
</TabPanel>
58+
</TabPanels>
59+
</Tabs>
60+
</div>
61+
);
62+
};

0 commit comments

Comments
 (0)