-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add error type from Feathers * Update LoginForm.tsx * add error from API in LoginModal * Update entities.mdx * improve secondary button style * fix image layout in markdown * fixupdatenotebooks to update only notebooks without the SHA or with a different SHA --------- Co-authored-by: Daniele Guido <[email protected]>
- Loading branch information
1 parent
38407d3
commit 06da915
Showing
10 changed files
with
170 additions
and
118 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
import { | ||
BadRequest, | ||
NotAuthenticated, | ||
type FeathersError, | ||
} from "@feathersjs/errors" | ||
import React, { useRef } from "react" | ||
import { Form } from "react-bootstrap" | ||
import { useBrowserStore } from "../store" | ||
import { BrowserViewRegister } from "../constants" | ||
|
||
export interface LoginFormPayload { | ||
email: string | ||
|
@@ -9,37 +16,96 @@ export interface LoginFormPayload { | |
export interface LoginFormProps { | ||
className?: string | ||
onSubmit: (payload: LoginFormPayload) => void | ||
error?: FeathersError | null | ||
} | ||
|
||
const LoginForm: React.FC<LoginFormProps> = ({ className, onSubmit }) => { | ||
const LoginForm: React.FC<LoginFormProps> = ({ | ||
className, | ||
onSubmit, | ||
error, | ||
}) => { | ||
const setView = useBrowserStore((state) => state.setView) | ||
const formPayload = useRef({ email: "", password: "" }) | ||
const handleOnSubmit = (e: React.FormEvent<HTMLFormElement>) => { | ||
e.preventDefault() | ||
console.info("[LoginForm] @handleOnSubmit") | ||
onSubmit(formPayload.current) | ||
} | ||
|
||
console.info("[LoginForm] @render", { error }) | ||
let errorMessages: { key: string; message: string }[] = [] | ||
|
||
if (error instanceof BadRequest && error.data) { | ||
errorMessages = Object.keys(error.data).map((key) => { | ||
return { key, message: error.data[key].message } | ||
}) | ||
} else if (error instanceof NotAuthenticated) { | ||
errorMessages = [{ key: "Error", message: error.message }] | ||
} else if (error) { | ||
errorMessages = [{ key: "Error", message: error.message }] | ||
} | ||
return ( | ||
<Form onSubmit={handleOnSubmit} className={`LoginForm ${className}`}> | ||
<Form.Group className="mb-3" controlId="ModalLoginForm.email"> | ||
<Form.Label className="font-weight-bold">Email address</Form.Label> | ||
<Form.Control | ||
onChange={(e) => (formPayload.current.email = e.target.value)} | ||
type="email" | ||
placeholder="[email protected]" | ||
/> | ||
</Form.Group> | ||
<Form.Group className="mb-3" controlId="ModalLoginForm.password"> | ||
<Form.Label className="font-weight-bold">Password</Form.Label> | ||
<Form.Control | ||
onChange={(e) => (formPayload.current.password = e.target.value)} | ||
type="password" | ||
/> | ||
</Form.Group> | ||
<button type="submit" className="btn btn-primary"> | ||
Log in | ||
</button> | ||
</Form> | ||
<> | ||
<Form onSubmit={handleOnSubmit} className={`LoginForm ${className}`}> | ||
{errorMessages.length > 0 ? ( | ||
<div className="alert alert-danger" role="alert"> | ||
<ul className="list-unstyled m-0"> | ||
{errorMessages.map((d, _i) => ( | ||
<li key={_i}> | ||
<b>{d.key}</b>: | ||
{d.message} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
) : null} | ||
<Form.Group className="mb-3" controlId="ModalLoginForm.email"> | ||
<Form.Label className="font-weight-bold">Email address</Form.Label> | ||
<Form.Control | ||
onChange={(e) => (formPayload.current.email = e.target.value)} | ||
type="email" | ||
placeholder="[email protected]" | ||
/> | ||
</Form.Group> | ||
<Form.Group className="mb-3" controlId="ModalLoginForm.password"> | ||
<Form.Label className="font-weight-bold">Password</Form.Label> | ||
<Form.Control | ||
onChange={(e) => (formPayload.current.password = e.target.value)} | ||
type="password" | ||
/> | ||
</Form.Group> | ||
<div className=""> | ||
<button | ||
type="submit" | ||
className="btn btn-primary w-100 d-flex justify-content-center px-5" | ||
> | ||
Log in | ||
</button> | ||
</div> | ||
</Form> | ||
{/* Did you forget your password? */} | ||
<p className="mt-3"> | ||
Did you forget your password?{" "} | ||
<a href="https://impresso-project.ch/app/password-reset"> | ||
Reset your password | ||
</a> | ||
</p> | ||
<p className="my-3 py-3 gap-3 border-top border-bottom d-flex align-items-center"> | ||
Don't have an account? | ||
<button | ||
onClick={() => setView(BrowserViewRegister)} | ||
className="btn btn-secondary px-5" | ||
> | ||
Register | ||
</button> | ||
</p> | ||
|
||
<p className="mt-2"> | ||
Any Questions? <br /> | ||
Contact us at{" "} | ||
<a href="mailto:[email protected]">[email protected]</a> | ||
</p> | ||
</> | ||
) | ||
} | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.MarkdownSnippet img { | ||
max-width: 100%; | ||
height: auto; | ||
display: block; | ||
margin: 0 auto; | ||
} |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
--- | ||
title: Explore and Visualise your Impresso Data | ||
excerpt: "Notebook templates offer complementary views on your Impresso personal collections and external datasets beyond the capabilities of the Impresso Web App." | ||
excerpt: "" | ||
notebooks: | ||
- impresso-py-maps | ||
- impresso-py-network | ||
category: | ||
- explorations | ||
position: central-column | ||
--- | ||
|
||
Notebook templates offer complementary views on your Impresso personal collections and external datasets beyond the capabilities of the Impresso Web App. |
Oops, something went wrong.