Sha256: 79f7d2f0693534f3551b6b55c0c9fa624c3b88b6b6d8b723847290249069202f
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 KB
Contents
import React, { useState, useReducer } from "react"; import { Button, buttons } from "../types/button"; import { ModalProps } from "../components/buttons_modal"; export type ModalSetting = { toggleModal: any; setCallbackOnSubmit: any; setCallbackOnClose: any; setTitle: any; setPrefillButtons: any; } type openModalParams = { title: string, prefill: any, callbackOnSubmit: any, }; export const useModal = () => { const [visible, toggleModal] = useReducer(((m: boolean) => { return !m; }), false); const [callbackOnSubmit, setCallbackOnSubmit] = useState(undefined as any) const [callbackOnClose, setCallbackOnClose] = useState(undefined as any) const [title, setTitle] = useState("") const [prefill, setPrefillButtons] = useState<Array<Button>>([]) const openModal = ({ title, prefill, callbackOnSubmit }: openModalParams): void => { toggleModal(); setTitle(title) setPrefillButtons(prefill); setCallbackOnSubmit(() => callbackOnSubmit); setCallbackOnClose(() => toggleModal); } const modalProps: ModalProps = { visible, callbackOnSubmit, callbackOnClose, title, prefill }; const modalSetting: ModalSetting ={ toggleModal, setCallbackOnSubmit, setCallbackOnClose, setTitle, setPrefillButtons }; return [modalProps, openModal] as const; }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
procon_bypass_man-web-0.1.3 | src/hooks/useModal.ts |
procon_bypass_man-web-0.1.2 | src/hooks/useModal.ts |