-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(log): Fixed log crashing when user was not loaded
- Loading branch information
1 parent
30d710f
commit e425f16
Showing
4 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/components/shared/Layout/nav/CustomTokenDialog/CustomTokenDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { | ||
Button, | ||
Dialog, | ||
DialogActions, | ||
DialogContent, | ||
TextField, | ||
} from "@mui/material"; | ||
import { DialogTitleWithCloseButton } from "components/shared/DialogTitleWithCloseButton"; | ||
import { loginWithToken } from "lib/auth.lib"; | ||
import { useState } from "react"; | ||
|
||
export interface CustomTokenDialogProps { | ||
open: boolean; | ||
onClose: () => void; | ||
} | ||
|
||
export function CustomTokenDialog(props: CustomTokenDialogProps) { | ||
const { open, onClose } = props; | ||
|
||
const [token, setToken] = useState(""); | ||
const handleLogin = () => { | ||
loginWithToken(token) | ||
.then(() => { | ||
location.reload(); | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
}); | ||
}; | ||
|
||
return ( | ||
<Dialog open={open} onClose={onClose}> | ||
<DialogTitleWithCloseButton onClose={onClose}> | ||
Login with Custom Token | ||
</DialogTitleWithCloseButton> | ||
<DialogContent> | ||
<TextField | ||
sx={{ mt: 0.5 }} | ||
label={"Token"} | ||
value={token} | ||
onChange={(evt) => setToken(evt.target.value)} | ||
/> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button color={"inherit"} onClick={onClose}> | ||
Cancel | ||
</Button> | ||
<Button variant={"contained"} onClick={handleLogin}> | ||
Login | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters