forked from reanahub/reana-ui
-
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.
* maint-0.7: release: 0.7.2 auth: hide SSO sign up notification ui: added privacy policy page with RoPo content auth: adjust success messages to user confirmation auth: clear notifications before sign in/up auth: display server confirmation success message auth: display notification when signing up via SSO auth: add route to handle email confirmation auth: show proper notifications when signing in/up ui: make notifications more generic ui: control signup form visibility with configs ui: show more meaningful errors ui: split Signin component into two separate components addresses reanahub/reana#469
- Loading branch information
Showing
14 changed files
with
653 additions
and
92 deletions.
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
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
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,32 @@ | ||
/* | ||
-*- coding: utf-8 -*- | ||
This file is part of REANA. | ||
Copyright (C) 2020 CERN. | ||
REANA is free software; you can redistribute it and/or modify it | ||
under the terms of the MIT License; see LICENSE file for more details. | ||
*/ | ||
|
||
import { useDispatch } from "react-redux"; | ||
import { useHistory, useLocation } from "react-router-dom"; | ||
|
||
export function useSubmit(action) { | ||
const dispatch = useDispatch(); | ||
const history = useHistory(); | ||
const location = useLocation(); | ||
|
||
const handleSubmit = (event, formData, setFormData) => { | ||
const { from } = location.state || { from: { pathname: "/" } }; | ||
dispatch(action(formData)).then((res) => { | ||
if (res.isAxiosError ?? false) { | ||
setFormData({ ...formData, password: "" }); | ||
} else { | ||
history.replace(from); | ||
} | ||
}); | ||
event.preventDefault(); | ||
}; | ||
|
||
return handleSubmit; | ||
} |
Oops, something went wrong.