we are so back

This commit is contained in:
2025-05-05 14:05:12 -04:00
parent 11aa4cda16
commit 5c85411c69
20 changed files with 2417 additions and 33 deletions

View File

@ -20,6 +20,22 @@
</script>
</head>
<body class="bg-gray-900 min-h-screen text-gray-100">
<!-- Navigation Menu -->
<nav class="bg-gray-800 shadow-sm">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex items-center justify-between h-16">
<div class="flex items-center">
<a href="/" class="text-xl font-bold text-gray-100">TCGPlayer Manager</a>
</div>
<div class="flex items-center space-x-4">
<a href="/" class="px-3 py-2 rounded-md text-sm font-medium text-gray-300 hover:text-white hover:bg-gray-700">Orders</a>
<a href="/manabox.html" class="px-3 py-2 rounded-md text-sm font-medium text-gray-300 hover:text-white hover:bg-gray-700">Manabox</a>
<a href="/transactions.html" class="px-3 py-2 rounded-md text-sm font-medium text-gray-300 hover:text-white hover:bg-gray-700">Transactions</a>
</div>
</div>
</div>
</nav>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<div class="bg-gray-800 rounded-xl shadow-sm p-6 mb-8">
<h1 class="text-3xl font-bold text-gray-100 mb-2">TCGPlayer Order Management</h1>

86
app/static/manabox.html Normal file
View File

@ -0,0 +1,86 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Manabox Inventory Management</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
},
}
}
}
</script>
</head>
<body class="bg-gray-900 min-h-screen text-gray-100">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<div class="bg-gray-800 rounded-xl shadow-sm p-6 mb-8">
<h1 class="text-3xl font-bold text-gray-100 mb-2">Manabox Inventory Management</h1>
<p class="text-gray-400">Upload and manage your Manabox inventory</p>
</div>
<!-- File Upload Section -->
<div class="bg-gray-800 rounded-xl shadow-sm p-6 mb-8">
<h2 class="text-xl font-semibold text-gray-100 mb-6">Upload Manabox CSV</h2>
<form id="uploadForm" class="space-y-4">
<div>
<label for="source" class="block text-sm font-medium text-gray-300 mb-2">Source</label>
<input type="text" id="source" name="source" required
class="w-full rounded-lg border-gray-600 bg-gray-700 text-gray-100 focus:ring-blue-500 focus:border-blue-500">
</div>
<div>
<label for="description" class="block text-sm font-medium text-gray-300 mb-2">Description</label>
<textarea id="description" name="description" rows="3" required
class="w-full rounded-lg border-gray-600 bg-gray-700 text-gray-100 focus:ring-blue-500 focus:border-blue-500"></textarea>
</div>
<div>
<label for="csvFile" class="block text-sm font-medium text-gray-300 mb-2">CSV File</label>
<input type="file" id="csvFile" name="file" accept=".csv" required
class="w-full rounded-lg border-gray-600 bg-gray-700 text-gray-100 focus:ring-blue-500 focus:border-blue-500">
</div>
<button type="submit" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors">
Upload CSV
</button>
</form>
</div>
<!-- File Uploads List Section -->
<div class="bg-gray-800 rounded-xl shadow-sm p-6">
<div class="flex items-center justify-between mb-6">
<h2 class="text-xl font-semibold text-gray-100">Recent Uploads</h2>
<div class="flex items-center space-x-4">
<button onclick="selectAllUploads()" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors">
Select All
</button>
</div>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-700">
<thead>
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">
<input type="checkbox" id="selectAll" class="rounded border-gray-600 bg-gray-800 text-blue-600 focus:ring-blue-500">
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Source</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Description</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Upload Date</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Status</th>
</tr>
</thead>
<tbody id="uploadsList" class="divide-y divide-gray-700">
<!-- Uploads will be populated here -->
</tbody>
</table>
</div>
</div>
</div>
<script src="/manabox.js"></script>
</body>
</html>

170
app/static/manabox.js Normal file
View File

@ -0,0 +1,170 @@
// API base URL
const API_BASE_URL = '/api';
// Selected uploads for actions
let selectedUploads = new Set();
// Show toast notification
function showToast(message, type = 'success') {
const toast = document.createElement('div');
toast.className = `fixed bottom-4 right-4 px-6 py-3 rounded-lg shadow-lg text-white ${
type === 'success' ? 'bg-green-600' : 'bg-red-600'
} transform translate-y-0 opacity-100 transition-all duration-300`;
toast.textContent = message;
document.body.appendChild(toast);
setTimeout(() => {
toast.style.transform = 'translateY(100%)';
toast.style.opacity = '0';
setTimeout(() => toast.remove(), 300);
}, 3000);
}
// Show loading state
function setLoading(isLoading) {
const buttons = document.querySelectorAll('button');
buttons.forEach(button => {
if (isLoading) {
button.disabled = true;
button.classList.add('opacity-50', 'cursor-not-allowed');
} else {
button.disabled = false;
button.classList.remove('opacity-50', 'cursor-not-allowed');
}
});
}
// Handle form submission
document.getElementById('uploadForm').addEventListener('submit', async (e) => {
e.preventDefault();
const formData = new FormData();
formData.append('file', document.getElementById('csvFile').files[0]);
formData.append('source', document.getElementById('source').value);
formData.append('description', document.getElementById('description').value);
try {
setLoading(true);
const response = await fetch(`${API_BASE_URL}/manabox/process-csv`, {
method: 'POST',
body: formData
});
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.detail || 'Failed to upload CSV');
}
showToast('CSV uploaded successfully');
document.getElementById('uploadForm').reset();
fetchUploads(); // Refresh the uploads list
} catch (error) {
showToast('Error uploading CSV: ' + error.message, 'error');
} finally {
setLoading(false);
}
});
// Fetch uploads from the API
async function fetchUploads() {
try {
setLoading(true);
const response = await fetch(`${API_BASE_URL}/manabox/manabox-file-uploads`);
if (!response.ok) {
throw new Error('Failed to fetch uploads');
}
const uploads = await response.json();
displayUploads(uploads);
} catch (error) {
showToast('Error fetching uploads: ' + error.message, 'error');
} finally {
setLoading(false);
}
}
// Display uploads in the UI
function displayUploads(uploads) {
const uploadsList = document.getElementById('uploadsList');
uploadsList.innerHTML = '';
if (!uploads || uploads.length === 0) {
uploadsList.innerHTML = '<tr><td colspan="5" class="px-6 py-4 text-center text-gray-400">No uploads found</td></tr>';
return;
}
uploads.forEach(upload => {
const row = document.createElement('tr');
row.className = 'hover:bg-gray-700';
row.dataset.uploadId = upload.id;
row.innerHTML = `
<td class="px-6 py-4 whitespace-nowrap">
<input type="checkbox" class="upload-checkbox rounded border-gray-600 bg-gray-800 text-blue-600 focus:ring-blue-500">
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300">${upload.name || 'N/A'}</td>
<td class="px-6 py-4 text-sm text-gray-300">${upload.file_metadata?.description || 'N/A'}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300">${formatDate(upload.created_at)}</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 py-1 text-xs rounded-full bg-green-900/50 text-green-300">Processed</span>
</td>
`;
uploadsList.appendChild(row);
// Add click event listener to the checkbox
const checkbox = row.querySelector('.upload-checkbox');
checkbox.addEventListener('change', () => {
const uploadId = row.dataset.uploadId;
if (checkbox.checked) {
selectedUploads.add(uploadId);
} else {
selectedUploads.delete(uploadId);
}
});
});
}
// Helper function to format date
function formatDate(dateString) {
if (!dateString) return 'N/A';
const date = new Date(dateString);
return date.toLocaleDateString() + ' ' + date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
}
// Select all uploads
function selectAllUploads() {
const checkboxes = document.querySelectorAll('.upload-checkbox');
const allSelected = checkboxes.length > 0 && Array.from(checkboxes).every(checkbox => checkbox.checked);
checkboxes.forEach(checkbox => {
checkbox.checked = !allSelected;
const row = checkbox.closest('tr');
const uploadId = row.dataset.uploadId;
if (!allSelected) {
selectedUploads.add(uploadId);
} else {
selectedUploads.delete(uploadId);
}
});
showToast(allSelected ? 'All uploads deselected' : 'All uploads selected');
}
// Initialize the page
document.addEventListener('DOMContentLoaded', () => {
fetchUploads();
// Add event listener for the select all checkbox
document.getElementById('selectAll').addEventListener('change', (e) => {
const checkboxes = document.querySelectorAll('.upload-checkbox');
checkboxes.forEach(checkbox => {
checkbox.checked = e.target.checked;
const row = checkbox.closest('tr');
const uploadId = row.dataset.uploadId;
if (e.target.checked) {
selectedUploads.add(uploadId);
} else {
selectedUploads.delete(uploadId);
}
});
});
});

View File

@ -105,4 +105,126 @@ button:hover {
select, button {
width: 100%;
}
}
/* Transaction Page Styles */
.transaction-form {
max-width: 800px;
margin: 0 auto;
}
.transaction-form .form-group {
margin-bottom: 1.5rem;
}
.transaction-form label {
display: block;
margin-bottom: 0.5rem;
font-weight: 500;
}
.transaction-form .form-control {
width: 100%;
padding: 0.5rem;
border: 1px solid #ddd;
border-radius: 4px;
}
.transaction-form .btn-add {
margin-left: 0.5rem;
padding: 0.25rem 0.5rem;
font-size: 0.875rem;
}
.transaction-form .items-section {
margin-top: 2rem;
padding: 1rem;
border: 1px solid #ddd;
border-radius: 4px;
}
.transaction-list {
margin-top: 2rem;
}
.transaction-card {
padding: 1rem;
margin-bottom: 1rem;
border: 1px solid #ddd;
border-radius: 4px;
background-color: white;
}
.transaction-card h3 {
margin-bottom: 0.5rem;
color: #333;
}
.transaction-card p {
margin-bottom: 0.25rem;
color: #666;
}
/* Modal Styles */
.modal-content {
border-radius: 8px;
}
.modal-header {
border-bottom: 1px solid #dee2e6;
padding: 1rem;
}
.modal-body {
padding: 1.5rem;
}
.modal-footer {
border-top: 1px solid #dee2e6;
padding: 1rem;
}
/* Dark Mode Support */
body.dark-mode {
background-color: #1a1a1a;
color: #ffffff;
}
body.dark-mode .container {
background-color: #2d2d2d;
}
body.dark-mode .transaction-card {
background-color: #2d2d2d;
border-color: #404040;
}
body.dark-mode .transaction-card h3 {
color: #ffffff;
}
body.dark-mode .transaction-card p {
color: #b3b3b3;
}
body.dark-mode .modal-content {
background-color: #2d2d2d;
color: #ffffff;
}
body.dark-mode .modal-header,
body.dark-mode .modal-footer {
border-color: #404040;
}
body.dark-mode .form-control {
background-color: #404040;
border-color: #505050;
color: #ffffff;
}
body.dark-mode .form-control:focus {
background-color: #404040;
border-color: #007bff;
color: #ffffff;
}

View File

@ -0,0 +1,179 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Transactions - AI Giga TCG</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
},
}
}
}
</script>
</head>
<body class="bg-gray-900 min-h-screen text-gray-100">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<div class="bg-gray-800 rounded-xl shadow-sm p-6 mb-8">
<h1 class="text-3xl font-bold text-gray-100 mb-2">Transactions</h1>
<p class="text-gray-400">Manage your transactions</p>
</div>
<!-- Create Transaction Button -->
<div class="bg-gray-800 rounded-xl shadow-sm p-6 mb-8">
<button id="createTransactionBtn" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors">
Create New Transaction
</button>
</div>
<!-- Transaction List -->
<div id="transactionList" class="bg-gray-800 rounded-xl shadow-sm p-6">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-100">Recent Transactions</h2>
<div class="flex items-center space-x-4">
<div class="flex items-center space-x-2">
<label for="limitSelect" class="text-sm text-gray-300">Show:</label>
<select id="limitSelect" class="rounded-lg border-gray-600 bg-gray-700 text-gray-100 focus:ring-blue-500 focus:border-blue-500">
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</div>
</div>
</div>
<div id="transactionsTable" class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-700">
<thead>
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Date</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Type</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Vendor/Customer</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Total</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Notes</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-700" id="transactionsBody">
<!-- Transactions will be loaded here -->
</tbody>
</table>
</div>
<!-- Pagination Controls -->
<div class="flex justify-between items-center mt-4">
<button id="prevPageBtn" class="px-4 py-2 bg-gray-700 text-white rounded-lg hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed">
Previous
</button>
<span id="pageInfo" class="text-gray-300">Page 1</span>
<button id="nextPageBtn" class="px-4 py-2 bg-gray-700 text-white rounded-lg hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed">
Next
</button>
</div>
</div>
<!-- Create Transaction Modal -->
<div id="createTransactionModal" class="fixed inset-0 bg-black bg-opacity-50 hidden flex items-center justify-center">
<div class="bg-gray-800 rounded-lg p-6 max-w-2xl w-full mx-4">
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-semibold text-gray-100">Create Transaction</h3>
<button onclick="closeTransactionModal()" class="text-gray-400 hover:text-white">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<form id="transactionForm" class="space-y-4">
<!-- Transaction Type -->
<div>
<label for="transactionType" class="block text-sm font-medium text-gray-300 mb-2">Transaction Type</label>
<select id="transactionType" class="w-full rounded-lg border-gray-600 bg-gray-700 text-gray-100 focus:ring-blue-500 focus:border-blue-500">
<option value="purchase" selected>Purchase</option>
<option value="sale">Sale</option>
</select>
</div>
<!-- Vendor/Customer Selection -->
<div>
<div class="flex items-center justify-between mb-2">
<label for="vendorSelect" class="block text-sm font-medium text-gray-300">Vendor</label>
<button type="button" id="addVendorBtn" class="px-2 py-1 text-sm bg-blue-600 text-white rounded hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors">
Add New
</button>
</div>
<select id="vendorSelect" class="w-full rounded-lg border-gray-600 bg-gray-700 text-gray-100 focus:ring-blue-500 focus:border-blue-500">
<option value="">Select a vendor</option>
</select>
</div>
<!-- Marketplace Selection (for sales) -->
<div id="marketplaceSection" class="hidden">
<div class="flex items-center justify-between mb-2">
<label for="marketplaceSelect" class="block text-sm font-medium text-gray-300">Marketplace</label>
<button type="button" id="addMarketplaceBtn" class="px-2 py-1 text-sm bg-blue-600 text-white rounded hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors">
Add New
</button>
</div>
<select id="marketplaceSelect" class="w-full rounded-lg border-gray-600 bg-gray-700 text-gray-100 focus:ring-blue-500 focus:border-blue-500">
<option value="">Select a marketplace</option>
</select>
</div>
<!-- Transaction Date -->
<div>
<label for="transactionDate" class="block text-sm font-medium text-gray-300 mb-2">Transaction Date</label>
<input type="datetime-local" id="transactionDate" class="w-full rounded-lg border-gray-600 bg-gray-700 text-gray-100 focus:ring-blue-500 focus:border-blue-500" required>
</div>
<!-- Transaction Notes -->
<div>
<label for="transactionNotes" class="block text-sm font-medium text-gray-300 mb-2">Notes</label>
<textarea id="transactionNotes" class="w-full rounded-lg border-gray-600 bg-gray-700 text-gray-100 focus:ring-blue-500 focus:border-blue-500" rows="3"></textarea>
</div>
<!-- Items Section -->
<div id="itemsSection" class="border border-gray-700 rounded-lg p-4">
<h5 class="text-lg font-medium text-gray-100 mb-4">Items</h5>
<div id="itemsContainer" class="space-y-4">
<!-- Items will be added here -->
</div>
<button type="button" id="addItemBtn" class="mt-4 px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2 transition-colors">
Add Item
</button>
</div>
</form>
<div class="flex justify-end space-x-3 mt-6">
<button onclick="closeTransactionModal()" class="px-4 py-2 bg-gray-600 text-white rounded-lg hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 transition-colors">
Cancel
</button>
<button id="saveTransactionBtn" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors">
Save Transaction
</button>
</div>
</div>
</div>
<!-- Transaction Details Modal -->
<div id="transactionDetailsModal" class="fixed inset-0 bg-black bg-opacity-50 hidden flex items-center justify-center">
<div class="bg-gray-800 rounded-lg p-6 max-w-4xl w-full mx-4 max-h-[90vh] overflow-y-auto">
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-semibold text-gray-100">Transaction Details</h3>
<button onclick="closeTransactionDetailsModal()" class="text-gray-400 hover:text-white">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<div id="transactionDetails" class="space-y-4">
<!-- Transaction details will be loaded here -->
</div>
</div>
</div>
</div>
<script src="transactions.js"></script>
</body>
</html>

1077
app/static/transactions.js Normal file

File diff suppressed because it is too large Load Diff