@datalayer/core
Version:
[](https://datalayer.io)
36 lines (35 loc) • 1.95 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
/*
* Copyright (c) 2023-2025 Datalayer, Inc.
* Distributed under the terms of the Modified BSD License.
*/
import { useEffect, useState } from 'react';
import { Text, Link } from '@primer/react';
import { FlashClosable } from '../../components/flashes';
import { Box } from '@datalayer/primer-addons';
import { useToast } from '../../hooks';
import { useCoreStore, useSurveysStore } from '../../state';
import { Survey2025_1 } from './surveys';
export const SURVEY_2025_1_NAME = '2025-1';
export const FlashSurveys = (props) => {
const { surveyName } = props;
const { enqueueToast } = useToast();
const [show, setShow] = useState(false);
const { surveys, createSurvey } = useSurveysStore();
const { configuration } = useCoreStore();
useEffect(() => {
if (surveys) {
if (!surveys.get(SURVEY_2025_1_NAME)) {
setShow(true);
}
}
}, [surveys]);
const onSubmit = (data, e) => {
const { formData } = data;
createSurvey(SURVEY_2025_1_NAME, formData);
setShow(false);
enqueueToast('Thank you for your answers.', { variant: 'success' });
};
return (_jsx(_Fragment, { children: surveys && (show || surveyName) && !configuration.whiteLabel && (_jsxs(FlashClosable, { variant: "default", children: [_jsx(Box, { children: _jsx(Text, { as: "h2", children: "We'd love to know a bit more about you and your needs..." }) }), _jsx(Box, { children: _jsx(Survey2025_1, { formData: surveyName ? surveys.get(SURVEY_2025_1_NAME)?.form : undefined, onSubmit: onSubmit }) }), _jsx(Box, { mt: 3, children: _jsxs(Text, { children: ["The information you give will remain fully private, read our", ' ', _jsx(Link, { href: "https://datalayer.app/privacy", target: "_blank", children: "privacy policy" }), "."] }) })] })) }));
};
export default FlashSurveys;