update pricing i guess
This commit is contained in:
@ -28,9 +28,14 @@
|
||||
|
||||
<!-- 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 class="flex space-x-4">
|
||||
<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>
|
||||
<button id="downloadTcgplayerUpdateBtn" class="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">
|
||||
Download TCGPlayer Update File
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Transaction List -->
|
||||
|
@ -4,6 +4,8 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
showTransactionModal();
|
||||
});
|
||||
|
||||
document.getElementById('downloadTcgplayerUpdateBtn').addEventListener('click', downloadTcgplayerUpdateFile);
|
||||
|
||||
document.getElementById('addVendorBtn').addEventListener('click', () => {
|
||||
const vendorName = prompt('Enter vendor name:');
|
||||
if (vendorName) {
|
||||
@ -1074,4 +1076,38 @@ async function saveTransaction() {
|
||||
console.error('Error saving transaction:', error);
|
||||
alert('Failed to save transaction. Please try again.');
|
||||
}
|
||||
}
|
||||
|
||||
// TCGPlayer Update File Functions
|
||||
async function downloadTcgplayerUpdateFile() {
|
||||
try {
|
||||
const response = await fetch('/api/inventory/tcgplayer/update-file');
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to download TCGPlayer update file');
|
||||
}
|
||||
|
||||
// Get the filename from the Content-Disposition header
|
||||
const contentDisposition = response.headers.get('Content-Disposition');
|
||||
let filename = 'tcgplayer_update_file.csv';
|
||||
if (contentDisposition) {
|
||||
const filenameMatch = contentDisposition.match(/filename=(.+)/);
|
||||
if (filenameMatch) {
|
||||
filename = filenameMatch[1];
|
||||
}
|
||||
}
|
||||
|
||||
// Create a blob from the response and download it
|
||||
const blob = await response.blob();
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(a);
|
||||
} catch (error) {
|
||||
console.error('Error downloading TCGPlayer update file:', error);
|
||||
alert('Failed to download TCGPlayer update file. Please try again.');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user