Add admin-frontend and user-frontend standalone projects, certification/invoice/discovery features, fix auth header and theme consistency

This commit is contained in:
TradeMate Dev
2026-05-22 18:35:30 +08:00
parent 18c6cf5406
commit 52dba37f22
79 changed files with 10333 additions and 248 deletions
+113
View File
@@ -0,0 +1,113 @@
import axios from 'axios'
const TOKEN_KEY = 'token'
const http = axios.create({ baseURL: '/api/v1', timeout: 30000 })
http.interceptors.request.use(config => {
const token = localStorage.getItem(TOKEN_KEY)
if (token) config.headers.Authorization = `Bearer ${token}`
return config
})
http.interceptors.response.use(
res => res.data,
err => {
if (err.response?.status === 401) {
localStorage.removeItem(TOKEN_KEY)
const path = window.location.pathname.replace('/workspace', '') || '/'
window.location.href = '/workspace/login?redirect=' + encodeURIComponent(path)
}
return Promise.reject(err.response?.data || err)
}
)
export function login(data) { return http.post('/auth/login', data) }
export function register(data) { return http.post('/auth/register', data) }
export function getUserInfo() { return http.get('/auth/me') }
export function updateProfile(data) { return http.put('/auth/me', data) }
export function changePassword(data) { return http.put('/auth/password', data) }
export function translate(data) { return http.post('/translate', data) }
export function translateReply(data) { return http.post('/translate/reply', data) }
export function extractInfo(data) { return http.post('/translate/extract', data) }
export function translateFeedback(data) { return http.post('/translate/feedback', data) }
export function sendSuggestion(data) { return http.post('/interaction/select', data) }
export function listCustomers(params) { return http.get('/customers', { params }) }
export function getCustomer(id) { return http.get(`/customers/${id}`) }
export function createCustomer(data) { return http.post('/customers', data) }
export function updateCustomer(id, data) { return http.patch(`/customers/${id}`, data) }
export function deleteCustomer(id) { return http.delete(`/customers/${id}`) }
export function getSilentCustomers(days = 3) { return http.get('/customers/silent', { params: { days } }) }
export function getCustomerConversation(id) { return http.get(`/customers/${id}/conversation`) }
export function exportCustomersCsv() { return http.get('/customers/export/csv') }
export function exportCustomersXlsx() { return http.get('/customers/export/xlsx') }
export function importCustomers(data) { return http.post('/customers/import', data) }
export function getHealthOverview() { return http.get('/customers/health-overview') }
export function getHealthScores() { return http.get('/customers/health-scores') }
export function getCustomerHealth(id) { return http.get(`/customers/${id}/health`) }
export function listProducts(params) { return http.get('/products', { params }) }
export function createProduct(data) { return http.post('/products', data) }
export function updateProduct(id, data) { return http.patch(`/products/${id}`, data) }
export function deleteProduct(id) { return http.delete(`/products/${id}`) }
export function exportProductsCsv() { return http.get('/products/export/csv') }
export function exportProductsXlsx() { return http.get('/products/export/xlsx') }
export function importProducts(data) { return http.post('/products/import', data) }
export function listQuotations(params) { return http.get('/quotations', { params }) }
export function getQuotation(id) { return http.get(`/quotations/${id}`) }
export function createQuotation(data) { return http.post('/quotations', data) }
export function updateQuotationStatus(id, status) { return http.patch(`/quotations/${id}/status`, { status }) }
export function exportQuotationPdf(id) { return http.get(`/quotations/${id}/pdf`) }
export function exportQuotationsCsv() { return http.get('/quotations/export/csv') }
export function exportQuotationsXlsx() { return http.get('/quotations/export/xlsx') }
export function generateQuoteFromInquiry(data) { return http.post('/quotations/generate-from-inquiry', data) }
export function importQuotations(data) { return http.post('/quotations/import', data) }
export function generateMarketing(data) { return http.post('/marketing/generate', data) }
export function getKeywords(data) { return http.post('/marketing/keywords', data) }
export function competitorAnalysis(data) { return http.post('/marketing/competitor-analysis', data) }
export function discoverySearch(data) { return http.post('/discovery/search', data) }
export function discoveryAnalyze(data) { return http.post('/discovery/analyze', data) }
export function discoveryOutreach(data) { return http.post('/discovery/outreach', data) }
export function getFollowupStats() { return http.get('/followup/stats') }
export function getFollowupPending() { return http.get('/followup/pending') }
export function getFollowupLogs(params) { return http.get('/followup/logs', { params }) }
export function markFollowupSent(id) { return http.post(`/followup/${id}/send`) }
export function editFollowup(id, data) { return http.post(`/followup/${id}/edit`, data) }
export function scanFollowups() { return http.post('/followup/scan') }
export function getAnalyticsOverview() { return http.get('/analytics/overview') }
export function listTeams() { return http.get('/teams') }
export function createTeam(data) { return http.post('/teams', data) }
export function inviteTeamMember(id, userId) { return http.post(`/teams/${id}/invite`, { user_id: userId }) }
export function deleteTeamMember(id, memberId) { return http.delete(`/teams/${id}/members/${memberId}`) }
export function leaveTeam(id) { return http.post(`/teams/${id}/leave`) }
export function updateTeamMemberRole(id, memberId, role) { return http.patch(`/teams/${id}/members/${memberId}/role`, { role }) }
export function listNotifications(params) { return http.get('/notifications', { params }) }
export function getUnreadCount() { return http.get('/notifications/unread-count') }
export function markNotificationRead(id) { return http.patch(`/notifications/${id}/read`) }
export function markAllRead() { return http.post('/notifications/read-all') }
export function getPlans() { return http.get('/payment/plans') }
export function getSubscription() { return http.get('/payment/subscription') }
export function createOrder(planId) { return http.post('/payment/create-order', { plan_id: planId }) }
export function submitCertification(data) { return http.post('/certification/submit', data) }
export function getCertificationStatus() { return http.get('/certification/status') }
export function applyInvoice(data) { return http.post('/invoices/apply', data) }
export function listInvoices(params) { return http.get('/invoices/list', { params }) }
export function submitFeedback(data) { return http.post('/feedback', data) }
export function sendWhatsApp(data) { return http.post('/whatsapp/send', data) }
export default http