import { __awaiter, __generator } from '../../../../node_modules/tslib/tslib.es6.js';
import React, { forwardRef, useState, useCallback } from 'react';
import { TenantSelectionSelectList } from '../../../tenantSelection/select/List.js';
import { NavigationTenantMenuLoading } from './Loading.js';

var NavigationTenantMenuContent = forwardRef(function (_a, ref) {
    var user = _a.user, selectTenant = _a.selectTenant, onClose = _a.onClose, title = _a.title, selectedTenantId = _a.selectedTenantId;
    var _b = useState(false), isLoading = _b[0], setIsLoading = _b[1];
    var onTenantSelect = useCallback(function (newTenantId) { return __awaiter(void 0, void 0, void 0, function () {
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    setIsLoading(true);
                    _a.label = 1;
                case 1:
                    _a.trys.push([1, , 3, 4]);
                    return [4 /*yield*/, selectTenant(newTenantId)];
                case 2:
                    _a.sent();
                    return [3 /*break*/, 4];
                case 3:
                    onClose();
                    setIsLoading(false);
                    return [7 /*endfinally*/];
                case 4: return [2 /*return*/];
            }
        });
    }); }, [selectTenant, onClose]);
    return (React.createElement(React.Fragment, null,
        React.createElement(TenantSelectionSelectList, { managedSellers: user.managedSellers, selectedTenantId: selectedTenantId, onTenantSelect: onTenantSelect, title: title, searchFieldOptions: { autoComplete: 'off' }, ref: ref }),
        isLoading ? React.createElement(NavigationTenantMenuLoading, null) : null));
});

export { NavigationTenantMenuContent as default };
//# sourceMappingURL=Content.js.map
