How to use the react-admin.useGetList function in react-admin

To help you get started, we’ve selected a few react-admin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github navidrome / navidrome / ui / src / common / AddToPlaylistMenu.js View on Github external
({ 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>
github navidrome / navidrome / ui / src / layout / PlaylistSubmenu.js View on Github external
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
github marmelab / react-admin / examples / simple / src / customRouteLayout.js View on Github external
const CustomRouteLayout = () =&gt; {
    useAuth();
    const { total, loaded } = useGetList(
        'posts',
        { page: 1, perPage: 10 },
        { field: 'published_at', order: 'DESC' }
    );

    return loaded ? (
        <div>
            <title title="Example Admin">
            &lt;h1&gt;Posts&lt;/h1&gt;
            &lt;p&gt;
                Found &lt;span className="total"&gt;{total}&lt;/span&gt; posts !
            &lt;/p&gt;
        &lt;/div&gt;
    ) : null;
};
</title></div>
github navidrome / navidrome / ui / src / album / GridButton.js View on Github external
const GridButton = (props) =&gt; {
const dispatch = useDispatch()
const { ids, data, loading, error } = useGetList(
	'albumSong', 
	{  }, 
	{ field: 'trackNumber', order: 'ASC' }, 
	{ album_id: props.id},
	)

	if (loading) {
	    return (
	      
	        
	      
	    )
	}

	if (error) {
	    return (
github marmelab / react-admin / examples / demo / src / visitors / Aside.js View on Github external
const EventList = ({ record, basePath }) =&gt; {
    const translate = useTranslate();
    const { data: orders, ids: orderIds } = useGetList(
        'commands',
        { page: 1, perPage: 100 },
        { field: 'date', order: 'DESC' },
        { customer_id: record &amp;&amp; record.id }
    );
    const { data: reviews, ids: reviewIds } = useGetList(
        'reviews',
        { page: 1, perPage: 100 },
        { field: 'date', order: 'DESC' },
        { customer_id: record &amp;&amp; record.id }
    );
    const events = mixOrdersAndReviews(orders, orderIds, reviews, reviewIds);

    return (
        &lt;&gt;
            
                
                    
                        
                            {translate(
                                'resources.customers.fieldGroups.history'
                            )}
github navidrome / navidrome / ui / src / album / AlbumSongList.js View on Github external
const AlbumSongList = (props) =&gt; {
  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) =&gt; {
    const name = r.title
    if (r.trackNumber) {
      return r.trackNumber.toString().padStart(2, '0') + ' ' + name
    }
    return name
github marmelab / react-admin / examples / demo / src / visitors / Aside.js View on Github external
const EventList = ({ record, basePath }) =&gt; {
    const translate = useTranslate();
    const { data: orders, ids: orderIds } = useGetList(
        'commands',
        { page: 1, perPage: 100 },
        { field: 'date', order: 'DESC' },
        { customer_id: record &amp;&amp; record.id }
    );
    const { data: reviews, ids: reviewIds } = useGetList(
        'reviews',
        { page: 1, perPage: 100 },
        { field: 'date', order: 'DESC' },
        { customer_id: record &amp;&amp; record.id }
    );
    const events = mixOrdersAndReviews(orders, orderIds, reviews, reviewIds);

    return (
        &lt;&gt;
github navidrome / navidrome / ui / src / i18n / useGetLanguageChoices.js View on Github external
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 }
}
github navidrome / navidrome / ui / src / dialogs / SelectPlaylistInput.js View on Github external
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({