Add owner_id to playlist

This commit is contained in:
Deluan
2021-10-29 22:55:28 -04:00
committed by Deluan Quintão
parent 84bbcdbfc2
commit 133fed344f
38 changed files with 173 additions and 100 deletions
+6 -6
View File
@@ -1,19 +1,19 @@
import { cloneElement, Children, isValidElement } from 'react'
export const isWritable = (owner) => {
export const isWritable = (ownerId) => {
return (
localStorage.getItem('username') === owner ||
localStorage.getItem('userId') === ownerId ||
localStorage.getItem('role') === 'admin'
)
}
export const isReadOnly = (owner) => {
return !isWritable(owner)
export const isReadOnly = (ownerId) => {
return !isWritable(ownerId)
}
export const Writable = (props) => {
const { record = {}, children } = props
if (isWritable(record.owner)) {
if (isWritable(record.ownerId)) {
return Children.map(children, (child) =>
isValidElement(child) ? cloneElement(child, props) : child
)
@@ -24,4 +24,4 @@ export const Writable = (props) => {
export const isSmartPlaylist = (pls) => !!pls.rules
export const canChangeTracks = (pls) =>
isWritable(pls.owner) && !isSmartPlaylist(pls)
isWritable(pls.ownerId) && !isSmartPlaylist(pls)