Untitled

mail@pastecode.io avatar
unknown
plain_text
12 days ago
1.9 kB
4
Indexable
Never
import React from 'react';
import PrimeWrapper from '../primeWrapper/primeWrapper';
import { ConfirmDialog } from 'primereact/confirmdialog'; // For <ConfirmDialog /> component
import { confirmDialog } from 'primereact/confirmdialog'; // For confirmDialog method
import { v4 as uuidv4 } from 'uuid';
import PropTypes from 'prop-types';

const PrimeConfirmDialog = (props) => {
    const {
        id,
        header,
        headerKey,
        footer,
        footerKey,
        message,
        messageKey,
        ariaLabel,
        ariaLabelKey,
        children,
        ...rest
    } = props;
    return (
        <ConfirmDialog
            id={id ? id : uuidv4() + '_confirmDialog'}
            header={props.evalLangText(headerKey, header)}
            footer={props.evalLangText(footerKey, footer)}
            message={props.evalLangText(messageKey, message)}
            aria-label={props.evalLangText(ariaLabelKey, ariaLabel)}
            {...rest}>
            {children}
        </ConfirmDialog>
    );
};

// Expose the programmatic confirmDialog function as a static method
export const confirmDialogMethod = (options) => {
    confirmDialog(options);
};

PrimeConfirmDialog.propTypes = {
    confirmDialogMethod: PropTypes.func,
    /** Define/Generate a unique id for the component */
    id: PropTypes.string,
    /**aria label key*/
    ariaLabelKey: PropTypes.string,
    /** Accepts a Content Manager key and assigns the value to the Header of the confirm dialog. */
    headerKey: PropTypes.string,
    /** Accepts a Content Manager key and assigns the value to the Footer of the confirm dialog. */
    footerKey: PropTypes.string,
    /** Accepts a Content Manager key and assigns the value to the Message of the confirmation. */
    messageKey: PropTypes.string,
};

PrimeConfirmDialog.defaultProps = {};

export default PrimeWrapper(PrimeConfirmDialog);

Leave a Comment