User profile page (#102)

* Added mock profile page

* Added translations

* Modularized page, added LoginProvider, started validation

* Re-adding profile route after router refactoring

* Added API calls for password and name change

* Added user deletion modal

* Refactored translations in profile-page to match new locales

* Fixed merge-conflicted locales/de.json

* Removed values for password fields

* Fixed capitalization of LoginProvider

* Fixed codestyle method declarations

* Fix names of methods and started countdown

* Fix countdown

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
Erik Michelson 2020-05-31 21:56:39 +02:00 committed by GitHub
parent 515cf1f34d
commit 747d9686fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 356 additions and 13 deletions

View file

@ -1,3 +1,4 @@
import { LoginProvider } from '../redux/user/types'
import { expectResponseCode, getBackendUrl } from '../utils/apiUtils'
import { defaultFetchConfig } from './default'
@ -11,6 +12,7 @@ export interface meResponse {
id: string
name: string
photo: string
provider: LoginProvider
}
export const doEmailLogin = async (email: string, password: string): Promise<void> => {
@ -50,3 +52,37 @@ export const doOpenIdLogin = async (openId: string): Promise<void> => {
expectResponseCode(response)
}
export const updateDisplayName = async (displayName: string): Promise<void> => {
const response = await fetch(getBackendUrl() + '/me', {
...defaultFetchConfig,
method: 'POST',
body: JSON.stringify({
name: displayName
})
})
expectResponseCode(response)
}
export const changePassword = async (oldPassword: string, newPassword: string): Promise<void> => {
const response = await fetch(getBackendUrl() + '/me/password', {
...defaultFetchConfig,
method: 'POST',
body: JSON.stringify({
oldPassword,
newPassword
})
})
expectResponseCode(response)
}
export const deleteUser = async (): Promise<void> => {
const response = await fetch(getBackendUrl() + '/me', {
...defaultFetchConfig,
method: 'DELETE'
})
expectResponseCode(response)
}