// Copyright (c) 2023, JINGROW
// For license information, please see license.txt

jingrow.ui.form.on('Product Trial Request', {
	refresh(frm) {
		frm.add_custom_button(__('Preview Setup Wizard Payload'), function () {
			jingrow.call({
				method: 'get_setup_wizard_payload',
				pg: frm.pg,
				args: {},
				freeze: true,
				freeze_message: __('Generating Setup Wizard Payload'),
				callback: function (r) {
					if (r.exc) {
						jingrow.msgprint(r.exc);
					} else {
						jingrow.msgprint({
							title: __('Setup Wizard Payload'),
							message: JSON.stringify(r.message, null, 4),
						});
					}
				},
				error: function (r) {
					jingrow.msgprint(r.message);
				},
			});
		});
	},
});
