async function loadCompanies() {

    // Use cached data if available
    const cached = localStorage.getItem('companies');

    if (cached) {
        return JSON.parse(cached);
    }

    const response = await fetch(
        '/api/v1/customers/companies/?' +
        'builder[0][where][0]=company_state&' +
        'builder[0][where][1]=active',
        {
            credentials: 'include'
        }
    );

    const companies = await response.json();

    localStorage.setItem('companies', JSON.stringify(companies));

    return companies;
}

function getCompanyMap() {

    const companies = JSON.parse(localStorage.getItem('companies') || '[]');

    return companies.reduce((map, company) => {
        map[company.company_uuid] = company.company_name;
        return map;
    }, {});
}