Files
konstitisyon.nu/components/konstitisyon/comments/handle-comments.js
T

58 lines
1.4 KiB
JavaScript
Raw Normal View History

'use client'
import PropTypes from 'prop-types'
import WriteComment from './write-comment.js'
import ReadComments from './read-comments.js'
export default function HandleComments({
session,
selectedTitre,
isOpen,
setIsOpen,
setError,
setSuccess,
setIsErrorAlertOpen,
setIsSuccessAlertOpen,
operation
}) {
if (operation === 'write') {
return (
<WriteComment
session={session}
selectedTitre={selectedTitre}
isOpen={isOpen}
setIsOpen={setIsOpen}
setError={setError}
setSuccess={setSuccess}
setIsErrorAlertOpen={setIsErrorAlertOpen}
setIsSuccessAlertOpen={setIsSuccessAlertOpen}
/>
)
}
if (operation === 'read') {
return (
<ReadComments
session={session}
selectedTitre={selectedTitre}
isOpen={isOpen}
setIsOpen={setIsOpen}
setError={setError}
setIsErrorAlertOpen={setIsErrorAlertOpen}
/>
)
}
}
HandleComments.propTypes = {
session: PropTypes.object,
selectedTitre: PropTypes.object.isRequired,
isOpen: PropTypes.bool.isRequired,
setIsOpen: PropTypes.func.isRequired,
setError: PropTypes.func.isRequired,
setSuccess: PropTypes.func.isRequired,
setIsErrorAlertOpen: PropTypes.func.isRequired,
setIsSuccessAlertOpen: PropTypes.func.isRequired,
operation: PropTypes.oneOf(['write', 'read']).isRequired
}