diff --git a/apps/react/app/layout.tsx b/apps/react/app/layout.tsx index b03b6bf7..87a8fbf8 100644 --- a/apps/react/app/layout.tsx +++ b/apps/react/app/layout.tsx @@ -37,6 +37,8 @@ export default function RootLayout({ > Create a New Space Re-use a Space + Sheet + Workbook {children} diff --git a/apps/react/app/page.tsx b/apps/react/app/page.tsx index c2232dd7..84b488cf 100644 --- a/apps/react/app/page.tsx +++ b/apps/react/app/page.tsx @@ -11,8 +11,7 @@ export default function Home() { diff --git a/apps/react/app/sheet/App.tsx b/apps/react/app/sheet/App.tsx new file mode 100644 index 00000000..f99727d4 --- /dev/null +++ b/apps/react/app/sheet/App.tsx @@ -0,0 +1,44 @@ +'use client' +import { sheet } from '@/utils/sheet' +import { useFlatfile, useEvent, Sheet, Workbook, Space } from '@flatfile/react' +import React from 'react' +import styles from '../page.module.css' +const App = () => { + const { open, openPortal, closePortal } = useFlatfile() + + useEvent('**', async (event) => { + console.group('Event ->', event.topic) + console.log({ event }) + console.groupEnd() + }) + + return ( +
+
+ +
+ + { + const email = record.get('email') + if (!email) { + record.addError('email', 'Gotta add an Email here!') + } + return record + }} + onSubmit={(sheet) => { + console.log('onSubmit from Sheet Action', { sheet }) + }} + /> +
+ ) +} + +export default App diff --git a/apps/react/app/sheet/page.tsx b/apps/react/app/sheet/page.tsx new file mode 100644 index 00000000..84b488cf --- /dev/null +++ b/apps/react/app/sheet/page.tsx @@ -0,0 +1,20 @@ +'use client' +import React from 'react' + +import App from './App' +import { FlatfileProvider } from '@flatfile/react' + +export default function Home() { + const PUBLISHABLE_KEY = process.env.NEXT_PUBLIC_FLATFILE_PUBLISHABLE_KEY + if (!PUBLISHABLE_KEY) return <>No Publishable Key Available + return ( + + + + ) +} diff --git a/apps/react/app/workbook/App.tsx b/apps/react/app/workbook/App.tsx new file mode 100644 index 00000000..8e1a48ab --- /dev/null +++ b/apps/react/app/workbook/App.tsx @@ -0,0 +1,53 @@ +'use client' +import { workbook } from '@/utils/workbook' +import { useFlatfile, useEvent, Sheet, Workbook, Space } from '@flatfile/react' +import React from 'react' +import styles from '../page.module.css' +const App = () => { + const { open, openPortal, closePortal } = useFlatfile() + + useEvent('**', async (event) => { + console.group('Event ->', event.topic) + console.log({ event }) + console.groupEnd() + }) + + return ( +
+
+ +
+ + { + console.log('on Workbook Submit ', { sheet }) + }} + onRecordHooks={[ + [ + 'contacts', + (record) => { + record.set('email', 'SHEET 1 RECORDHOOKS') + return record + }, + ], + [ + 'contacts2', + (record) => { + record.set('email', 'SHEET 2 RECORDHOOKS') + return record + }, + ], + ]} + /> +
+ ) +} + +export default App diff --git a/apps/react/app/workbook/page.tsx b/apps/react/app/workbook/page.tsx new file mode 100644 index 00000000..84b488cf --- /dev/null +++ b/apps/react/app/workbook/page.tsx @@ -0,0 +1,20 @@ +'use client' +import React from 'react' + +import App from './App' +import { FlatfileProvider } from '@flatfile/react' + +export default function Home() { + const PUBLISHABLE_KEY = process.env.NEXT_PUBLIC_FLATFILE_PUBLISHABLE_KEY + if (!PUBLISHABLE_KEY) return <>No Publishable Key Available + return ( + + + + ) +}