feat(auth): implement OTP login flow with toast notifications
feat(content): enhance detail view with dynamic content and comments feat(order): add polling for payment status in the payment view feat(user): update dashboard to display wallet and recent orders feat(user): improve orders view with dynamic order fetching and status mapping feat(api): create API modules for auth, content, order, user, and common functionalities refactor(request): implement a centralized request utility for API calls
This commit is contained in:
6
frontend/portal/src/api/auth.js
Normal file
6
frontend/portal/src/api/auth.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import { request } from '../utils/request';
|
||||
|
||||
export const authApi = {
|
||||
sendOTP: (phone) => request('/auth/otp', { method: 'POST', body: { phone } }),
|
||||
login: (phone, otp) => request('/auth/login', { method: 'POST', body: { phone, otp } }),
|
||||
};
|
||||
10
frontend/portal/src/api/common.js
Normal file
10
frontend/portal/src/api/common.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import { request } from '../utils/request';
|
||||
|
||||
export const commonApi = {
|
||||
upload: (file, type) => {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
formData.append('type', type);
|
||||
return request('/upload', { method: 'POST', body: formData });
|
||||
},
|
||||
};
|
||||
13
frontend/portal/src/api/content.js
Normal file
13
frontend/portal/src/api/content.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { request } from '../utils/request';
|
||||
|
||||
export const contentApi = {
|
||||
list: (params) => {
|
||||
const qs = new URLSearchParams(params).toString();
|
||||
return request(`/contents?${qs}`);
|
||||
},
|
||||
get: (id) => request(`/contents/${id}`),
|
||||
listComments: (id, page) => request(`/contents/${id}/comments?page=${page || 1}`),
|
||||
createComment: (id, data) => request(`/contents/${id}/comments`, { method: 'POST', body: data }),
|
||||
likeComment: (id) => request(`/comments/${id}/like`, { method: 'POST' }),
|
||||
listTopics: () => request('/topics'),
|
||||
};
|
||||
24
frontend/portal/src/api/creator.js
Normal file
24
frontend/portal/src/api/creator.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { request } from '../utils/request';
|
||||
|
||||
export const creatorApi = {
|
||||
apply: (data) => request('/creator/apply', { method: 'POST', body: data }),
|
||||
getDashboard: () => request('/creator/dashboard'),
|
||||
listContents: (params) => {
|
||||
const qs = new URLSearchParams(params).toString();
|
||||
return request(`/creator/contents?${qs}`);
|
||||
},
|
||||
createContent: (data) => request('/creator/contents', { method: 'POST', body: data }),
|
||||
updateContent: (id, data) => request(`/creator/contents/${id}`, { method: 'PUT', body: data }),
|
||||
deleteContent: (id) => request(`/creator/contents/${id}`, { method: 'DELETE' }),
|
||||
listOrders: (params) => {
|
||||
const qs = new URLSearchParams(params).toString();
|
||||
return request(`/creator/orders?${qs}`);
|
||||
},
|
||||
refundOrder: (id, data) => request(`/creator/orders/${id}/refund`, { method: 'POST', body: data }),
|
||||
getSettings: () => request('/creator/settings'),
|
||||
updateSettings: (data) => request('/creator/settings', { method: 'PUT', body: data }),
|
||||
listPayoutAccounts: () => request('/creator/payout-accounts'),
|
||||
addPayoutAccount: (data) => request('/creator/payout-accounts', { method: 'POST', body: data }),
|
||||
removePayoutAccount: (id) => request(`/creator/payout-accounts?id=${id}`, { method: 'DELETE' }),
|
||||
withdraw: (data) => request('/creator/withdraw', { method: 'POST', body: data }),
|
||||
};
|
||||
7
frontend/portal/src/api/order.js
Normal file
7
frontend/portal/src/api/order.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import { request } from '../utils/request';
|
||||
|
||||
export const orderApi = {
|
||||
create: (data) => request('/orders', { method: 'POST', body: data }),
|
||||
pay: (id, data) => request(`/orders/${id}/pay`, { method: 'POST', body: data }),
|
||||
status: (id) => request(`/orders/${id}/status`),
|
||||
};
|
||||
21
frontend/portal/src/api/user.js
Normal file
21
frontend/portal/src/api/user.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { request } from '../utils/request';
|
||||
|
||||
export const userApi = {
|
||||
getMe: () => request('/me'),
|
||||
updateMe: (data) => request('/me', { method: 'PUT', body: data }),
|
||||
realName: (data) => request('/me/realname', { method: 'POST', body: data }),
|
||||
getWallet: () => request('/me/wallet'),
|
||||
recharge: (data) => request('/me/wallet/recharge', { method: 'POST', body: data }),
|
||||
getOrders: (status) => request(`/me/orders?status=${status || 'all'}`),
|
||||
getOrder: (id) => request(`/me/orders/${id}`),
|
||||
getLibrary: () => request('/me/library'),
|
||||
getFavorites: () => request('/me/favorites'),
|
||||
addFavorite: (contentId) => request(`/me/favorites?content_id=${contentId}`, { method: 'POST' }),
|
||||
removeFavorite: (contentId) => request(`/me/favorites/${contentId}`, { method: 'DELETE' }),
|
||||
getLikes: () => request('/me/likes'),
|
||||
addLike: (contentId) => request(`/me/likes?content_id=${contentId}`, { method: 'POST' }),
|
||||
removeLike: (contentId) => request(`/me/likes/${contentId}`, { method: 'DELETE' }),
|
||||
getNotifications: (type, page) => request(`/me/notifications?type=${type || 'all'}&page=${page || 1}`),
|
||||
getFollowing: () => request('/me/following'),
|
||||
getCoupons: (status) => request(`/me/coupons?status=${status || 'unused'}`),
|
||||
};
|
||||
Reference in New Issue
Block a user