Try to validate Supervisor or Manager Role upon submiting document

Im trying to validate document with supervisor or manager role upon submitting sales invoice document with client script v13 with frappe confirm, but I have no idea how to go through
My code
frappe.confirm(" Are you sure you want to proceed?",
() => {
// action to perform if Yes is selected
let d = new frappe.ui.Dialog({
title: ‘Enter Supervisor/Manager Credential’,
fields: [
{
label: ‘Username’,
fieldname: ‘username’,
fieldtype: ‘Data’
},
{
label: ‘Password’,
fieldname: ‘Password’,
fieldtype: ‘Data’
}

            ],
            primary_action_label: 'Submit',
            primary_action(values) {
                console.log(values.username);
                d.hide();
                //VALIDATE USERNAME AND PASSWORD
               //VALIDATE IF USER IS SUPERVISOR OR MANAGER ROLE
            }
            });
    
            d.show();
        }, () => {
            // action to perform if No is selected
            frappe.validated = false;
        });

Pls help me on this…