--- /dev/null
+/* jshint esversion: 6 */
+const param30 = $('meta[name=csrf-param]').attr("content");
+const token30 = $('meta[name=csrf-token]').attr("content");
+
+
+function setTgDialog(storeId, tg_chat_id) {
+ const $mainModal = $('#mainModal');
+ const $modalBody = $mainModal.find('.modal-body');
+ $modalBody.html('<input type="number">');
+ const $modalFooter = $mainModal.find('.modal-footer');
+ $modalFooter.html('');
+ $modalFooter.get(0).insertAdjacentHTML('beforeend', '<button>Сохранить</button>');
+ const $saveButton = $modalFooter.find('button');
+ $saveButton.addClass(['btn', 'btn-success', 'btn-lg']);
+ $saveButton.on('click', () => {
+ $.ajax({
+ method: 'POST',
+ url: window.location.href,
+ data: {action: 'saveTg', storeId, tgInput: $tgInput.val(), [param30]: token30},
+ dataType: "text",
+ success: function (data) {
+ console.log(data);
+ if (data === 'ok') {
+ window.location.reload();
+ }
+ }
+ });
+ })
+ const $tgInput = $modalBody.find('input');
+ if (tg_chat_id) {
+ $tgInput.val(tg_chat_id);
+ }
+ $mainModal.find('.modal-title').html('Установка Телеграм чата');
+ $mainModal.find('.close').on('click', () => $('#mainModal').modal('hide'));
+
+ $mainModal.modal('show');
+}
\ No newline at end of file