Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
({ selectedIds, albumId, onClose, onItemAdded }, ref) => {
const notify = useNotify()
const translate = useTranslate()
const dataProvider = useDataProvider()
const { ids, data, loaded } = useGetList(
'playlist',
{ page: 1, perPage: -1 },
{ field: 'name', order: 'ASC' },
{}
)
if (!loaded) {
return <menuitem>Loading...</menuitem>
}
// TODO: This is temporary, while we don't have the "New Playlist" option in the menu
if (ids.length === 0) {
return (
<menuitem> {
e.stopPropagation()</menuitem>
const PlaylistSubmenu = ({
isSidebarOpen,
isToggled,
name,
dense,
handleToggle,
onMenuClick,
}) => {
const refresh = useRefresh()
const [playLists, setPlaylists] = useState([])
const { data } = useGetList(
'playlist',
{ page: 1, perPage: -1 },
{ field: 'name', order: 'ASC' },
{}
)
useEffect(() => {
if (data && typeof data === 'object') {
const isEmpty = !Object.keys(data).length
if (!isEmpty) {
setPlaylists(Object.values(data))
} else if (isEmpty && playLists.length) {
refresh()
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
const CustomRouteLayout = () => {
useAuth();
const { total, loaded } = useGetList(
'posts',
{ page: 1, perPage: 10 },
{ field: 'published_at', order: 'DESC' }
);
return loaded ? (
<div>
<title title="Example Admin">
<h1>Posts</h1>
<p>
Found <span className="total">{total}</span> posts !
</p>
</div>
) : null;
};
</title></div>
const GridButton = (props) => {
const dispatch = useDispatch()
const { ids, data, loading, error } = useGetList(
'albumSong',
{ },
{ field: 'trackNumber', order: 'ASC' },
{ album_id: props.id},
)
if (loading) {
return (
)
}
if (error) {
return (
const EventList = ({ record, basePath }) => {
const translate = useTranslate();
const { data: orders, ids: orderIds } = useGetList(
'commands',
{ page: 1, perPage: 100 },
{ field: 'date', order: 'DESC' },
{ customer_id: record && record.id }
);
const { data: reviews, ids: reviewIds } = useGetList(
'reviews',
{ page: 1, perPage: 100 },
{ field: 'date', order: 'DESC' },
{ customer_id: record && record.id }
);
const events = mixOrdersAndReviews(orders, orderIds, reviews, reviewIds);
return (
<>
{translate(
'resources.customers.fieldGroups.history'
)}
const AlbumSongList = (props) => {
const dispatch = useDispatch()
const { record } = props
const { data, total, loading, error } = useGetList(
'song',
{ page: 0, perPage: 100 },
{ field: 'album', order: 'ASC' },
{ album_id: record.id }
)
if (error) {
return <p>ERROR: {error}</p>
}
const trackName = (r) => {
const name = r.title
if (r.trackNumber) {
return r.trackNumber.toString().padStart(2, '0') + ' ' + name
}
return name
const EventList = ({ record, basePath }) => {
const translate = useTranslate();
const { data: orders, ids: orderIds } = useGetList(
'commands',
{ page: 1, perPage: 100 },
{ field: 'date', order: 'DESC' },
{ customer_id: record && record.id }
);
const { data: reviews, ids: reviewIds } = useGetList(
'reviews',
{ page: 1, perPage: 100 },
{ field: 'date', order: 'DESC' },
{ customer_id: record && record.id }
);
const events = mixOrdersAndReviews(orders, orderIds, reviews, reviewIds);
return (
<>
const useGetLanguageChoices = () => {
const { ids, data, loaded, loading } = useGetList(
'translation',
{ page: 1, perPage: -1 },
{ field: '', order: '' },
{}
)
const choices = [{ id: 'en', name: 'English' }]
if (loaded) {
ids.forEach((id) => choices.push({ id: id, name: data[id].name }))
}
choices.sort((a, b) => a.name.localeCompare(b.name))
return { choices, loaded, loading }
}
export const SelectPlaylistInput = ({ onChange }) => {
const classes = useStyles()
const translate = useTranslate()
const { ids, data } = useGetList(
'playlist',
{ page: 1, perPage: -1 },
{ field: 'name', order: 'ASC' },
{}
)
const options =
ids &&
ids.map((id) => data[id]).filter((option) => isWritable(option.owner))
const handleOnChange = (event, newValue) => {
let newState = []
if (newValue && newValue.length) {
newValue.forEach((playlistObject) => {
if (playlistObject.inputValue) {
newState.push({