({
isOpen,
setIsOpen,
redirectUrl = { pathname: "graph" },
signInText = "Sign in to your account"
})
| 58 | } |
| 59 | |
| 60 | const AuthDialog: FC<AuthDialogProps> = ({ |
| 61 | isOpen, |
| 62 | setIsOpen, |
| 63 | redirectUrl = { pathname: "graph" }, |
| 64 | signInText = "Sign in to your account" |
| 65 | }) => { |
| 66 | const navigate = useNavigate(); |
| 67 | |
| 68 | const [authDialogState, setAuthDialogState] = useState(AuthDialogState.LOGIN); |
| 69 | const [authApiErrorMessage, setAuthApiErrorMessage] = useState<string | null>( |
| 70 | null, |
| 71 | ); |
| 72 | const [verifyEmailMessage, setVerifyEmailMessage] = useState<string | null>( |
| 73 | null, |
| 74 | ); |
| 75 | |
| 76 | const redirectOnLogin = (userID: string) => { |
| 77 | |
| 78 | const { pathname, queryParams } = redirectUrl; |
| 79 | |
| 80 | const url: { pathname: string; search: string } = { |
| 81 | pathname, |
| 82 | search: "" |
| 83 | } |
| 84 | |
| 85 | url.pathname = `/${userID}/${pathname}`; |
| 86 | |
| 87 | if (queryParams) { |
| 88 | const searchParams = new URLSearchParams(queryParams); |
| 89 | url.search = searchParams.toString(); |
| 90 | |
| 91 | } |
| 92 | |
| 93 | navigate(url); |
| 94 | |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Resets the authApiErrorMessage state to null |
| 99 | * |
| 100 | * @returns void |
| 101 | */ |
| 102 | const resetAuthApiErrorMessage = () => { |
| 103 | setAuthApiErrorMessage(null); |
| 104 | }; |
| 105 | |
| 106 | /** |
| 107 | * Closes the dialog and resets the state to LOGIN |
| 108 | * |
| 109 | * @returns void |
| 110 | */ |
| 111 | const closeDialog = () => { |
| 112 | setIsOpen(false); |
| 113 | setAuthDialogState(AuthDialogState.LOGIN); |
| 114 | setAuthApiErrorMessage(null); |
| 115 | setVerifyEmailMessage(null); |
| 116 | }; |
| 117 |
nothing calls this directly
no test coverage detected