Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
hdastageeri
hft_awado_app
Commits
ccd07189
Commit
ccd07189
authored
Jan 06, 2020
by
Priyanka Upadhye
Browse files
Account deactivation API integrated
parent
84214a24
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/app/settings/settings.page.ts
View file @
ccd07189
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
Router
,
LoadChildrenCallback
}
from
'
@angular/router
'
;
import
{
ToastService
}
from
'
../services/toast.service
'
;
import
{
AlertController
}
from
'
@ionic/angular
'
;
import
{
RestService
}
from
'
../rest.service
'
;
import
{
Observable
,
Subject
}
from
'
rxjs
'
;
import
{
HttpClient
,
HttpHeaders
}
from
'
@angular/common/http
'
;
import
{
Storage
}
from
'
@ionic/storage
'
;
@
Component
({
selector
:
'
app-settings
'
,
templateUrl
:
'
./settings.page.html
'
,
...
...
@@ -8,15 +13,56 @@ import { ToastService } from '../services/toast.service';
})
export
class
SettingsPage
implements
OnInit
{
constructor
(
private
router
:
Router
,
private
toastService
:
ToastService
)
{
}
constructor
(
private
router
:
Router
,
private
toastService
:
ToastService
,
public
alertController
:
AlertController
,
public
restService
:
RestService
,
public
httpClient
:
HttpClient
,
private
storage
:
Storage
,)
{
}
ngOnInit
()
{
}
ChangePassword
()
{
this
.
router
.
navigateByUrl
(
'
/reset-password
'
);
}
DeactivateUser
(){
this
.
toastService
.
showToast
(
"
Account Deactivated Sucessfully
"
);
this
.
router
.
navigateByUrl
(
'
/logout
'
);
async
DeactivateUser
(){
const
alert
=
await
this
.
alertController
.
create
({
header
:
'
Deactivation!
'
,
message
:
'
<strong>Do you really want to deactivate your account</strong>?
'
,
buttons
:
[
{
text
:
'
Not Now
'
,
role
:
'
cancel
'
,
cssClass
:
'
secondary
'
,
handler
:
(
blah
)
=>
{
console
.
log
(
'
Confirm Cancel: blah
'
);
this
.
router
.
navigateByUrl
(
'
/settings
'
);
}
},
{
text
:
'
Yes
'
,
handler
:
()
=>
{
console
.
log
(
'
Confirm Okay
'
);
this
.
storage
.
get
(
'
token
'
).
then
((
token
)
=>
{
let
url
=
'
http://193.196.52.237:8081/deactivate-account
'
;
const
headers
=
new
HttpHeaders
().
set
(
"
Authorization
"
,
"
Bearer
"
+
token
);
let
deactivateApi
=
this
.
httpClient
.
delete
(
url
,
{
headers
});
deactivateApi
.
subscribe
((
resp
:
any
)
=>
{
console
.
log
(
'
my data:
'
,
resp
);
this
.
router
.
navigateByUrl
(
'
/login
'
);
this
.
toastService
.
showToast
(
"
User account has been deactivated!
"
);
},
(
error
)
=>
{
console
.
log
(
error
);
});
});
}
}
]
});
await
alert
.
present
();
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment