Update
This commit is contained in:
@@ -5,7 +5,7 @@ import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } f
|
||||
import { useMitt } from '@/plugins/MittContext';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
const AuthDialog = ({ onOpenChange }) => {
|
||||
const AuthDialog = ({}) => {
|
||||
const emitter = useMitt();
|
||||
|
||||
const [isLogin, setIsLogin] = useState(false);
|
||||
@@ -21,13 +21,31 @@ const AuthDialog = ({ onOpenChange }) => {
|
||||
setIsOpen(true);
|
||||
};
|
||||
|
||||
const handleOpenLogin = () => {
|
||||
setIsLogin(true);
|
||||
setIsOpen(true);
|
||||
};
|
||||
|
||||
const handleOpenJoin = () => {
|
||||
setIsLogin(false);
|
||||
setIsOpen(true);
|
||||
};
|
||||
|
||||
emitter.on('401', handleOpenAuth);
|
||||
emitter.on('login', handleOpenLogin);
|
||||
emitter.on('join', handleOpenJoin);
|
||||
|
||||
return () => {
|
||||
emitter.off('401', handleOpenAuth);
|
||||
emitter.off('login', handleOpenLogin);
|
||||
emitter.off('join', handleOpenJoin);
|
||||
};
|
||||
}, [emitter]);
|
||||
|
||||
const onOpenChange = (open) => {
|
||||
setIsOpen(open);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="sm:max-w-[400px]">
|
||||
|
||||
Reference in New Issue
Block a user