|
1 | 1 | import React from "react";
|
2 | 2 | import {Container, Navbar} from "react-bootstrap";
|
| 3 | +import {useLoginMutation} from "../api/services/auth"; |
| 4 | +import {setCredentials} from "../api/authSlice"; |
| 5 | +import {useDispatch} from "react-redux"; |
| 6 | +import {Link} from "react-router-dom"; |
3 | 7 |
|
4 | 8 | export const MainNavbar: React.FC = () => {
|
| 9 | + const [login, { isLoading }] = useLoginMutation() |
| 10 | + const dispatch = useDispatch() |
| 11 | + |
5 | 12 | return (
|
6 | 13 | <Navbar className="bg-body-tertiary">
|
7 | 14 | <Container fluid>
|
8 | 15 | <Navbar.Brand href="#home" className="align-items-center d-flex">
|
9 |
| - <svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" fill="currentColor" |
10 |
| - className="bi bi-play-fill" viewBox="0 0 16 16"> |
11 |
| - <path |
12 |
| - d="m11.596 8.697-6.363 3.692c-.54.313-1.233-.066-1.233-.697V4.308c0-.63.692-1.01 1.233-.696l6.363 3.692a.802.802 0 0 1 0 1.393"/> |
| 16 | + <svg width="64" height="64" xmlns="http://www.w3.org/2000/svg" className="pe-3"> |
| 17 | + <image href="assets/images/BBDatastorePlaygroundLogo.svg" height="64" width="64"/> |
13 | 18 | </svg>
|
14 | 19 | {' '}
|
15 | 20 | BB Datastore Playground
|
16 | 21 | </Navbar.Brand>
|
| 22 | + <div className="text-end"> |
| 23 | + <Link |
| 24 | + className="btn btn-outline-dark" |
| 25 | + role="button" |
| 26 | + to="/about" |
| 27 | + > |
| 28 | + about |
| 29 | + </Link> |
| 30 | + <button |
| 31 | + type="button" |
| 32 | + className="btn btn-dark me-2" |
| 33 | + onClick={async () => { |
| 34 | + try { |
| 35 | + const user = await login().unwrap() |
| 36 | + dispatch(setCredentials(user)) |
| 37 | + } catch (err) { |
| 38 | + // toast({ |
| 39 | + // status: 'error', |
| 40 | + // title: 'Error', |
| 41 | + // description: 'Oh no, there was an error!', |
| 42 | + // isClosable: true, |
| 43 | + // }) |
| 44 | + } |
| 45 | + }} |
| 46 | + > |
| 47 | + <div className="align-items-center d-flex gap-2"> |
| 48 | + <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" |
| 49 | + className="bi bi-github" viewBox="0 0 16 16"> |
| 50 | + <path |
| 51 | + d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8"/> |
| 52 | + </svg> |
| 53 | + Login |
| 54 | + </div> |
| 55 | + </button> |
| 56 | + </div> |
17 | 57 | </Container>
|
18 | 58 | </Navbar>
|
19 | 59 | );
|
|
0 commit comments