mirror of
https://github.com/vercel/commerce.git
synced 2025-07-27 04:01:23 +00:00
✨ feat: open modal authen from the header
:%s
This commit is contained in:
23
src/components/hooks/useModalCommon.tsx
Normal file
23
src/components/hooks/useModalCommon.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import { useState } from 'react';
|
||||
|
||||
interface Props {
|
||||
initialValue?: boolean,
|
||||
}
|
||||
|
||||
export const useModalCommon = ({ initialValue = false }: Props) => {
|
||||
const [visible, setVisible] = useState<boolean>(initialValue)
|
||||
|
||||
const openModal = (e?: any) => {
|
||||
e && e.stopPropagation()
|
||||
setVisible(true)
|
||||
}
|
||||
|
||||
const closeModal = (e?: any) => {
|
||||
e && e.stopPropagation()
|
||||
setVisible(false)
|
||||
}
|
||||
|
||||
return {
|
||||
visible, openModal, closeModal
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user