import React from 'react';
import { Auth0UserType } from '@smg-automotive/auth';
import { GridItem, Stack, Box, Divider } from '@chakra-ui/react';
import Show from '../../../../show/index.js';
import Avatar from '../../../../avatar/index.js';
import TenantSelectionMenu from './TenantSelectionMenu.js';
import SelectedTenantInfo from './SelectedTenantInfo.js';

var DrawerUserInfo = function (_a) {
    var _b;
    var user = _a.user, selectTenant = _a.selectTenant, showTenantSelection = _a.showTenantSelection;
    if (!user)
        return null;
    var selectedTenant = (_b = user.managedSellers) === null || _b === void 0 ? void 0 : _b.find(function (seller) { return seller.id === Number(user.sellerId); });
    return (React.createElement(GridItem, { colSpan: { base: 1, md: 5 } },
        React.createElement(Stack, { px: "lg", mb: "lg", direction: {
                base: 'column',
                md: 'row',
            }, spacing: { base: 'sm', md: '2xl' } },
            React.createElement(Stack, { direction: "row" },
                React.createElement(Avatar, null),
                React.createElement(Stack, { direction: {
                        base: 'column',
                        md: 'row',
                    }, spacing: {
                        base: 0,
                        md: 'sm',
                    } },
                    React.createElement(Box, { as: "span", fontWeight: "bold", maxW: "calc(100vw - 2 * var(--chakra-space-lg) - var(--chakra-space-sm) - var(--chakra-sizes-sm))" }, user.email),
                    user.userType === Auth0UserType.Professional ? (React.createElement(Box, { as: "span" },
                        "(",
                        user.sellerId,
                        ")")) : null)),
            selectedTenant && showTenantSelection ? (React.createElement(React.Fragment, null,
                React.createElement(Show, { above: "md" },
                    React.createElement(SelectedTenantInfo, { selectedTenant: selectedTenant })),
                React.createElement(Show, { below: "sm", marginX: "-lg", marginBottom: "-lg" },
                    React.createElement(TenantSelectionMenu, { user: user, selectedTenant: selectedTenant, selectTenant: selectTenant })))) : null),
        React.createElement(Divider, { borderBottomWidth: {
                base: selectedTenant ? 0 : '1px',
                md: '1px',
            } })));
};

export { DrawerUserInfo as default };
//# sourceMappingURL=index.js.map
