2020-06-09 16:34:36 -08:00
|
|
|
import { useSelector } from 'react-redux'
|
|
|
|
|
import get from 'lodash.get'
|
2020-06-09 16:29:12 -08:00
|
|
|
|
|
|
|
|
const getPerPage = (width) => {
|
|
|
|
|
if (width === 'xs') return 12
|
|
|
|
|
if (width === 'sm') return 12
|
2020-11-20 18:10:56 -09:00
|
|
|
if (width === 'md') return 12
|
2020-06-09 16:29:12 -08:00
|
|
|
if (width === 'lg') return 18
|
2020-07-29 11:41:57 -08:00
|
|
|
return 36
|
2020-06-09 16:29:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getPerPageOptions = (width) => {
|
|
|
|
|
const options = [3, 6, 12]
|
|
|
|
|
if (width === 'xs') return [12]
|
|
|
|
|
if (width === 'sm') return [12]
|
|
|
|
|
if (width === 'md') return options.map((v) => v * 4)
|
|
|
|
|
return options.map((v) => v * 6)
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-10 15:27:28 -09:00
|
|
|
export const useAlbumsPerPage = (width) => {
|
2020-06-09 16:29:12 -08:00
|
|
|
const perPage =
|
|
|
|
|
useSelector((state) =>
|
|
|
|
|
get(state.admin.resources, ['album', 'list', 'params', 'perPage'])
|
|
|
|
|
) || getPerPage(width)
|
|
|
|
|
|
|
|
|
|
return [perPage, getPerPageOptions(width)]
|
|
|
|
|
}
|