import React from "react";
import * as lunatic from "@inseefr/lunatic";
import * as lunaticEDT from "../../ui";
const { Button } = lunatic;
const { ThemeProvider, ...edtComponents } = lunaticEDT;
export type Props = {
goPrevious: () => void;
goNext: () => void;
isLast: boolean;
isFirst: boolean;
};
const Pager = (props: Props) => {
const { goPrevious, goNext, isLast, isFirst } = props;
return (
);
};
const onLogChange = (e: React.ChangeEvent) => console.log("onChange", { ...e });
export type OrchestratorProps = {
source: object;
data?: object;
};
export const OrchestratorForStories = (props: OrchestratorProps) => {
const { source, data } = props;
const { getComponents, goPreviousPage, goNextPage, isFirstPage, isLastPage, getCurrentErrors } =
lunatic.useLunatic(source, data, {
onChange: onLogChange,
activeControls: true,
});
const components = getComponents();
const currentErrors = getCurrentErrors();
return (
{components.map(function (component: any) {
const { id, componentType, response, ...other } = component;
const Component = lunatic[componentType];
return (
);
})}
);
};