UNPKG

@brizy/media-gallery

Version:
50 lines (49 loc) 1.78 kB
import { createElement, useCallback } from "react"; import { useDispatch } from "react-redux"; import { pipe } from "ramda"; import { Footer as CFooter } from "../../../components/layouts/Footer"; import * as State from "../types/State"; import * as Actions from "../types/Actions"; import { disabled, isReadyOrBulkOrInsert, isReadyOrMultipleInsert, isWithContent } from "../utils"; import { InsertFilesTypes } from "../../../types/Context"; export var Footer = function(s) { var dispatch = useDispatch(); var onCancel = useCallback(function() { return pipe(Actions.unSelectAll, dispatch)(); }, [ dispatch ]); var onClick = useCallback(function() { return pipe(Actions.insertFiles, dispatch)(); }, [ dispatch ]); var onPrevClick = useCallback(function() { return pipe(Actions.prev, dispatch)(); }, [ dispatch ]); var onNextClick = useCallback(function() { return pipe(Actions.next, dispatch)(); }, [ dispatch ]); var isLastPage = !isWithContent(s) || s.isLastPage; var isFirstPage = !isWithContent(s) || s.page === 1; return createElement(CFooter, { onCancel: onCancel, onClick: onClick, onPrevClick: onPrevClick, onNextClick: onNextClick, previewLink: isReadyOrBulkOrInsert(s) ? s.selectedItem.url : undefined, isMultipleSelected: State.isBulkSelectMultiple(s), loading: { insertFiles: isReadyOrMultipleInsert(s) }, disabled: disabled(s), isFirstPage: isFirstPage, isLastPage: isLastPage, isWithInsertFiles: s.insertFilesType !== InsertFilesTypes.NONE, isWithImportToLibrary: s.insertFilesType === InsertFilesTypes.NONE }); };