feat: add ZIP archive detection and automatic catalog refetching on bulk upload
This commit is contained in:
parent
b0b75531cc
commit
e2d2288ed8
1 changed files with 8 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ import {
|
|||
FileText
|
||||
} from 'lucide-react';
|
||||
import { api } from '../../services/api';
|
||||
import { useSeller } from '../../context/SellerContext';
|
||||
import { formatISTDateTime } from '../../utils/date';
|
||||
|
||||
interface BatchLog {
|
||||
|
|
@ -21,6 +22,7 @@ interface BatchLog {
|
|||
}
|
||||
|
||||
export const BulkUploadPage: React.FC = () => {
|
||||
const { fetchData } = useSeller();
|
||||
const [isUploading, setIsUploading] = useState(false);
|
||||
const [uploadSuccess, setUploadSuccess] = useState<string | null>(null);
|
||||
const [errorMsg, setErrorMsg] = useState<string | null>(null);
|
||||
|
|
@ -47,10 +49,15 @@ export const BulkUploadPage: React.FC = () => {
|
|||
setErrorMsg(null);
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('csv_file', file);
|
||||
if (file.name.toLowerCase().endsWith('.zip')) {
|
||||
formData.append('zip_file', file);
|
||||
} else {
|
||||
formData.append('csv_file', file);
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await api.bulkUploadProducts(formData);
|
||||
await fetchData();
|
||||
const count = res.products ? res.products.length : 0;
|
||||
|
||||
setUploadSuccess(`Successfully processed batch file! ${count} craft SKUs created/updated in your catalog.`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue