import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2023-2025 GoodData Corporation
import { useIntl } from "react-intl";
import { DetailRow } from "./DetailRow.js";
import { OrganizationMemberDropdown } from "./OrganizationMemberDropdown.js";
import { messages } from "../locales.js";
import { useTelemetry } from "../TelemetryContext.js";
export function UserDetailsView({ user, isAdmin, isBootstrapUser, mode, onChange }) {
    const intl = useIntl();
    const trackEvent = useTelemetry();
    if (!user) {
        return null;
    }
    return (_jsxs("div", { className: "gd-user-management-dialog-detail s-user-management-user", children: [
            _jsx(DetailRow, { labelText: intl.formatMessage(messages.userFirstName), value: user.firstName, mode: mode, onChange: (firstName) => onChange?.({ ...user, firstName: String(firstName) }, isAdmin) }), _jsx(DetailRow, { labelText: intl.formatMessage(messages.userLastName), value: user.lastName, mode: mode, onChange: (lastName) => onChange?.({ ...user, lastName: String(lastName) }, isAdmin) }), _jsx(DetailRow, { labelText: intl.formatMessage(messages.userEmail), value: user.email, mode: mode, onChange: (email) => onChange?.({ ...user, email: String(email) }, isAdmin) }), _jsxs("div", { className: "gd-user-management-dialog-detail-row", children: [
                    _jsx("div", { className: "gd-user-management-dialog-detail-label", children: intl.formatMessage(messages.userMembership) }), _jsxs("div", { children: [mode === "VIEW" &&
                                (isAdmin
                                    ? intl.formatMessage(messages.userIsAdmin)
                                    : intl.formatMessage(messages.userIsRegularUser)), mode === "EDIT" && (_jsx(OrganizationMemberDropdown, { isDisabled: isBootstrapUser, isAdmin: isAdmin, onChange: (isAdminNow) => {
                                    onChange?.(user, isAdminNow);
                                    trackEvent(isAdmin ? "user-role-changed-to-admin" : "user-role-changed-to-member");
                                } }))] })
                ] }), _jsx(DetailRow, { labelText: intl.formatMessage(messages.userId), value: user.login, mode: mode, disabled: true, onChange: () => { } })
        ] }));
}
//# sourceMappingURL=UserDetailsView.js.map