Update frontend/src/components/ExportButtons.jsx
Browse files
frontend/src/components/ExportButtons.jsx
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
| 8 |
Share2,
|
| 9 |
FileText,
|
| 10 |
Link2,
|
|
|
|
| 11 |
} from "lucide-react";
|
| 12 |
import { Button } from "@/components/ui/button";
|
| 13 |
import {
|
|
@@ -18,6 +19,8 @@ import {
|
|
| 18 |
DropdownMenuTrigger,
|
| 19 |
} from "@/components/ui/dropdown-menu";
|
| 20 |
import { cn } from "@/lib/utils";
|
|
|
|
|
|
|
| 21 |
|
| 22 |
// Helper functions from ExtractionOutput
|
| 23 |
function prepareFieldsForOutput(fields, format = "json") {
|
|
@@ -173,6 +176,7 @@ function objectToXML(obj, rootName = "extraction") {
|
|
| 173 |
export default function ExportButtons({ isComplete, extractionResult }) {
|
| 174 |
const [downloading, setDownloading] = useState(null);
|
| 175 |
const [copied, setCopied] = useState(false);
|
|
|
|
| 176 |
|
| 177 |
// Helper function to extract text from fields (same as in ExtractionOutput)
|
| 178 |
const extractTextFromFields = (fields) => {
|
|
@@ -538,6 +542,10 @@ ${htmlContent}
|
|
| 538 |
setTimeout(() => setCopied(false), 2000);
|
| 539 |
};
|
| 540 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 541 |
if (!isComplete) return null;
|
| 542 |
|
| 543 |
return (
|
|
@@ -567,6 +575,14 @@ ${htmlContent}
|
|
| 567 |
</Button>
|
| 568 |
</DropdownMenuTrigger>
|
| 569 |
<DropdownMenuContent align="end" className="w-56 rounded-xl p-2">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 570 |
<DropdownMenuItem
|
| 571 |
className="rounded-lg cursor-pointer"
|
| 572 |
onClick={handleCopyLink}
|
|
@@ -635,6 +651,14 @@ ${htmlContent}
|
|
| 635 |
</DropdownMenuItem>
|
| 636 |
</DropdownMenuContent>
|
| 637 |
</DropdownMenu>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 638 |
</motion.div>
|
| 639 |
);
|
| 640 |
}
|
|
|
|
| 8 |
Share2,
|
| 9 |
FileText,
|
| 10 |
Link2,
|
| 11 |
+
Mail,
|
| 12 |
} from "lucide-react";
|
| 13 |
import { Button } from "@/components/ui/button";
|
| 14 |
import {
|
|
|
|
| 19 |
DropdownMenuTrigger,
|
| 20 |
} from "@/components/ui/dropdown-menu";
|
| 21 |
import { cn } from "@/lib/utils";
|
| 22 |
+
import ShareModal from "@/components/ShareModal";
|
| 23 |
+
import { shareExtraction } from "@/services/api";
|
| 24 |
|
| 25 |
// Helper functions from ExtractionOutput
|
| 26 |
function prepareFieldsForOutput(fields, format = "json") {
|
|
|
|
| 176 |
export default function ExportButtons({ isComplete, extractionResult }) {
|
| 177 |
const [downloading, setDownloading] = useState(null);
|
| 178 |
const [copied, setCopied] = useState(false);
|
| 179 |
+
const [isShareModalOpen, setIsShareModalOpen] = useState(false);
|
| 180 |
|
| 181 |
// Helper function to extract text from fields (same as in ExtractionOutput)
|
| 182 |
const extractTextFromFields = (fields) => {
|
|
|
|
| 542 |
setTimeout(() => setCopied(false), 2000);
|
| 543 |
};
|
| 544 |
|
| 545 |
+
const handleShare = async (extractionId, recipientEmail) => {
|
| 546 |
+
await shareExtraction(extractionId, recipientEmail);
|
| 547 |
+
};
|
| 548 |
+
|
| 549 |
if (!isComplete) return null;
|
| 550 |
|
| 551 |
return (
|
|
|
|
| 575 |
</Button>
|
| 576 |
</DropdownMenuTrigger>
|
| 577 |
<DropdownMenuContent align="end" className="w-56 rounded-xl p-2">
|
| 578 |
+
<DropdownMenuItem
|
| 579 |
+
className="rounded-lg cursor-pointer"
|
| 580 |
+
onClick={() => setIsShareModalOpen(true)}
|
| 581 |
+
>
|
| 582 |
+
<Mail className="h-4 w-4 mr-2 text-indigo-600" />
|
| 583 |
+
Share Output
|
| 584 |
+
</DropdownMenuItem>
|
| 585 |
+
<DropdownMenuSeparator />
|
| 586 |
<DropdownMenuItem
|
| 587 |
className="rounded-lg cursor-pointer"
|
| 588 |
onClick={handleCopyLink}
|
|
|
|
| 651 |
</DropdownMenuItem>
|
| 652 |
</DropdownMenuContent>
|
| 653 |
</DropdownMenu>
|
| 654 |
+
|
| 655 |
+
{/* Share Modal */}
|
| 656 |
+
<ShareModal
|
| 657 |
+
isOpen={isShareModalOpen}
|
| 658 |
+
onClose={() => setIsShareModalOpen(false)}
|
| 659 |
+
onShare={handleShare}
|
| 660 |
+
extractionId={extractionResult?.id}
|
| 661 |
+
/>
|
| 662 |
</motion.div>
|
| 663 |
);
|
| 664 |
}
|