refactor: apply consistent formatting to improve code quality
Ensure uniform code formatting across components by aligning with the established code style. Adjust imports, indentation, and spacing to enhance readability and maintainability.
This commit is contained in:
@@ -1,22 +1,24 @@
|
||||
import api from "@/lib/api";
|
||||
import type { LoginResponse } from "@/types/auth";
|
||||
import type { LoginResponse, RegisterPayload } from "@/types/auth";
|
||||
|
||||
export const AuthService = {
|
||||
async login(email: string, password: string): Promise<LoginResponse> {
|
||||
const { data } = await api.post<LoginResponse>("/auth/login", { email, password });
|
||||
return data;
|
||||
},
|
||||
async login(email: string, password: string): Promise<LoginResponse> {
|
||||
const { data } = await api.post<LoginResponse>("/auth/login", {
|
||||
email,
|
||||
password,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
|
||||
async register(payload: any): Promise<any> {
|
||||
const { data } = await api.post("/auth/register", payload);
|
||||
return data;
|
||||
},
|
||||
async register(payload: RegisterPayload): Promise<void> {
|
||||
await api.post("/auth/register", payload);
|
||||
},
|
||||
|
||||
async logout(): Promise<void> {
|
||||
await api.post("/auth/logout");
|
||||
},
|
||||
async logout(): Promise<void> {
|
||||
await api.post("/auth/logout");
|
||||
},
|
||||
|
||||
async refresh(): Promise<void> {
|
||||
await api.post("/auth/refresh");
|
||||
},
|
||||
async refresh(): Promise<void> {
|
||||
await api.post("/auth/refresh");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2,13 +2,13 @@ import api from "@/lib/api";
|
||||
import type { Category } from "@/types/content";
|
||||
|
||||
export const CategoryService = {
|
||||
async getAll(): Promise<Category[]> {
|
||||
const { data } = await api.get<Category[]>("/categories");
|
||||
return data;
|
||||
},
|
||||
async getAll(): Promise<Category[]> {
|
||||
const { data } = await api.get<Category[]>("/categories");
|
||||
return data;
|
||||
},
|
||||
|
||||
async getOne(id: string): Promise<Category> {
|
||||
const { data } = await api.get<Category>(`/categories/${id}`);
|
||||
return data;
|
||||
},
|
||||
async getOne(id: string): Promise<Category> {
|
||||
const { data } = await api.get<Category>(`/categories/${id}`);
|
||||
return data;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2,54 +2,63 @@ import api from "@/lib/api";
|
||||
import type { Content, PaginatedResponse } from "@/types/content";
|
||||
|
||||
export const ContentService = {
|
||||
async getExplore(params: {
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
sort?: "trend" | "recent";
|
||||
tag?: string;
|
||||
category?: string;
|
||||
query?: string;
|
||||
author?: string;
|
||||
}): Promise<PaginatedResponse<Content>> {
|
||||
const { data } = await api.get<PaginatedResponse<Content>>("/contents/explore", {
|
||||
params,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
async getExplore(params: {
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
sort?: "trend" | "recent";
|
||||
tag?: string;
|
||||
category?: string;
|
||||
query?: string;
|
||||
author?: string;
|
||||
}): Promise<PaginatedResponse<Content>> {
|
||||
const { data } = await api.get<PaginatedResponse<Content>>(
|
||||
"/contents/explore",
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
return data;
|
||||
},
|
||||
|
||||
async getTrends(limit = 10, offset = 0): Promise<PaginatedResponse<Content>> {
|
||||
const { data } = await api.get<PaginatedResponse<Content>>("/contents/trends", {
|
||||
params: { limit, offset },
|
||||
});
|
||||
return data;
|
||||
},
|
||||
async getTrends(limit = 10, offset = 0): Promise<PaginatedResponse<Content>> {
|
||||
const { data } = await api.get<PaginatedResponse<Content>>(
|
||||
"/contents/trends",
|
||||
{
|
||||
params: { limit, offset },
|
||||
},
|
||||
);
|
||||
return data;
|
||||
},
|
||||
|
||||
async getRecent(limit = 10, offset = 0): Promise<PaginatedResponse<Content>> {
|
||||
const { data } = await api.get<PaginatedResponse<Content>>("/contents/recent", {
|
||||
params: { limit, offset },
|
||||
});
|
||||
return data;
|
||||
},
|
||||
async getRecent(limit = 10, offset = 0): Promise<PaginatedResponse<Content>> {
|
||||
const { data } = await api.get<PaginatedResponse<Content>>(
|
||||
"/contents/recent",
|
||||
{
|
||||
params: { limit, offset },
|
||||
},
|
||||
);
|
||||
return data;
|
||||
},
|
||||
|
||||
async getOne(idOrSlug: string): Promise<Content> {
|
||||
const { data } = await api.get<Content>(`/contents/${idOrSlug}`);
|
||||
return data;
|
||||
},
|
||||
async getOne(idOrSlug: string): Promise<Content> {
|
||||
const { data } = await api.get<Content>(`/contents/${idOrSlug}`);
|
||||
return data;
|
||||
},
|
||||
|
||||
async incrementViews(id: string): Promise<void> {
|
||||
await api.post(`/contents/${id}/view`);
|
||||
},
|
||||
async incrementViews(id: string): Promise<void> {
|
||||
await api.post(`/contents/${id}/view`);
|
||||
},
|
||||
|
||||
async incrementUsage(id: string): Promise<void> {
|
||||
await api.post(`/contents/${id}/use`);
|
||||
},
|
||||
async incrementUsage(id: string): Promise<void> {
|
||||
await api.post(`/contents/${id}/use`);
|
||||
},
|
||||
|
||||
async upload(formData: FormData): Promise<Content> {
|
||||
const { data } = await api.post<Content>("/contents/upload", formData, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
});
|
||||
return data;
|
||||
},
|
||||
async upload(formData: FormData): Promise<Content> {
|
||||
const { data } = await api.post<Content>("/contents/upload", formData, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2,16 +2,21 @@ import api from "@/lib/api";
|
||||
import type { Content, PaginatedResponse } from "@/types/content";
|
||||
|
||||
export const FavoriteService = {
|
||||
async add(contentId: string): Promise<void> {
|
||||
await api.post(`/favorites/${contentId}`);
|
||||
},
|
||||
async add(contentId: string): Promise<void> {
|
||||
await api.post(`/favorites/${contentId}`);
|
||||
},
|
||||
|
||||
async remove(contentId: string): Promise<void> {
|
||||
await api.delete(`/favorites/${contentId}`);
|
||||
},
|
||||
async remove(contentId: string): Promise<void> {
|
||||
await api.delete(`/favorites/${contentId}`);
|
||||
},
|
||||
|
||||
async list(params: { limit: number; offset: number }): Promise<PaginatedResponse<Content>> {
|
||||
const { data } = await api.get<PaginatedResponse<Content>>("/favorites", { params });
|
||||
return data;
|
||||
},
|
||||
async list(params: {
|
||||
limit: number;
|
||||
offset: number;
|
||||
}): Promise<PaginatedResponse<Content>> {
|
||||
const { data } = await api.get<PaginatedResponse<Content>>("/favorites", {
|
||||
params,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import api from "@/lib/api";
|
||||
import type { User, UserProfile } from "@/types/user";
|
||||
import type { User } from "@/types/user";
|
||||
|
||||
export const UserService = {
|
||||
async getMe(): Promise<User> {
|
||||
const { data } = await api.get<User>("/users/me");
|
||||
return data;
|
||||
},
|
||||
async getMe(): Promise<User> {
|
||||
const { data } = await api.get<User>("/users/me");
|
||||
return data;
|
||||
},
|
||||
|
||||
async getProfile(username: string): Promise<User> {
|
||||
const { data } = await api.get<User>(`/users/public/${username}`);
|
||||
return data;
|
||||
},
|
||||
async getProfile(username: string): Promise<User> {
|
||||
const { data } = await api.get<User>(`/users/public/${username}`);
|
||||
return data;
|
||||
},
|
||||
|
||||
async updateMe(update: Partial<User>): Promise<User> {
|
||||
const { data } = await api.patch<User>("/users/me", update);
|
||||
return data;
|
||||
},
|
||||
async updateMe(update: Partial<User>): Promise<User> {
|
||||
const { data } = await api.patch<User>("/users/me", update);
|
||||
return data;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user