| @@ -520,9 +520,9 @@ | ||
| 520 | 520 | |
| 521 | 521 | // Handle actual export after data type selection - uses background job |
| 522 | 522 | const handleExport = async () => { |
| 523 | 523 | if (selectedExportData.length === 0) { |
| 524 | - alert("Please select at least one data type to export."); | |
| 524 | + showToast(__("Please select at least one data type to export.", "yatra"), "error"); | |
| 525 | 525 | return; |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | setIsExporting(true); |
| @@ -537,9 +537,9 @@ | ||
| 537 | 537 | const jobId = data.job_id; |
| 538 | 538 | pollJobStatus(jobId, "export"); |
| 539 | 539 | } catch (error) { |
| 540 | 540 | console.error("Export error:", error); |
| 541 | - alert("Export failed. Please try again."); | |
| 541 | + showToast(__("Export failed. Please try again.", "yatra"), "error"); | |
| 542 | 542 | setIsExporting(false); |
| 543 | 543 | } |
| 544 | 544 | }; |
| 545 | 545 | |
| @@ -578,10 +578,17 @@ | ||
| 578 | 578 | setIsImporting(false); |
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | if (jobData.status === "failed") { |
| 582 | - alert( | |
| 583 | - `${type === "export" ? "Export" : "Import"} failed: ${jobData.error || "Unknown error"}`, | |
| 582 | + showToast( | |
| 583 | + (type === "export" | |
| 584 | + ? __("Export failed: %s", "yatra") | |
| 585 | + : __("Import failed: %s", "yatra") | |
| 586 | + ).replace( | |
| 587 | + "%s", | |
| 588 | + jobData.error || __("Unknown error", "yatra"), | |
| 589 | + ), | |
| 590 | + "error", | |
| 584 | 591 | ); |
| 585 | 592 | } |
| 586 | 593 | } |
| 587 | 594 | } |
| @@ -620,9 +627,9 @@ | ||
| 620 | 627 | // Clear the job after download and deletion |
| 621 | 628 | setExportJob(null); |
| 622 | 629 | } catch (error) { |
| 623 | 630 | console.error("Download error:", error); |
| 624 | - alert("Download failed. Please try again."); | |
| 631 | + showToast(__("Download failed. Please try again.", "yatra"), "error"); | |
| 625 | 632 | } |
| 626 | 633 | }; |
| 627 | 634 | |
| 628 | 635 | // Show delete confirmation modal |
| @@ -646,9 +653,9 @@ | ||
| 646 | 653 | // Immediately clear the export job from state to remove it from UI |
| 647 | 654 | setExportJob(null); |
| 648 | 655 | } catch (error) { |
| 649 | 656 | console.error("Delete error:", error); |
| 650 | - alert("Failed to delete export file."); | |
| 657 | + showToast(__("Failed to delete export file.", "yatra"), "error"); | |
| 651 | 658 | } |
| 652 | 659 | }; |
| 653 | 660 | |
| 654 | 661 | // Load logs when logs tab becomes active |
| @@ -660,9 +667,9 @@ | ||
| 660 | 667 | |
| 661 | 668 | // Handle file processing (for both input and drop) - uses background job |
| 662 | 669 | const processFile = async (file: File) => { |
| 663 | 670 | if (selectedImportData.length === 0) { |
| 664 | - alert("Please select at least one data type to import."); | |
| 671 | + showToast(__("Please select at least one data type to import.", "yatra"), "error"); | |
| 665 | 672 | return; |
| 666 | 673 | } |
| 667 | 674 | |
| 668 | 675 | setIsImporting(true); |
| @@ -679,9 +686,9 @@ | ||
| 679 | 686 | pollJobStatus(jobId, "import"); |
| 680 | 687 | setSelectedImportData([]); |
| 681 | 688 | } catch (error) { |
| 682 | 689 | console.error("Import error:", error); |
| 683 | - alert("Import failed. Please check the file format and try again."); | |
| 690 | + showToast(__("Import failed. Please check the file format and try again.", "yatra"), "error"); | |
| 684 | 691 | setIsImporting(false); |
| 685 | 692 | } |
| 686 | 693 | }; |
| 687 | 694 | |
| @@ -715,9 +722,9 @@ | ||
| 715 | 722 | (file) => file.type === "application/json" || file.name.endsWith(".json"), |
| 716 | 723 | ); |
| 717 | 724 | |
| 718 | 725 | if (!jsonFile) { |
| 719 | - alert("Please drop a valid JSON file."); | |
| 726 | + showToast(__("Please drop a valid JSON file.", "yatra"), "error"); | |
| 720 | 727 | return; |
| 721 | 728 | } |
| 722 | 729 | |
| 723 | 730 | setPendingImportFile(jsonFile); |