Only allows adding to a writable playlist

This commit is contained in:
Deluan
2020-06-05 10:26:53 -04:00
parent 39afe0c669
commit 4906b816af
4 changed files with 6 additions and 3 deletions
+22
View File
@@ -0,0 +1,22 @@
import { cloneElement } from 'react'
export const isWritable = (owner) => {
return (
localStorage.getItem('username') === owner ||
localStorage.getItem('role') === 'admin'
)
}
export const isReadOnly = (owner) => {
return !isWritable(owner)
}
const Writable = (props) => {
const { record, children } = props
if (isWritable(record.owner)) {
return cloneElement(children, props)
}
return null
}
export default Writable