import React from 'react'; import * as Survey from 'survey-react'; import { toBase64 } from '../util'; import emailHostSettings from './email-host-settings'; import { EmailTemplate3Config } from './email-template-3'; import verbs from './verbs'; var json = { showQuestionNumbers: 'off', pages: [ { title: 'Zaimki', elements: [ { type: 'dropdown', name: 'zaimek', title: 'Forma czasownika:', isRequired: true, choices: [ { value: 0, text: 'Wysłałem' }, { value: 1, text: 'Wysłałam' }, { value: 2, text: 'Wysłałom' }, { value: 3, text: 'Wysłaliśmy' }, ], }, ], }, { title: 'Polityka prywatności', elements: [ { type: 'dropdown', title: 'Czy polityka prywatności jest dostępna i czytelna?', isRequired: true, choices: [ { value: 'yes', text: 'dostępna i czytelna' }, { value: 'entirely_obscured_by_popup', text: 'dostępna, ale nieczytelna. Zasłania ją popup o RODO', }, { value: 'cant_find', text: `Niedostępna. {Szukałem}, ale nie {znalazłem} jej na stronie`, }, ], }, ], }, ], }; const survey = new Survey.Model(json); survey.onProcessTextValue.add(function ( sender: Survey.SurveyModel, options: { name: string; value?: string } ) { if (verbs[options.name.toLowerCase()]) { options.value = verbs[options.name.toLowerCase()][sender.valuesHash.zaimek]; if (options.name[0] == options.name[0].toUpperCase()) { options.value = [options.value[0].toUpperCase(), ...options.value.slice(1)].join(''); } } }); export default function EmailTemplate3Controls() { return ; } export function _EmailTemplate3Controls({ config, setConfig, }: { config: EmailTemplate3Config; setConfig: React.Dispatch>; }): JSX.Element { return (
{emailHostSettings(config, setConfig)}
{config.popup_type !== 'none' ? (
{ const popup_screenshot_base64 = await toBase64(e.target.files[0]); setConfig((v) => ({ ...v, popup_screenshot_base64, })); }, }} />
) : ( '' )}
{config.popup_action === 'closed' ? (
setConfig((v) => ({ ...v, popup_closed_how: e.target.value, })) } />
) : ( '' )} {config.popup_type !== 'none' ? (
setConfig((v) => ({ ...v, popup_mentions_passive_consent: e.target.checked, })) } />
) : ( '' )} {config.popup_mentions_passive_consent ? (
setConfig((v) => ({ ...v, popup_passive_consent_text: e.target.value, })) } />
) : ( '' )}
); }