import React from "react";
import DropdownButton from "../../../../common/DropdownButton";
import Button from "../../../../shared/Button";
import { doAction } from "../../../../../hooks/useNotifications";
const renderActionButtons = (notification, action, id) => {
    if (Array.isArray(action)) {
        let buttonData = {};
        let buttonOptions = [];
        action.forEach((compositeAction, index) => {
            if (index === 0) {
                buttonData.mainAction = () => doAction && doAction(notification, compositeAction);
                buttonData.buttonLabel = compositeAction.buttonText;
            }
            else {
                buttonOptions.push({
                    buttonLabel: compositeAction.buttonText,
                    clickHandler: () => doAction && doAction(notification, compositeAction),
                });
            }
        });
        return (React.createElement(DropdownButton, { key: id, buttonLabel: buttonData.buttonLabel, mainAction: buttonData.mainAction, buttonOptions: buttonOptions }));
    }
    else {
        return (React.createElement(Button, { key: id, buttonLabel: action.buttonText, clickHandler: () => doAction && doAction(notification, action) }));
    }
};
export const NotificationCardBodyActions = ({ notification }) => {
    const { actions } = notification;
    const hasActions = actions && actions.length > 0;
    return (React.createElement(React.Fragment, null, hasActions ? (React.createElement("div", { className: "actions-panel" }, actions === null || actions === void 0 ? void 0 : actions.map((action, index) => renderActionButtons(notification, action, index)))) : null));
};
//# sourceMappingURL=NotificationCardBodyActions.js.map