-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete account view #461
Open
mmircea16
wants to merge
5
commits into
develop
Choose a base branch
from
delete-account
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+107
−0
Open
Delete account view #461
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
26d8ca0
Adding delete account
mmircea16 d0271c7
Using the identity server URL
mmircea16 a2b5fcb
Fixing browser warning
mmircea16 62e0661
Update frontend/src/components/DeleteAccount/index.js
mmircea16 9acf30c
Merge branch 'develop' into delete-account
RaduCStefanescu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import axios from "axios"; | ||
import { Constants } from "../config/constants"; | ||
|
||
const api = axios.create({ | ||
baseURL: `${Constants.idpUrl}/api` | ||
}); | ||
|
||
const AccountApi = { | ||
deleteAccount: (user, password) => | ||
api.post("/DeleteAccount", { Username: user, Password: password }) | ||
}; | ||
|
||
export default AccountApi; |
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,81 @@ | ||
import React, { useState } from "react"; | ||
import SidebarLayout from "../SidebarLayout"; | ||
import AccountApi from "../../api/accountApi"; | ||
import "./style.scss"; | ||
import { removeUser } from "../../api/auth"; | ||
const DeleteAccount = () => { | ||
const [user, setUser] = useState(""); | ||
const [password, setPassword] = useState(""); | ||
const [loading, setLoading] = useState(false); | ||
const [errorDeleting, setErrorDeleting] = useState(false); | ||
|
||
const fieldsFilled = user && password; | ||
|
||
const updateUser = event => setUser(event.target.value); | ||
const updatePassword = event => setPassword(event.target.value); | ||
|
||
const deleteProfile = () => { | ||
setLoading(true); | ||
AccountApi.deleteAccount(user, password) | ||
.then(() => { | ||
setLoading(false); | ||
}) | ||
.then(removeUser) | ||
.catch(() => { | ||
setErrorDeleting(true); | ||
setLoading(false); | ||
}); | ||
}; | ||
|
||
const buttonClasses = "button is-danger" + (loading ? " is-loading" : ""); | ||
return ( | ||
<SidebarLayout> | ||
<div> | ||
Contul tău va fi șters. Pentru a putea reutiliza această aplicație va | ||
trebui să îți refaci contul de utilizator. Informațiile pe care le-ai | ||
transmis pana acum prin intermediul aplicație vor rămâne stocate în baza | ||
de date. Dacă dorești ca toate informațiile sa fie eliminate din baza de | ||
date te rugam sa adresezi aceasta cerere către: | ||
mmircea16 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<p>Adresa: Strada Italiană, nr. 22, Sector 2, 020976, București</p> | ||
<p>E-mail: [email protected]</p> | ||
</div> | ||
<form onSubmit={() => {}}> | ||
<div className="field"> | ||
<label className="label">Email</label> | ||
<input | ||
className="input is-medium" | ||
type="text" | ||
placeholder="Email" | ||
value={user} | ||
onChange={updateUser} | ||
/> | ||
</div> | ||
<div className="field"> | ||
<label className="label">Parola</label> | ||
<input | ||
className="input is-medium" | ||
type="password" | ||
placeholder="Parola" | ||
value={password} | ||
onChange={updatePassword} | ||
/> | ||
</div> | ||
<div className="field"> | ||
<button | ||
className={buttonClasses} | ||
onClick={deleteProfile} | ||
disabled={!fieldsFilled || loading} | ||
> | ||
Șterge cont | ||
</button> | ||
</div> | ||
</form> | ||
<div className="notification is-warning" hidden={!errorDeleting}> | ||
<button className="delete" onClick={() => setErrorDeleting(false)} /> | ||
Încercarea de ștergere a eșuat! | ||
</div> | ||
</SidebarLayout> | ||
); | ||
}; | ||
|
||
export default DeleteAccount; |
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,3 @@ | ||
.notification { | ||
margin-top: 1em; | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we pass the user and not taking it from the session ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point! Had a chat with @RaduCStefanescu and my takeaway was we need to ask for them to type the email and password. It might be that I got it wrong and we only need to ask for the password. @RaduCStefanescu can you clarify if there is a requirement to ask the user to put in the email?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on this comment I'm guessing he's on-board with the idea 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool! I will update the PR accordingly