2022-02-07 21:11:25 +01:00
|
|
|
import * as Survey from 'survey-react';
|
2022-07-07 19:59:16 +02:00
|
|
|
import { RequestCluster } from '../../request-cluster';
|
2022-02-07 21:11:25 +01:00
|
|
|
import RawAnswers from './raw-answers';
|
|
|
|
import useSurvey from './use-survey';
|
|
|
|
|
|
|
|
export default function Questions({
|
2022-07-07 19:59:16 +02:00
|
|
|
clusters,
|
2022-02-07 21:11:25 +01:00
|
|
|
onComplete,
|
|
|
|
}: {
|
2022-07-07 19:59:16 +02:00
|
|
|
clusters: RequestCluster[];
|
2022-02-07 21:11:25 +01:00
|
|
|
onComplete: (data: RawAnswers) => void;
|
|
|
|
}) {
|
2022-07-07 19:59:16 +02:00
|
|
|
const survey = useSurvey(clusters, {
|
2022-02-07 21:11:25 +01:00
|
|
|
onComplete: (sender) => onComplete(sender.data),
|
|
|
|
});
|
|
|
|
if (!survey) {
|
2022-04-25 20:02:20 +02:00
|
|
|
return <div>Wczytywanie...</div>;
|
2022-02-07 21:11:25 +01:00
|
|
|
}
|
|
|
|
return <Survey.Survey model={survey} />;
|
|
|
|
}
|