HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall/buyercall/assets/components/partnership/account_edit.js
import {showConfirm} from '../utils';
import $ from 'jquery';

$("#form_partnerships_account_edit_login_access").on('click', 'input:checkbox', e => {
	let checkbox = e.target;
	const checked = checkbox.checked;
    let yesCallback = () => {
    	$(checkbox).prop('checked', checked);
        $("#form_partnerships_account_edit_login_access").submit();
    };
    showConfirm({
        title: 'CONFIRM',
        body: checked ? '<p>Are you sure you want to restrict login access to this account?</p>'
        			: '<p>Are you sure you want to allow login access to this account?</p>',
        yesCb: yesCallback,
    });
    return false;
});

$("#form_partnerships_account_edit_lead_import_access").on('click', 'input:checkbox', e => {
	let checkbox = e.target;

    $('#allowImport').val($(checkbox).prop('checked'));

	if ($(checkbox).prop('checked') == true) {
        const checked = checkbox.checked;
        let yesCallback = () => {
            $(checkbox).prop('checked', checked);
            $("#form_partnerships_account_edit_lead_import_access").submit();
        };
        showConfirm({
            title: 'CONFIRM',
            body: checked ? '<p>Are you sure you want to allow lead imports for this account?</p>'
                        : '<p>Are you sure you want to allow lead imports for this account?</p>',
            yesCb: yesCallback,
        });
        return false;
    } else {
        $(checkbox).prop('checked', '');
        $("#form_partnerships_account_edit_lead_import_access").submit();
    }
});

$("#form_partnerships_account_edit_twillio").on('click', 'input:checkbox', e => {
	let checkbox = e.target;
	const checked = checkbox.checked;
    let yesCallback = () => {
    	$(checkbox).prop('checked', checked);
        $("#form_partnerships_account_edit_twillio").submit();
    };
    showConfirm({
        title: 'CONFIRM',
        body: checked ? `<p>Are you sure you want to suspend subscription?</p>
        					<p class="small help-block sm-margin-bottom">
                      <strong>Before you suspend subscription, please read the following:
                  </p>
                  <ul class="margin-bottom">
                      <li>You will no longer be billed</li>
                      <li>You will lose access to your call widget list</li>
                      <li>You will not be able to create new call widgets</li>
                      <li>The call widget on your website will not work anymore</li>
                      <li>You will stop receiving leads</li>
                      <li>You <strong>will</strong> have access to your existing leads</li>
                      <li>You <strong>will</strong> have access to your existing list of agents</li>
                      <li>Your account <strong>will</strong> remain open</li>
                      <li>You may subscribe again in the future</li>
                  </ul>`
        			: '<p>Are you sure you want to activate subscription?</p>',
        yesCb: yesCallback,
    });
    return false;
});

$("#form_partnerships_account_close_subscription").on('click', 'button', e => {
    let yesCallback = () => {
        $("#form_partnerships_account_close_subscription").submit();
    };
    showConfirm({
        title: 'CONFIRM',
        body: `<p>Are you sure you want to close subscription?</p>
        					<p class="small help-block sm-margin-bottom">
                      <strong>Before you close subscription, please read the following:
                  </p>
                  <ul class="margin-bottom">
                      <li>Phone numbers will be released</li>
                      <li>You will no longer be billed</li>
                      <li>You will lose access to your call widget list</li>
                      <li>You will not be able to create new call widgets</li>
                      <li>The call widget on your website will not work anymore</li>
                      <li>You will stop receiving leads</li>
                      <li>You <strong>will</strong> have access to your existing leads</li>
                      <li>You <strong>will</strong> have access to your existing list of agents</li>
                      <li>Your account <strong>will</strong> remain open</li>
                      <li>You may subscribe again in the future</li>
                  </ul>`,
        yesCb: yesCallback,
    });
    return false;
});

// jQuery code to show a flash message when the button is clicked
$("#addButton").on('click', function() {
    $("#auto_email").modal("hide");
    const flashMessages = $("#flash-messages");
    const message = "The auto respond email template was saved successfully.";

    // Create a message element and add it to the flash messages div
    const messageElement = $("<div class='alert alert-success'>" + message + "</div>");
    flashMessages.append(messageElement);

    // Hide the message after a few seconds (you can adjust the delay as needed)
    setTimeout(function() {
        messageElement.fadeOut("slow");
    }, 3000); // Message will be hidden after 3 seconds
});