mirror of
https://github.com/penpot/penpot.git
synced 2025-05-19 06:36:11 +02:00
🎉 Backport questions form integration.
Among other related that need to be ported.
This commit is contained in:
parent
a2d3616171
commit
eb1bcfba83
45 changed files with 983 additions and 529 deletions
48
frontend/src/app/main/ui/onboarding/questions.cljs
Normal file
48
frontend/src/app/main/ui/onboarding/questions.cljs
Normal file
|
@ -0,0 +1,48 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) UXBOX Labs SL
|
||||
|
||||
(ns app.main.ui.onboarding.questions
|
||||
"External form for onboarding questions."
|
||||
(:require
|
||||
[app.main.data.users :as du]
|
||||
[app.main.store :as st]
|
||||
[app.util.dom :as dom]
|
||||
[goog.events :as ev]
|
||||
[promesa.core :as p]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(defn load-arengu-sdk
|
||||
[container-ref email form-id]
|
||||
(letfn [(on-init []
|
||||
(when-let [container (mf/ref-val container-ref)]
|
||||
(-> (.embed js/ArenguForms form-id container)
|
||||
(p/then (fn [form]
|
||||
(.setHiddenField ^js form "email" email))))))
|
||||
|
||||
(on-submit-success [_event]
|
||||
(st/emit! (du/mark-questions-as-answered)))
|
||||
]
|
||||
|
||||
(let [script (dom/create-element "script")
|
||||
head (unchecked-get js/document "head")
|
||||
lkey1 (ev/listen js/document "af-submitForm-success" on-submit-success)]
|
||||
|
||||
(unchecked-set script "src" "https://sdk.arengu.com/forms.js")
|
||||
(unchecked-set script "onload" on-init)
|
||||
(dom/append-child! head script)
|
||||
|
||||
(fn []
|
||||
(ev/unlistenByKey lkey1)))))
|
||||
|
||||
(mf/defc questions
|
||||
[{:keys [profile form-id]}]
|
||||
(let [container (mf/use-ref)]
|
||||
(mf/use-effect (partial load-arengu-sdk container (:email profile) form-id))
|
||||
[:div.modal-wrapper.questions-form
|
||||
[:div.modal-overlay
|
||||
[:div.modal-container {:ref container}]]]))
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue