UNPKG

@open-tender/store

Version:

A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our in-store POS API

25 lines (24 loc) 1.28 kB
import React, { useCallback, useMemo } from 'react'; import { useAppSelector } from '../app/hooks'; import { selectKioskConfig } from '../slices'; import { default as KeypadContainer } from './Keypad'; var MadeForName = function (_a) { var subtitle = _a.subtitle, hasMadeFor = _a.hasMadeFor, madeFor = _a.madeFor, setMadeFor = _a.setMadeFor, close = _a.close, children = _a.children, KeypadView = _a.KeypadView, title = _a.title; var _b = useAppSelector(selectKioskConfig), config = _b.keypadModal, modalContentConfig = _b.modalContent; var handlers = { submit: close }; var keypadHandlers = useMemo(function () { return ({ change: setMadeFor }); }, [setMadeFor]); var renderKeypad = useCallback(function () { return (React.createElement(KeypadContainer, { type: "default", handlers: keypadHandlers, value: madeFor !== null && madeFor !== void 0 ? madeFor : '', children: KeypadView })); }, [keypadHandlers, madeFor, KeypadView]); if (!config || !modalContentConfig || !hasMadeFor) return null; return children({ config: config, modalContentConfig: modalContentConfig, handlers: handlers, subtitle: subtitle, title: title, renderKeypad: renderKeypad }); }; export default MadeForName;