mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-28 22:15:12 -04:00
fix: Move content into to frontend directory
Doing this BEFORE the merge prevents a lot of merge conflicts. Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
4e18ce38f3
commit
762a0a850e
1051 changed files with 0 additions and 35 deletions
55
frontend/src/api/me/index.ts
Normal file
55
frontend/src/api/me/index.ts
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { MediaUpload } from '../media/types'
|
||||
import type { ChangeDisplayNameDto, LoginUserInfo } from './types'
|
||||
import { GetApiRequestBuilder } from '../common/api-request-builder/get-api-request-builder'
|
||||
import { DeleteApiRequestBuilder } from '../common/api-request-builder/delete-api-request-builder'
|
||||
import { PostApiRequestBuilder } from '../common/api-request-builder/post-api-request-builder'
|
||||
|
||||
/**
|
||||
* Returns metadata about the currently signed-in user from the API.
|
||||
*
|
||||
* @return The user metadata.
|
||||
* @throws {Error} when the user is not signed-in.
|
||||
*/
|
||||
export const getMe = async (): Promise<LoginUserInfo> => {
|
||||
const response = await new GetApiRequestBuilder<LoginUserInfo>('me').sendRequest()
|
||||
return response.asParsedJsonObject()
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the current user from the server.
|
||||
*
|
||||
* @throws {Error} when the api request wasn't successful.
|
||||
*/
|
||||
export const deleteUser = async (): Promise<void> => {
|
||||
await new DeleteApiRequestBuilder('me').sendRequest()
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the display name of the current user.
|
||||
*
|
||||
* @param displayName The new display name to set.
|
||||
* @throws {Error} when the api request wasn't successful.
|
||||
*/
|
||||
export const updateDisplayName = async (displayName: string): Promise<void> => {
|
||||
await new PostApiRequestBuilder<void, ChangeDisplayNameDto>('me/profile')
|
||||
.withJsonBody({
|
||||
displayName
|
||||
})
|
||||
.sendRequest()
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of media belonging to the user.
|
||||
*
|
||||
* @return List of media object information.
|
||||
* @throws {Error} when the api request wasn't successful.
|
||||
*/
|
||||
export const getMyMedia = async (): Promise<MediaUpload[]> => {
|
||||
const response = await new GetApiRequestBuilder<MediaUpload[]>('me/media').sendRequest()
|
||||
return response.asParsedJsonObject()
|
||||
}
|
15
frontend/src/api/me/types.ts
Normal file
15
frontend/src/api/me/types.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { UserInfo } from '../users/types'
|
||||
|
||||
export interface LoginUserInfo extends UserInfo {
|
||||
authProvider: string
|
||||
email: string
|
||||
}
|
||||
|
||||
export interface ChangeDisplayNameDto {
|
||||
displayName: string
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue