@brizy/media-gallery
Version:
56 lines (55 loc) • 1.95 kB
JavaScript
import { createElement, useCallback } from "react";
import { useDispatch } from "react-redux";
import { pipe } from "ramda";
import { Footer as CFooter } from "../../../components/layouts/Footer";
import * as Actions from "../types/Actions";
import * as GlobalActions from "../../../global/actions";
import { disabled, isMultipleSelected, isReadyOrBulk, isReadyOrNothingOrBulk, isRemoving } from "../utils";
import { MEDIA_LIBRARY_LIMIT } from "../../../constants";
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(GlobalActions.insertFile, dispatch)();
}, [
dispatch
]);
var onDelete = useCallback(function() {
return pipe(Actions.remove, dispatch)();
}, [
dispatch
]);
var onPrevClick = useCallback(function() {
return pipe(Actions.prev, dispatch)();
}, [
dispatch
]);
var onNextClick = useCallback(function() {
return pipe(Actions.next, dispatch)();
}, [
dispatch
]);
var isLastPage = !isReadyOrNothingOrBulk(s) || s.items.length < MEDIA_LIBRARY_LIMIT;
var isFirstPage = !isReadyOrNothingOrBulk(s) || s.page === 1;
return createElement(CFooter, {
onCancel: onCancel,
onClick: onClick,
onDelete: onDelete,
onPrevClick: onPrevClick,
onNextClick: onNextClick,
previewLink: isReadyOrBulk(s) ? s.selectedItem.url : undefined,
isMultipleSelected: isMultipleSelected(s),
loading: {
delete: isRemoving(s)
},
disabled: disabled(s),
isFirstPage: isFirstPage,
isLastPage: isLastPage,
isWithInsertFiles: s.insertFilesType !== InsertFilesTypes.NONE
});
};