Seth0330 commited on
Commit
00e8c2a
·
verified ·
1 Parent(s): ee0b401

Create frontend/src/components/ExportButtons.jsx

Browse files
frontend/src/components/ExportButtons.jsx ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from "react";
2
+ import { motion, AnimatePresence } from "framer-motion";
3
+ import {
4
+ Download,
5
+ Braces,
6
+ FileCode2,
7
+ Check,
8
+ Share2,
9
+ FileJson,
10
+ Copy,
11
+ Mail,
12
+ Link2,
13
+ } from "lucide-react";
14
+ import { Button } from "@/components/ui/button";
15
+ import {
16
+ DropdownMenu,
17
+ DropdownMenuContent,
18
+ DropdownMenuItem,
19
+ DropdownMenuSeparator,
20
+ DropdownMenuTrigger,
21
+ } from "@/components/ui/dropdown-menu";
22
+ import { cn } from "@/lib/utils";
23
+
24
+ export default function ExportButtons({ isComplete }) {
25
+ const [downloading, setDownloading] = useState(null);
26
+ const [copied, setCopied] = useState(false);
27
+
28
+ const handleDownload = (format) => {
29
+ setDownloading(format);
30
+ // Simulate download
31
+ setTimeout(() => {
32
+ setDownloading(null);
33
+ }, 1500);
34
+ };
35
+
36
+ const handleCopyLink = () => {
37
+ setCopied(true);
38
+ setTimeout(() => setCopied(false), 2000);
39
+ };
40
+
41
+ if (!isComplete) return null;
42
+
43
+ return (
44
+ <motion.div
45
+ initial={{ opacity: 0, y: 20 }}
46
+ animate={{ opacity: 1, y: 0 }}
47
+ className="flex items-center gap-3"
48
+ >
49
+ {/* JSON Download */}
50
+ <Button
51
+ onClick={() => handleDownload("json")}
52
+ disabled={downloading === "json"}
53
+ className={cn(
54
+ "h-11 px-5 rounded-xl font-semibold transition-all duration-200",
55
+ "bg-gradient-to-r from-indigo-600 to-violet-600 hover:from-indigo-700 hover:to-violet-700",
56
+ "shadow-lg shadow-indigo-500/25 hover:shadow-xl hover:shadow-indigo-500/30",
57
+ "text-white"
58
+ )}
59
+ >
60
+ <AnimatePresence mode="wait">
61
+ {downloading === "json" ? (
62
+ <motion.div
63
+ key="loading"
64
+ initial={{ opacity: 0, scale: 0.8 }}
65
+ animate={{ opacity: 1, scale: 1 }}
66
+ exit={{ opacity: 0, scale: 0.8 }}
67
+ className="flex items-center gap-2"
68
+ >
69
+ <motion.div
70
+ animate={{ rotate: 360 }}
71
+ transition={{ duration: 1, repeat: Infinity, ease: "linear" }}
72
+ >
73
+ <Download className="h-4 w-4" />
74
+ </motion.div>
75
+ Downloading...
76
+ </motion.div>
77
+ ) : (
78
+ <motion.div
79
+ key="default"
80
+ initial={{ opacity: 0, scale: 0.8 }}
81
+ animate={{ opacity: 1, scale: 1 }}
82
+ exit={{ opacity: 0, scale: 0.8 }}
83
+ className="flex items-center gap-2"
84
+ >
85
+ <Braces className="h-4 w-4" />
86
+ Download JSON
87
+ </motion.div>
88
+ )}
89
+ </AnimatePresence>
90
+ </Button>
91
+
92
+ {/* XML Download */}
93
+ <Button
94
+ onClick={() => handleDownload("xml")}
95
+ disabled={downloading === "xml"}
96
+ variant="outline"
97
+ className={cn(
98
+ "h-11 px-5 rounded-xl font-semibold transition-all duration-200",
99
+ "border-2 border-slate-200 hover:border-slate-300",
100
+ "hover:bg-slate-50"
101
+ )}
102
+ >
103
+ <AnimatePresence mode="wait">
104
+ {downloading === "xml" ? (
105
+ <motion.div
106
+ key="loading"
107
+ initial={{ opacity: 0, scale: 0.8 }}
108
+ animate={{ opacity: 1, scale: 1 }}
109
+ exit={{ opacity: 0, scale: 0.8 }}
110
+ className="flex items-center gap-2"
111
+ >
112
+ <motion.div
113
+ animate={{ rotate: 360 }}
114
+ transition={{ duration: 1, repeat: Infinity, ease: "linear" }}
115
+ >
116
+ <Download className="h-4 w-4" />
117
+ </motion.div>
118
+ Downloading...
119
+ </motion.div>
120
+ ) : (
121
+ <motion.div
122
+ key="default"
123
+ initial={{ opacity: 0, scale: 0.8 }}
124
+ animate={{ opacity: 1, scale: 1 }}
125
+ exit={{ opacity: 0, scale: 0.8 }}
126
+ className="flex items-center gap-2"
127
+ >
128
+ <FileCode2 className="h-4 w-4" />
129
+ Download XML
130
+ </motion.div>
131
+ )}
132
+ </AnimatePresence>
133
+ </Button>
134
+
135
+ {/* More Options Dropdown */}
136
+ <DropdownMenu>
137
+ <DropdownMenuTrigger asChild>
138
+ <Button variant="ghost" className="h-11 w-11 rounded-xl">
139
+ <Share2 className="h-4 w-4" />
140
+ </Button>
141
+ </DropdownMenuTrigger>
142
+ <DropdownMenuContent align="end" className="w-48 rounded-xl p-2">
143
+ <DropdownMenuItem
144
+ className="rounded-lg cursor-pointer"
145
+ onClick={handleCopyLink}
146
+ >
147
+ {copied ? (
148
+ <Check className="h-4 w-4 mr-2 text-emerald-500" />
149
+ ) : (
150
+ <Link2 className="h-4 w-4 mr-2" />
151
+ )}
152
+ {copied ? "Link copied!" : "Copy share link"}
153
+ </DropdownMenuItem>
154
+ <DropdownMenuItem className="rounded-lg cursor-pointer">
155
+ <Copy className="h-4 w-4 mr-2" />
156
+ Copy to clipboard
157
+ </DropdownMenuItem>
158
+ <DropdownMenuSeparator />
159
+ <DropdownMenuItem className="rounded-lg cursor-pointer">
160
+ <Mail className="h-4 w-4 mr-2" />
161
+ Send via email
162
+ </DropdownMenuItem>
163
+ <DropdownMenuItem className="rounded-lg cursor-pointer">
164
+ <FileJson className="h-4 w-4 mr-2" />
165
+ Export to Google Sheets
166
+ </DropdownMenuItem>
167
+ </DropdownMenuContent>
168
+ </DropdownMenu>
169
+ </motion.div>
170
+ );
171
+ }