Untitled

mail@pastecode.io avatar
unknown
plain_text
16 days ago
1.2 kB
3
Indexable
Never
Update the code so as to create a PrimeConfirmDialog on top of ConfirmDialog from prime react.  Also make it so that we are able to use ConfirmDialog and confirmDialog both in PrimeConfirmDialog.

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, ariaLabel, ariaLabelKey, children, ...rest } = props;
    return (
        <ConfirmDialog
            id={id ? id : uuidv4() + '_confirmDialog'}
            aria-label={props.evalLangText(ariaLabelKey, ariaLabel)}
            {...rest}>
            {children}
        </ConfirmDialog>
    );
};

PrimeConfirmDialog.propTypes = {
    /** Define/Generate a unique id for the component */
    id: PropTypes.string,
    /**aria label key*/
    ariaLabelKey: PropTypes.string,
};

PrimeConfirmDialog.defaultProps = {};

export default PrimeWrapper(PrimeConfirmDialog);
Leave a Comment