"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const system_1 = require("@mui/system");
const styles_1 = require("@mui/material/styles");
const react_intl_1 = require("react-intl");
const react_core_1 = require("@selfcommunity/react-core");
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const CreateEventButton_1 = tslib_1.__importDefault(require("../CreateEventButton"));
const PREFIX = 'SCEditEventButton';
const classes = {
    root: `${PREFIX}-root`
};
const Root = (0, styles_1.styled)(CreateEventButton_1.default, {
    name: PREFIX,
    slot: 'Root',
    overridesResolver: (props, styles) => styles.root
})(({ theme }) => ({}));
/**
 *> API documentation for the Community-JS Create Event Button component. Learn about the available props and the CSS API.
 *
 #### Import
 ```jsx
 import {CreateEventButton} from '@selfcommunity/react-ui';
 ```

 #### Component Name
 The name `SCEditEventButton` can be used when providing style overrides in the theme.

 #### CSS

 |Rule Name|Global class|Description|
 |---|---|---|
 |root|.SCEditEventButton-root|Styles applied to the root element.|

 * @param inProps
 */
function EditEventButton(inProps) {
    //PROPS
    const props = (0, system_1.useThemeProps)({
        props: inProps,
        name: PREFIX
    });
    const { className, eventId, event, onEditSuccess } = props, rest = tslib_1.__rest(props, ["className", "eventId", "event", "onEditSuccess"]);
    const { scEvent, setSCEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
    const scUserContext = (0, react_core_1.useSCUser)();
    const handleSuccess = (data) => {
        setSCEvent(data);
        onEditSuccess && onEditSuccess(data);
    };
    if (!scUserContext.user) {
        return null;
    }
    /**
     * Renders root object
     */
    return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ variant: "outlined", className: (0, classnames_1.default)(classes.root, className), EventFormDialogComponentProps: { EventFormComponentProps: { event: scEvent, onSuccess: handleSuccess } } }, rest, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.editEventButton", defaultMessage: "ui.editEventButton" }) })));
}
exports.default = EditEventButton;
