@vergelijkdirect/comparison-forms 2.0.0-rc.10 → 2.0.0-rc.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -116,14 +116,19 @@ declare const __VLS_export_15: DefineComponent<ComparisonFormFlowProps, {}, {},
116
116
  declare const __VLS_export_16: DefineComponent<RiskScannerFormProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<RiskScannerFormProps> & Readonly<{}>, {
117
117
  title: string;
118
118
  description: string;
119
+ qaId: string;
120
+ thankyouPageTemplate: string;
119
121
  buttonText: string;
120
122
  showTitle: boolean;
121
- qaOptions: Partial<QaOptions>;
123
+ qaUrl: string;
124
+ currentItemId: string;
125
+ nextItemId: string;
122
126
  }, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
123
127
 
124
128
  declare const __VLS_export_17: DefineComponent<QuestionnaireSharedProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<QuestionnaireSharedProps> & Readonly<{}>, {
125
129
  title: string;
126
130
  description: string;
131
+ thankyouPageTemplate: string;
127
132
  buttonText: string;
128
133
  showTitle: boolean;
129
134
  }, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
@@ -603,31 +608,42 @@ export declare interface PetFormData {
603
608
 
604
609
  export declare function petPresenter(data: PetFormData): ComparisonPayload;
605
610
 
606
- export declare interface QaOptions {
607
- qaId: string;
608
- thankyouPageTemplate?: string;
609
- qaUrl?: string;
610
- currentItemId?: string;
611
- nextItemId?: string;
612
- }
613
-
614
611
  export declare const QuestionnaireForm: typeof __VLS_export_17;
615
612
 
616
613
  export declare type QuestionnaireFormProps = QuestionnaireSharedProps;
617
614
 
615
+ /**
616
+ * The shared public API of every questionnaire (QA-renderer quiz starter).
617
+ * Deliberately independent from the comparison forms' `ComparisonFormProps` —
618
+ * questionnaires are VD-internal drop-ins, their contract evolves separately.
619
+ *
620
+ * On master (1.x) this contract was `link`/`title`/`description`/`buttonText`/
621
+ * `showTitle` + an `additionalOptions` object carrying the QA params; 2.x
622
+ * flattens those params into plain props, keeping the master names
623
+ * (`thankyouPageTemplate` still lands in the url as the `template` query param).
624
+ */
618
625
  export declare interface QuestionnaireSharedProps {
626
+ /** base page url of the quiz app; `{qaId, template, …}` are merged into its query */
619
627
  link: string;
628
+ qaId: string;
629
+ thankyouPageTemplate?: string;
620
630
  title?: string;
621
631
  description?: string;
622
632
  buttonText?: string;
623
633
  showTitle?: boolean;
624
- qaOptions: QaOptions;
625
634
  }
626
635
 
627
636
  export declare const RiskScannerForm: typeof __VLS_export_16;
628
637
 
629
- export declare interface RiskScannerFormProps extends Omit<QuestionnaireSharedProps, 'qaOptions'> {
630
- qaOptions?: Partial<QaOptions>;
638
+ export declare interface RiskScannerFormProps extends Omit<QuestionnaireSharedProps, 'qaId'> {
639
+ /**
640
+ * base url of the QA API (a missing trailing slash is normalized internally);
641
+ * falls back to the ITC client's qa config when omitted
642
+ */
643
+ qaUrl?: string;
644
+ qaId?: string;
645
+ currentItemId?: string;
646
+ nextItemId?: string;
631
647
  }
632
648
 
633
649
  export declare const TravelForm: typeof __VLS_export_4;
@@ -5716,19 +5716,20 @@ var Sa = /* @__PURE__ */ B({
5716
5716
  __name: "QuestionnaireForm",
5717
5717
  props: {
5718
5718
  link: {},
5719
+ qaId: {},
5720
+ thankyouPageTemplate: { default: "common" },
5719
5721
  title: { default: "" },
5720
5722
  description: { default: "" },
5721
5723
  buttonText: { default: "" },
5722
5724
  showTitle: {
5723
5725
  type: Boolean,
5724
5726
  default: !0
5725
- },
5726
- qaOptions: {}
5727
+ }
5727
5728
  },
5728
5729
  setup(e) {
5729
5730
  let n = e, a = t(() => Qr(n.link, {
5730
- qaId: n.qaOptions.qaId,
5731
- template: n.qaOptions.thankyouPageTemplate ?? "common"
5731
+ qaId: n.qaId,
5732
+ template: n.thankyouPageTemplate
5732
5733
  }));
5733
5734
  return (t, n) => (y(), i("div", Ra, [e.showTitle && e.title || e.description ? (y(), i("div", za, [e.showTitle && e.title ? (y(), i("h2", Ba, T(e.title), 1)) : r("", !0), e.description ? (y(), i("p", Va, T(e.description), 1)) : r("", !0)])) : r("", !0), c(E(Ie), {
5734
5735
  href: a.value,
@@ -5751,8 +5752,12 @@ var Sa = /* @__PURE__ */ B({
5751
5752
  }, Ka = { class: "vd-form__row" }, qa = { class: "vd-form__col-10 vd-form__col-md-6" }, Ja = { class: "vd-form__col-2 vd-form__action" }, Ya = /* @__PURE__ */ l({
5752
5753
  __name: "RiskScannerForm",
5753
5754
  props: {
5754
- qaOptions: { default: () => ({}) },
5755
+ qaUrl: { default: "" },
5756
+ qaId: { default: "6627c64764165beec8076818" },
5757
+ currentItemId: { default: "6627e21c64165beec8076830" },
5758
+ nextItemId: { default: "6627e32464165beec8076838" },
5755
5759
  link: {},
5760
+ thankyouPageTemplate: { default: "risk-scanner" },
5756
5761
  title: { default: "Check de risico`s voor jouw bedrijf + ontvang gratis offerte!" },
5757
5762
  description: { default: "Doe onze risicoscan en ontdek de beste verzekering voor jouw specifieke bedrijf. Om te starten hebben we je bedrijfsnaam of KVK-nummer nodig!" },
5758
5763
  buttonText: { default: "Start de gratis scan" },
@@ -5762,15 +5767,9 @@ var Sa = /* @__PURE__ */ B({
5762
5767
  }
5763
5768
  },
5764
5769
  setup(e) {
5765
- let o = e, s = t(() => ({
5766
- qaId: "6627c64764165beec8076818",
5767
- currentItemId: "6627e21c64165beec8076830",
5768
- nextItemId: "6627e32464165beec8076838",
5769
- thankyouPageTemplate: "risk-scanner",
5770
- ...o.qaOptions
5771
- })), l = x(null), { isSubmitting: u, handleSubmit: f, defineField: p, setErrors: h, removeError: g } = Z(R({ company: Br() }), { company: null }), [_, v, b] = p("company"), S = (e) => e ? h({ company: e }) : g("company"), C = t(() => !!_.value && !_.value.hasVisitingAddress);
5772
- async function w(e) {
5773
- let t = s.value.qaUrl || An(), n = t.endsWith("/") ? t : `${t}/`, r = await fetch(`${n}api/v1/active-questionnaire/${s.value.qaId}/start`, {
5770
+ let o = e, s = x(null), { isSubmitting: l, handleSubmit: u, defineField: f, setErrors: p, removeError: h } = Z(R({ company: Br() }), { company: null }), [g, _, v] = f("company"), b = (e) => e ? p({ company: e }) : h("company"), S = t(() => !!g.value && !g.value.hasVisitingAddress);
5771
+ async function C(e) {
5772
+ let t = o.qaUrl || An(), n = t.endsWith("/") ? t : `${t}/`, r = await fetch(`${n}api/v1/active-questionnaire/${o.qaId}/start`, {
5774
5773
  method: "POST",
5775
5774
  headers: { "Content-Type": "application/json" },
5776
5775
  body: JSON.stringify({
@@ -5778,23 +5777,23 @@ var Sa = /* @__PURE__ */ B({
5778
5777
  value: e.kvkNummer,
5779
5778
  data: e
5780
5779
  } } },
5781
- current_item_id: s.value.currentItemId,
5782
- next_item_id: s.value.nextItemId
5780
+ current_item_id: o.currentItemId,
5781
+ next_item_id: o.nextItemId
5783
5782
  })
5784
5783
  });
5785
5784
  if (!r.ok) throw Error(`Failed to start the questionnaire (${r.status})`);
5786
5785
  let { leadId: i } = await r.json();
5787
5786
  return Qr(o.link, {
5788
5787
  leadid: i,
5789
- qaId: s.value.qaId,
5790
- template: s.value.thankyouPageTemplate
5788
+ qaId: o.qaId,
5789
+ template: o.thankyouPageTemplate
5791
5790
  });
5792
5791
  }
5793
- function D() {
5794
- u.value || f(async () => {
5792
+ function w() {
5793
+ l.value || u(async () => {
5795
5794
  try {
5796
- if (!l.value) throw Error("Missing company data");
5797
- let e = await w(l.value);
5795
+ if (!s.value) throw Error("Missing company data");
5796
+ let e = await C(s.value);
5798
5797
  window.location.href = e;
5799
5798
  } catch (e) {
5800
5799
  console.error(e);
@@ -5803,22 +5802,22 @@ var Sa = /* @__PURE__ */ B({
5803
5802
  }
5804
5803
  return (t, o) => (y(), i("form", {
5805
5804
  class: "vd-form vd-form--vertical vd-form--card",
5806
- onSubmit: I(D, ["prevent"])
5805
+ onSubmit: I(w, ["prevent"])
5807
5806
  }, [e.showTitle && e.title || e.description ? (y(), i("div", Ua, [e.showTitle && e.title ? (y(), i("h2", Wa, T(e.title), 1)) : r("", !0), e.description ? (y(), i("p", Ga, T(e.description), 1)) : r("", !0)])) : r("", !0), a("div", Ka, [a("div", qa, [c(E(zr), m({
5808
- modelValue: E(_),
5809
- "onUpdate:modelValue": o[0] ||= (e) => d(_) ? _.value = e : null
5810
- }, E(v), {
5811
- "error-message": E(b),
5812
- onError: S,
5813
- onRaw: o[1] ||= (e) => l.value = e
5814
- }), null, 16, ["modelValue", "error-message"]), C.value ? (y(), n(E(Kt), {
5807
+ modelValue: E(g),
5808
+ "onUpdate:modelValue": o[0] ||= (e) => d(g) ? g.value = e : null
5809
+ }, E(_), {
5810
+ "error-message": E(v),
5811
+ onError: b,
5812
+ onRaw: o[1] ||= (e) => s.value = e
5813
+ }), null, 16, ["modelValue", "error-message"]), S.value ? (y(), n(E(Kt), {
5815
5814
  key: 0,
5816
5815
  style: { "margin-top": "12px" },
5817
5816
  text: "Dit bedrijf heeft geen geregistreerd bezoekadres. Voeg dit toe bij de KvK om door te gaan met de aanvraag."
5818
5817
  })) : r("", !0)]), a("div", Ja, [c(E(Ie), {
5819
5818
  label: e.buttonText,
5820
- "is-loading": E(u),
5821
- disabled: C.value,
5819
+ "is-loading": E(l),
5820
+ disabled: S.value,
5822
5821
  "button-type": "green",
5823
5822
  size: "big",
5824
5823
  block: "",