fix validation & implement profile page (#5)

* fix validation

* implement profile page

* catch error
This commit is contained in:
UUBulb
2024-11-26 21:20:56 +08:00
committed by GitHub
parent 3d1778f89d
commit 3f3a585a62
13 changed files with 258 additions and 43 deletions
+7 -3
View File
@@ -1,12 +1,12 @@
import { ModelProfile, ModelUserForm } from "@/types"
import { ModelProfile, ModelUserForm, ModelProfileForm } from "@/types"
import { fetcher, FetcherMethod } from "./api"
export const getProfile = async (): Promise<ModelProfile> => {
return fetcher<ModelProfile>(FetcherMethod.GET, '/api/v1/profile', null);
}
export const login = async (username: string, password: string): Promise<any> => {
return fetcher<any>(FetcherMethod.POST, '/api/v1/login', { username, password });
export const login = async (username: string, password: string): Promise<void> => {
return fetcher<void>(FetcherMethod.POST, '/api/v1/login', { username, password });
}
export const createUser = async (data: ModelUserForm): Promise<number> => {
@@ -16,3 +16,7 @@ export const createUser = async (data: ModelUserForm): Promise<number> => {
export const deleteUser = async (id: number[]): Promise<void> => {
return fetcher<void>(FetcherMethod.POST, '/api/v1/batch-delete/user', id);
}
export const updateProfile = async (data: ModelProfileForm): Promise<void> => {
return fetcher<void>(FetcherMethod.POST, '/api/v1/profile', data);
}