1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-05-01 23:56:41 +07:00

Отрефакторил бэк, исправил ошибки (#138)

* fixed paths to match refactored backend

* fixed some paths according to new backend

* fixed auth urls for new endpoints

* fixed urls

* fixed error handling

* fixes

* fixed error handling on user form

* fixed error handling on oauth

* using fallback: true on node pages

* type button for comment attach buttons

* fixed return types of social delete

* changed the way we upload user avatars
This commit is contained in:
muerwre 2022-09-16 14:53:52 +07:00 committed by GitHub
parent 1745cc636d
commit 080d59858c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 544 additions and 420 deletions

View file

@ -15,6 +15,7 @@ import {
ApiLoginWithSocialResult,
ApiRestoreCodeRequest,
ApiRestoreCodeResult,
ApiUpdatePhotoRequest,
ApiUpdateUserRequest,
ApiUpdateUserResult,
ApiUserLoginRequest,
@ -28,44 +29,72 @@ export const apiUserLogin = ({ username, password }: ApiUserLoginRequest) =>
.post<ApiUserLoginResult>(API.USER.LOGIN, { username, password })
.then(cleanResult);
export const apiAuthGetUser = () => api.get<ApiAuthGetUserResult>(API.USER.ME).then(cleanResult);
export const apiAuthGetUser = () =>
api.get<ApiAuthGetUserResult>(API.USER.ME).then(cleanResult);
export const apiAuthGetUserProfile = ({ username }: ApiAuthGetUserProfileRequest) =>
api.get<ApiAuthGetUserProfileResult>(API.USER.PROFILE(username)).then(cleanResult);
export const apiAuthGetUpdates = ({ exclude_dialogs, last }: ApiAuthGetUpdatesRequest) =>
export const apiAuthGetUserProfile = ({
username,
}: ApiAuthGetUserProfileRequest) =>
api
.get<ApiAuthGetUpdatesResult>(API.USER.GET_UPDATES, { params: { exclude_dialogs, last } })
.get<ApiAuthGetUserProfileResult>(API.USER.PROFILE(username))
.then(cleanResult);
export const apiAuthGetUpdates = ({
exclude_dialogs,
last,
}: ApiAuthGetUpdatesRequest) =>
api
.get<ApiAuthGetUpdatesResult>(API.USER.GET_UPDATES, {
params: { exclude_dialogs, last },
})
.then(cleanResult);
export const apiUpdateUser = ({ user }: ApiUpdateUserRequest) =>
api.patch<ApiUpdateUserResult>(API.USER.ME, user).then(cleanResult);
export const apiUpdatePhoto = ({ file }: ApiUpdatePhotoRequest) =>
api.post<ApiUpdateUserResult>(API.USER.UPDATE_PHOTO, file).then(cleanResult);
export const apiUpdateCover = ({ file }: ApiUpdatePhotoRequest) =>
api.post<ApiUpdateUserResult>(API.USER.UPDATE_COVER, file).then(cleanResult);
export const apiRequestRestoreCode = (field: string) =>
api
.post<{ field: string }>(API.USER.REQUEST_CODE(), { field })
.then(cleanResult);
export const apiCheckRestoreCode = ({ code }: ApiCheckRestoreCodeRequest) =>
api.get<ApiCheckRestoreCodeResult>(API.USER.REQUEST_CODE(code)).then(cleanResult);
api
.get<ApiCheckRestoreCodeResult>(API.USER.REQUEST_CODE(code))
.then(cleanResult);
export const apiRestoreCode = ({ code, password }: ApiRestoreCodeRequest) =>
api
.post<ApiRestoreCodeResult>(API.USER.REQUEST_CODE(code), { password })
.put<ApiRestoreCodeResult>(API.USER.REQUEST_CODE(code), { password })
.then(cleanResult);
export const apiGetSocials = () =>
api.get<ApiGetSocialsResult>(API.USER.GET_SOCIALS).then(cleanResult);
export const apiDropSocial = ({ id, provider }: ApiDropSocialRequest) =>
api.delete<ApiDropSocialResult>(API.USER.DROP_SOCIAL(provider, id)).then(cleanResult);
api
.delete<ApiDropSocialResult>(API.USER.DROP_SOCIAL(provider, id))
.then(cleanResult);
export const apiAttachSocial = ({ token }: ApiAttachSocialRequest) =>
api
.post<ApiAttachSocialResult>(API.USER.ATTACH_SOCIAL, { token })
.then(cleanResult);
export const apiLoginWithSocial = ({ token, username, password }: ApiLoginWithSocialRequest) =>
export const apiLoginWithSocial = ({
token,
username,
password,
}: ApiLoginWithSocialRequest) =>
api
.post<ApiLoginWithSocialResult>(API.USER.LOGIN_WITH_SOCIAL, { token, username, password })
.put<ApiLoginWithSocialResult>(API.USER.LOGIN_WITH_SOCIAL, {
token,
username,
password,
})
.then(cleanResult);