feat: Cập nhật các thành phần UI với cấu trúc dựa trên tính năng, thêm các thành phần glassmorphism, và cải thiện cấu hình đường dẫn trong tsconfig.

This commit is contained in:
Ho Ngoc Hai
2026-01-04 18:06:38 +07:00
parent 5a71b1132b
commit 863e821f24
397 changed files with 83344 additions and 2401 deletions

View File

@@ -0,0 +1,83 @@
// Debug script để kiểm tra token trong localStorage
// Chạy trong browser console tại http://localhost:3001
// KHÔNG chạy với node command!
console.log('🔍 Debug Token Storage...');
// Check if running in browser
if (typeof window === 'undefined') {
console.error('❌ Script này phải chạy trong browser console, không phải Node.js!');
console.log('💡 Hướng dẫn:');
console.log('1. Mở browser tại http://localhost:3001');
console.log('2. Mở Developer Console (F12)');
console.log('3. Copy và paste script này vào console');
process.exit(1);
}
// 1. Kiểm tra tất cả localStorage keys
console.log('📋 All localStorage keys:');
Object.keys(localStorage).forEach(key => {
const value = localStorage.getItem(key);
console.log(`- ${key}:`, value ? `${value.substring(0, 50)}...` : 'null');
});
// 2. Kiểm tra các key có thể chứa token
const possibleKeys = [
'auth_token',
'authToken',
'token',
'access_token',
'accessToken',
'jwt_token',
'jwtToken',
'authToken',
'user_token',
'session_token'
];
console.log('🔑 Checking possible token keys:');
possibleKeys.forEach(key => {
const value = localStorage.getItem(key);
if (value) {
console.log(`✅ Found in ${key}:`, value.substring(0, 50) + '...');
} else {
console.log(`❌ Not found in ${key}`);
}
});
// 3. Kiểm tra sessionStorage
console.log('📋 All sessionStorage keys:');
Object.keys(sessionStorage).forEach(key => {
const value = sessionStorage.getItem(key);
console.log(`- ${key}:`, value ? `${value.substring(0, 50)}...` : 'null');
});
// 4. Kiểm tra cookies
console.log('🍪 All cookies:');
document.cookie.split(';').forEach(cookie => {
console.log(`- ${cookie.trim()}`);
});
// 5. Test manual token setting
console.log('🧪 Test manual token setting...');
const testToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJjbWgxZ2drMXgwMDAxZnZldHVoNWF1NzZpIiwiZW1haWwiOiJob25nb2NoYWkxMEBpY2xvdWQuY29tIiwib3JnYW5pemF0aW9uSWQiOm51bGwsInJvbGVzIjpbXSwicGVybWlzc2lvbnMiOltdLCJpYXQiOjE3NjEyODIyNDgsImV4cCI6MTc2MTM2ODY0OH0.h13MLTT35w7XIz1oz2y0tBJ4BQ0-NpqkbDRqcgtls3A';
localStorage.setItem('auth_token', testToken);
console.log('✅ Test token set in localStorage');
// 6. Test ppoint service với token
console.log('🧪 Testing PPoint Service with token...');
import('../../src/lib/ppoint.service.js').then(module => {
const ppointService = new module.PPointService();
ppointService.getUserBalance()
.then(balance => {
console.log('✅ PPoint Service working with token!');
console.log('💰 Balance:', balance);
})
.catch(error => {
console.error('❌ PPoint Service still failing:', error);
});
}).catch(error => {
console.error('❌ Failed to import ppoint service:', error);
});

View File

@@ -0,0 +1,81 @@
// Script để login và set token
// Chạy trong browser console tại http://localhost:3001
// KHÔNG chạy với node command!
// Check if running in browser
if (typeof window === 'undefined') {
console.error('❌ Script này phải chạy trong browser console, không phải Node.js!');
console.log('💡 Hướng dẫn:');
console.log('1. Mở browser tại http://localhost:3001');
console.log('2. Mở Developer Console (F12)');
console.log('3. Copy và paste script này vào console');
process.exit(1);
}
async function loginAndSetToken() {
try {
console.log('🔐 Logging in...');
// Login với admin account
const response = await fetch('http://localhost:7001/api/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'hongochai10@icloud.com',
password: 'Hai@2025'
})
});
const data = await response.json();
console.log('📋 Login response:', data);
if (data.success && data.data && data.data.tokens) {
// Set tokens vào localStorage
localStorage.setItem('auth_token', data.data.tokens.accessToken);
localStorage.setItem('refresh_token', data.data.tokens.refreshToken);
console.log('✅ Login successful!');
console.log('👤 User:', data.data.user.email);
console.log('🎫 Access Token:', data.data.tokens.accessToken.substring(0, 50) + '...');
console.log('🔄 Refresh Token:', data.data.tokens.refreshToken.substring(0, 50) + '...');
// Verify tokens are stored
console.log('🔍 Verifying token storage:');
console.log('- auth_token:', localStorage.getItem('auth_token') ? '✅ Stored' : '❌ Missing');
console.log('- refresh_token:', localStorage.getItem('refresh_token') ? '✅ Stored' : '❌ Missing');
// Test ppoint service
console.log('🧪 Testing PPoint Service...');
try {
// Import từ đúng path
const { PPointService } = await import('/src/lib/ppoint.service.js');
const ppointService = new PPointService();
const balance = await ppointService.getUserBalance();
console.log('✅ PPoint Service working!');
console.log('💰 Balance:', balance);
// Test other endpoints
const dailyStatus = await ppointService.getDailyPointsStatus();
console.log('📅 Daily Points Status:', dailyStatus);
} catch (ppointError) {
console.error('❌ PPoint Service error:', ppointError);
console.log('🔍 Error details:', ppointError.message);
}
} else {
console.error('❌ Login failed:', data.error?.message || 'Unknown error');
console.log('📋 Full response:', data);
}
} catch (error) {
console.error('❌ Login error:', error);
}
}
// Run the function
loginAndSetToken();

View File

@@ -0,0 +1,19 @@
// Script để set token manually
// Chạy trong browser console tại http://localhost:3001
console.log('🔧 Setting token manually...');
// Token với permissions đầy đủ
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJjbWgxZ2drMXgwMDAxZnZldHVoNWF1NzZpIiwiZW1haWwiOiJob25nb2NoYWkxMEBpY2xvdWQuY29tIiwib3JnYW5pemF0aW9uSWQiOm51bGwsInJvbGVzIjpbInN1cGVyX2FkbWluIl0sInBlcm1pc3Npb25zIjpbInRhc2s6cmVhZCIsInRhc2s6bWFuYWdlIiwicG9pbnRzOm1hbmFnZSIsInBvaW50czpyZWFkIl0sImlhdCI6MTc2MTI4MzI2OCwiZXhwIjoxNzYxMzY5NjY4fQ.WUJVAt5R3zDcawVSAmwF96KZ6UnGpvSnC6oYhSqR2b8';
// Set token
localStorage.setItem('auth_token', token);
console.log('✅ Token set successfully!');
console.log('🔍 Verification:');
console.log('- auth_token:', localStorage.getItem('auth_token') ? 'Found' : 'Missing');
console.log('- All keys:', Object.keys(localStorage));
// Reload page to trigger dashboard
console.log('🔄 Reloading page...');
window.location.reload();

View File

@@ -0,0 +1,58 @@
// Test authentication và ppoint service
// Chạy script này trong browser console tại http://localhost:3001
console.log('🔍 Testing Authentication...');
// 1. Check localStorage for tokens
const authToken = localStorage.getItem('auth_token');
const refreshToken = localStorage.getItem('refresh_token');
const authTokenAlt = localStorage.getItem('authToken');
console.log('📋 Token Status:');
console.log('- auth_token:', authToken ? '✅ Found' : '❌ Missing');
console.log('- refresh_token:', refreshToken ? '✅ Found' : '❌ Missing');
console.log('- authToken (alt):', authTokenAlt ? '✅ Found' : '❌ Missing');
if (!authToken && !authTokenAlt) {
console.log('❌ No authentication token found!');
console.log('💡 Please login first or set token manually:');
console.log(`
// Set token manually:
localStorage.setItem('auth_token', 'your-jwt-token-here');
// Or login via API:
fetch('http://localhost:7001/api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: 'hongochai10@icloud.com',
password: 'Hai@2025'
})
}).then(r => r.json()).then(data => {
if (data.success) {
localStorage.setItem('auth_token', data.data.tokens.accessToken);
localStorage.setItem('refresh_token', data.data.tokens.refreshToken);
console.log('✅ Token set successfully!');
}
});
`);
} else {
console.log('✅ Token found! Testing PPoint Service...');
// Test ppoint service
import('../../src/lib/ppoint.service.js').then(module => {
const ppointService = new module.PPointService();
ppointService.getUserBalance()
.then(balance => {
console.log('✅ PPoint Service working!');
console.log('💰 Balance:', balance);
})
.catch(error => {
console.error('❌ PPoint Service error:', error);
console.log('🔍 Error details:', error.message);
});
}).catch(error => {
console.error('❌ Failed to import ppoint service:', error);
});
}

View File

@@ -0,0 +1,80 @@
// Test PPoint Service trực tiếp với token có sẵn
// Chạy trong browser console tại http://localhost:3001
console.log('🧪 Testing PPoint Service with existing token...');
// Kiểm tra token
const token = localStorage.getItem('auth_token');
console.log('🔍 Token status:', token ? '✅ Found' : '❌ Missing');
if (!token) {
console.error('❌ No token found! Please login first.');
return;
}
// Test API trực tiếp
async function testPPointAPI() {
try {
console.log('🔍 Testing API endpoints directly...');
// Test balance endpoint
const balanceResponse = await fetch('http://localhost:7009/api/points/balance', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
}
});
console.log('💰 Balance API Status:', balanceResponse.status);
if (balanceResponse.ok) {
const balanceData = await balanceResponse.json();
console.log('✅ Balance API working!', balanceData);
} else {
const errorData = await balanceResponse.json();
console.error('❌ Balance API error:', errorData);
}
// Test daily points status
const dailyResponse = await fetch('http://localhost:7009/api/daily-points/status', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
}
});
console.log('📅 Daily Points API Status:', dailyResponse.status);
if (dailyResponse.ok) {
const dailyData = await dailyResponse.json();
console.log('✅ Daily Points API working!', dailyData);
} else {
const errorData = await dailyResponse.json();
console.error('❌ Daily Points API error:', errorData);
}
// Test transaction history
const historyResponse = await fetch('http://localhost:7009/api/points/history?offset=0&limit=10', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
}
});
console.log('📊 History API Status:', historyResponse.status);
if (historyResponse.ok) {
const historyData = await historyResponse.json();
console.log('✅ History API working!', historyData);
} else {
const errorData = await historyResponse.json();
console.error('❌ History API error:', errorData);
}
} catch (error) {
console.error('❌ Test error:', error);
}
}
// Run test
testPPointAPI();

View File

@@ -0,0 +1,21 @@
// Test script to set auth token in localStorage
// Run this in browser console to test ppoint service
const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJjbWgxZ2drMXgwMDAxZnZldHVoNWF1NzZpIiwiZW1haWwiOiJob25nb2NoYWkxMEBpY2xvdWQuY29tIiwib3JnYW5pemF0aW9uSWQiOm51bGwsInJvbGVzIjpbXSwicGVybWlzc2lvbnMiOltdLCJpYXQiOjE3NjEyODIyNDgsImV4cCI6MTc2MTM2ODY0OH0.h13MLTT35w7XIz1oz2y0tBJ4BQ0-NpqkbDRqcgtls3A";
// Set token in localStorage
localStorage.setItem('authToken', token);
console.log('✅ Auth token set in localStorage');
console.log('Token:', token.substring(0, 50) + '...');
// Test ppoint service
const ppointService = new (await import('../../src/lib/ppoint.service.js')).PPointService();
try {
const balance = await ppointService.getUserBalance();
console.log('✅ PPoint Service working!');
console.log('Balance:', balance);
} catch (error) {
console.error('❌ PPoint Service error:', error);
}