mirror of
https://github.com/sasjs/server.git
synced 2025-12-10 19:34:34 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b243e62ece | ||
|
|
88c3056e97 | ||
| 203303b659 | |||
| 835709bd36 | |||
| 69f2576ee6 |
@@ -1,3 +1,10 @@
|
|||||||
|
## [0.28.6](https://github.com/sasjs/server/compare/v0.28.5...v0.28.6) (2023-01-26)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* show loading spinner on login screen while request is in process ([69f2576](https://github.com/sasjs/server/commit/69f2576ee6d3d7b7f3325922a88656d511e3ac88))
|
||||||
|
|
||||||
## [0.28.5](https://github.com/sasjs/server/compare/v0.28.4...v0.28.5) (2023-01-01)
|
## [0.28.5](https://github.com/sasjs/server/compare/v0.28.4...v0.28.5) (2023-01-01)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2499
api/package-lock.json
generated
2499
api/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -92,7 +92,7 @@
|
|||||||
"dotenv": "^10.0.0",
|
"dotenv": "^10.0.0",
|
||||||
"http-headers-validation": "^0.0.1",
|
"http-headers-validation": "^0.0.1",
|
||||||
"jest": "^27.0.6",
|
"jest": "^27.0.6",
|
||||||
"mongodb-memory-server": "^8.0.0",
|
"mongodb-memory-server": "8.11.4",
|
||||||
"nodejs-file-downloader": "4.10.2",
|
"nodejs-file-downloader": "4.10.2",
|
||||||
"nodemon": "^2.0.7",
|
"nodemon": "^2.0.7",
|
||||||
"pkg": "5.6.0",
|
"pkg": "5.6.0",
|
||||||
|
|||||||
@@ -2,7 +2,14 @@ import axios from 'axios'
|
|||||||
import React, { useState, useContext } from 'react'
|
import React, { useState, useContext } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
|
|
||||||
import { CssBaseline, Box, TextField, Button } from '@mui/material'
|
import {
|
||||||
|
Backdrop,
|
||||||
|
CircularProgress,
|
||||||
|
CssBaseline,
|
||||||
|
Box,
|
||||||
|
TextField,
|
||||||
|
Button
|
||||||
|
} from '@mui/material'
|
||||||
import { AppContext } from '../context/appContext'
|
import { AppContext } from '../context/appContext'
|
||||||
|
|
||||||
const login = async (payload: { username: string; password: string }) =>
|
const login = async (payload: { username: string; password: string }) =>
|
||||||
@@ -10,21 +17,27 @@ const login = async (payload: { username: string; password: string }) =>
|
|||||||
|
|
||||||
const Login = () => {
|
const Login = () => {
|
||||||
const appContext = useContext(AppContext)
|
const appContext = useContext(AppContext)
|
||||||
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
const [username, setUsername] = useState('')
|
const [username, setUsername] = useState('')
|
||||||
const [password, setPassword] = useState('')
|
const [password, setPassword] = useState('')
|
||||||
const [errorMessage, setErrorMessage] = useState('')
|
const [errorMessage, setErrorMessage] = useState('')
|
||||||
|
|
||||||
const handleSubmit = async (e: any) => {
|
const handleSubmit = async (e: any) => {
|
||||||
|
setIsLoading(true)
|
||||||
setErrorMessage('')
|
setErrorMessage('')
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
const { loggedIn, user } = await login({
|
const { loggedIn, user } = await login({
|
||||||
username,
|
username,
|
||||||
password
|
password
|
||||||
}).catch((err: any) => {
|
|
||||||
setErrorMessage(err.response?.data || err.toString())
|
|
||||||
return {}
|
|
||||||
})
|
})
|
||||||
|
.catch((err: any) => {
|
||||||
|
setErrorMessage(err.response?.data || err.toString())
|
||||||
|
return {}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setIsLoading(false)
|
||||||
|
})
|
||||||
|
|
||||||
if (loggedIn) {
|
if (loggedIn) {
|
||||||
appContext.setUserId?.(user.id)
|
appContext.setUserId?.(user.id)
|
||||||
@@ -37,42 +50,51 @@ const Login = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<>
|
||||||
className="container"
|
<Backdrop
|
||||||
component="form"
|
sx={{ color: '#fff', zIndex: (theme) => theme.zIndex.drawer + 1 }}
|
||||||
onSubmit={handleSubmit}
|
open={isLoading}
|
||||||
sx={{
|
|
||||||
'& > :not(style)': { m: 1, width: '25ch' }
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<CssBaseline />
|
|
||||||
<br />
|
|
||||||
<h2 style={{ width: 'auto' }}>Welcome to SASjs Server!</h2>
|
|
||||||
<TextField
|
|
||||||
id="username"
|
|
||||||
label="Username"
|
|
||||||
type="text"
|
|
||||||
variant="outlined"
|
|
||||||
onChange={(e: any) => setUsername(e.target.value)}
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
<TextField
|
|
||||||
id="password"
|
|
||||||
label="Password"
|
|
||||||
type="password"
|
|
||||||
variant="outlined"
|
|
||||||
onChange={(e: any) => setPassword(e.target.value)}
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
{errorMessage && <span>{errorMessage}</span>}
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
variant="outlined"
|
|
||||||
disabled={!appContext.setLoggedIn}
|
|
||||||
>
|
>
|
||||||
Submit
|
<CircularProgress color="inherit" />
|
||||||
</Button>
|
</Backdrop>
|
||||||
</Box>
|
|
||||||
|
<Box
|
||||||
|
className="container"
|
||||||
|
component="form"
|
||||||
|
onSubmit={handleSubmit}
|
||||||
|
sx={{
|
||||||
|
'& > :not(style)': { m: 1, width: '25ch' }
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CssBaseline />
|
||||||
|
<br />
|
||||||
|
<h2 style={{ width: 'auto' }}>Welcome to SASjs Server!</h2>
|
||||||
|
<TextField
|
||||||
|
id="username"
|
||||||
|
label="Username"
|
||||||
|
type="text"
|
||||||
|
variant="outlined"
|
||||||
|
onChange={(e: any) => setUsername(e.target.value)}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<TextField
|
||||||
|
id="password"
|
||||||
|
label="Password"
|
||||||
|
type="password"
|
||||||
|
variant="outlined"
|
||||||
|
onChange={(e: any) => setPassword(e.target.value)}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
{errorMessage && <span>{errorMessage}</span>}
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
variant="outlined"
|
||||||
|
disabled={!appContext.setLoggedIn}
|
||||||
|
>
|
||||||
|
Submit
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user