Untitled

mail@pastecode.io avatar
unknown
plain_text
14 days ago
1.7 kB
3
Indexable
Never
USE THE PROVIDED CODE(verify if it's written correctly) AND GIVE THE SAMPLE CODE TO TEST THE BELOW PROPS:- severity, summary,detail,sticky ,closable.

(TEST CODE SAMPLES)
<h5>severity props usage</h5>
                    <PrimeMessages severity="info" summary="Info" detail="Info Message" />
                    <PrimeMessages severity="success" detail="Success Message" />
                    <PrimeMessages severity="warn" detail="Warning Message" />
                    <PrimeMessages severity="error" detail="Error Message" />
                    <PrimeMessages severity="secondary" detail="Secondary Message" />
                    <PrimeMessages severity="contrast" detail="Contrast Message" />

                    <h5>closable props usage</h5>
                    <PrimeMessages severity="contrast" detail="Contrast Message" closable={true} />


CODE:

import React from 'react';
import PropTypes from 'prop-types';
import { Message } from 'primereact/message';
import PrimeWrapper from '../primeWrapper/primeWrapper';
import { v4 as uuidv4 } from 'uuid';

/** PrimeMessages Component */
const PrimeMessages = (props) => {
    // Destructure all props
    const { id, detail, detailKey, summary, summaryKey, ...rest } = props;

    return (
        <Message
            id={id ? id : uuidv4() + '_messages'}
            detail={props.evalLangText(detailKey, detail)}
            summary={props.evalLangText(summaryKey, summary)}
            {...rest}
        />
    );
};

PrimeMessages.propTypes = {
    id: PropTypes.string,
    wcmKey: PropTypes.string,
    detailKey: PropTypes.string,
    summaryKey: PropTypes.string,
};

// Export the component
export default PrimeWrapper(PrimeMessages);
Leave a Comment