import * as React from 'react';
import {
LiveProvider,
LiveEditor,
LivePreview,
LiveContext,
ContextProps,
} from 'react-live';
// only import the primitives to prevent importing sideEffects
import { primitives as AUI } from '@aws-amplify/ui-react';
import { trackClick } from '@/utils/track';
const { View, Alert } = AUI;
const code = `
New
Product title
Product description
$199.99
`;
const Error = () => {
const context: ContextProps = React.useContext(LiveContext);
const { error } = context;
if (error) {
return {error};
} else {
return null;
}
};
const HomeEditor = () => {
const [edited, setEdited] = React.useState(false);
return (
{
// This makes sure the editor is not a focus trap, allowing customers to 'tab' out of the editor
if (e.keyCode === 9) {
// tab key
e.preventDefault();
e.target.blur();
return;
}
if (!edited) {
trackClick('HomeCodeEdit');
setEdited(true);
}
}}
/>
);
};
export default HomeEditor;