2022-10-07 11:09:16 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import FormUrlApp from './components/form_url_app.vue';
|
|
|
|
|
|
|
|
export default () => {
|
|
|
|
const el = document.querySelector('.js-vue-webhook-form');
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-10-18 17:09:37 -04:00
|
|
|
const { url: initialUrl, urlVariables } = el.dataset;
|
|
|
|
|
2022-10-31 05:09:32 -04:00
|
|
|
// Convert the array of 'key' strings to array of { key } objects
|
|
|
|
const initialUrlVariables = urlVariables
|
|
|
|
? JSON.parse(urlVariables)?.map((key) => ({ key }))
|
|
|
|
: undefined;
|
|
|
|
|
2022-10-07 11:09:16 -04:00
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
name: 'WebhookFormRoot',
|
|
|
|
render(createElement) {
|
2022-10-18 17:09:37 -04:00
|
|
|
return createElement(FormUrlApp, {
|
|
|
|
props: {
|
|
|
|
initialUrl,
|
2022-10-31 05:09:32 -04:00
|
|
|
initialUrlVariables,
|
2022-10-18 17:09:37 -04:00
|
|
|
},
|
|
|
|
});
|
2022-10-07 11:09:16 -04:00
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|