samifalouti commited on
Commit
82f3ac4
·
verified ·
1 Parent(s): 7e45eab

Add 19 files

Browse files
.gitattributes CHANGED
@@ -58,3 +58,12 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
60
  apks/application-fdef46ad-b886-4e2b-a01f-bc2f6d2208bf.apk filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
60
  apks/application-fdef46ad-b886-4e2b-a01f-bc2f6d2208bf.apk filter=lfs diff=lfs merge=lfs -text
61
+ dfghjk5.ai filter=lfs diff=lfs merge=lfs -text
62
+ fdghjkl4.ai filter=lfs diff=lfs merge=lfs -text
63
+ Untitled-1.ai filter=lfs diff=lfs merge=lfs -text
64
+ Untitled-2.ai filter=lfs diff=lfs merge=lfs -text
65
+ Untitled-3.ai filter=lfs diff=lfs merge=lfs -text
66
+ Untitled-65e43.ai filter=lfs diff=lfs merge=lfs -text
67
+ Untitled-7689.ai filter=lfs diff=lfs merge=lfs -text
68
+ Untitled-dsa.ai filter=lfs diff=lfs merge=lfs -text
69
+ yguhijk3.ai filter=lfs diff=lfs merge=lfs -text
LogoDesigner.tsx ADDED
@@ -0,0 +1,1128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useEffect } from 'react';
2
+ import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";
3
+ import { Button } from "@/components/ui/button";
4
+ import { Textarea } from "@/components/ui/textarea";
5
+ import { Input } from "@/components/ui/input";
6
+ import { Label } from "@/components/ui/label";
7
+ import { Skeleton } from "@/components/ui/skeleton";
8
+ import { Badge } from "@/components/ui/badge";
9
+ import { Progress } from "@/components/ui/progress";
10
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
11
+ import { Slider } from "@/components/ui/slider";
12
+ import {
13
+ Sparkles,
14
+ Download,
15
+ Image as ImageIcon,
16
+ Palette,
17
+ Wand2,
18
+ RefreshCw,
19
+ Star,
20
+ Zap,
21
+ Grid3X3,
22
+ Type,
23
+ Heart,
24
+ ChevronRight,
25
+ Layers,
26
+ Target,
27
+ Lightbulb,
28
+ Crown
29
+ } from 'lucide-react';
30
+ import {
31
+ Select,
32
+ SelectContent,
33
+ SelectItem,
34
+ SelectTrigger,
35
+ SelectValue,
36
+ } from "@/components/ui/select";
37
+ import { Alert, AlertDescription } from "@/components/ui/alert";
38
+ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
39
+ import { useTranslation } from 'react-i18next';
40
+ import { supabase } from '@/integrations/supabase/client';
41
+ import { useSession } from '@supabase/auth-helpers-react';
42
+ import { showSuccess, showError, showLoading, dismissToast } from '@/utils/toast';
43
+
44
+ // Define interfaces for user data
45
+ interface UserProfile {
46
+ id: string;
47
+ logo_generations_this_month: number;
48
+ last_logo_generation_month?: string;
49
+ }
50
+
51
+ interface UserSubscription {
52
+ id: string;
53
+ plan: '50' | '100' | 'unlimited';
54
+ start_date: string;
55
+ end_date: string;
56
+ is_trial: boolean;
57
+ }
58
+
59
+ // Define available models for logo generation
60
+ const availableModels = [
61
+ { id: 'FLUX-PRO', nameKey: 'Sool Designer pro', description: 'A professional logo design model' },
62
+ { id: 'flux', nameKey: 'Sool Designer 0.2v', description: 'A logo design model' },
63
+ { id: 'FLUX-3D', nameKey: 'Sool Designer 0.1v 3D', description: 'A 3D logo design model' },
64
+ { id: 'Flux-cablyai', nameKey: 'Sool Designer 0.1v', description: 'A logo design model' },
65
+ ];
66
+
67
+ // Enhanced color palette options
68
+ const colorPalettes = [
69
+ { name: 'Modern Blue', colors: ['#3B82F6', '#1D4ED8', '#60A5FA'] },
70
+ { name: 'Vibrant Purple', colors: ['#8B5CF6', '#7C3AED', '#A78BFA'] },
71
+ { name: 'Fresh Green', colors: ['#10B981', '#059669', '#34D399'] },
72
+ { name: 'Warm Orange', colors: ['#F59E0B', '#D97706', '#FBBF24'] },
73
+ { name: 'Classic Black', colors: ['#000000', '#374151', '#6B7280'] },
74
+ { name: 'Elegant Gold', colors: ['#F59E0B', '#D97706', '#FDE047'] }
75
+ ];
76
+
77
+ // Industry templates with smart suggestions
78
+ const industryTemplates = {
79
+ 'Technology': {
80
+ suggestedStyles: ['Modern', 'Futuristic', 'Minimalist'],
81
+ suggestedColors: ['#3B82F6', '#8B5CF6', '#06B6D4'],
82
+ suggestedElements: 'circuits, geometric shapes, abstract symbols'
83
+ },
84
+ 'Health & Wellness': {
85
+ suggestedStyles: ['Clean', 'Organic', 'Trustworthy'],
86
+ suggestedColors: ['#10B981', '#3B82F6', '#F59E0B'],
87
+ suggestedElements: 'leaves, hearts, wellness symbols'
88
+ },
89
+ 'Finance': {
90
+ suggestedStyles: ['Professional', 'Trustworthy', 'Classic'],
91
+ suggestedColors: ['#1F2937', '#3B82F6', '#059669'],
92
+ suggestedElements: 'arrows, graphs, stability symbols'
93
+ },
94
+ 'Fashion': {
95
+ suggestedStyles: ['Elegant', 'Modern', 'Minimalist'],
96
+ suggestedColors: ['#E879F9', '#F472B6', '#FBCFE8'],
97
+ suggestedElements: 'abstract shapes, flowing lines, stylized initials'
98
+ },
99
+ 'Food & Beverage': {
100
+ suggestedStyles: ['Playful', 'Organic', 'Bold'],
101
+ suggestedColors: ['#F59E0B', '#EF4444', '#22C55E'],
102
+ suggestedElements: 'fruits, vegetables, kitchen utensils, abstract food shapes'
103
+ },
104
+ 'Real Estate': {
105
+ suggestedStyles: ['Professional', 'Trustworthy', 'Modern'],
106
+ suggestedColors: ['#1D4ED8', '#059669', '#F59E0B'],
107
+ suggestedElements: 'houses, buildings, keys, roofs, geometric shapes'
108
+ },
109
+ 'Education': {
110
+ suggestedStyles: ['Clean', 'Inspiring', 'Friendly'],
111
+ suggestedColors: ['#6366F1', '#3B82F6', '#F59E0B'],
112
+ suggestedElements: 'books, graduation caps, lightbulbs, abstract learning symbols'
113
+ },
114
+ 'Entertainment': {
115
+ suggestedStyles: ['Creative', 'Bold', 'Vibrant'],
116
+ suggestedColors: ['#A855F7', '#EC4899', '#F97316'],
117
+ suggestedElements: 'stars, abstract shapes, musical notes, film reels'
118
+ },
119
+ 'Sports & Fitness': {
120
+ suggestedStyles: ['Dynamic', 'Bold', 'Energetic'],
121
+ suggestedColors: ['#EF4444', '#3B82F6', '#10B981'],
122
+ suggestedElements: 'abstract motion, athletic figures, sports equipment'
123
+ },
124
+ 'Automotive': {
125
+ suggestedStyles: ['Sleek', 'Modern', 'Powerful'],
126
+ suggestedColors: ['#1F2937', '#6B7280', '#EF4444'],
127
+ suggestedElements: 'car silhouettes, wheels, speed lines, geometric shapes'
128
+ }
129
+ };
130
+
131
+ const LOCAL_STORAGE_LOGO_GEN_DATE_KEY = 'lastLogoGenerationDate';
132
+
133
+ const LogoDesigner = () => {
134
+ const { t } = useTranslation();
135
+ const session = useSession();
136
+ const isAuthenticated = !!session;
137
+
138
+ // Form State
139
+ const [brandName, setBrandName] = useState('');
140
+ const [industry, setIndustry] = useState('');
141
+ const [targetAudience, setTargetAudience] = useState('');
142
+ const [style, setStyle] = useState('');
143
+ const [colors, setColors] = useState('#6366f1');
144
+ const [keyElements, setKeyElements] = useState('');
145
+ const [textInLogo, setTextInLogo] = useState('');
146
+ const [negativeConstraints, setNegativeConstraints] = useState('');
147
+
148
+ // Advanced options
149
+ const [logoComplexity, setLogoComplexity] = useState([50]);
150
+ const [logoSize, setLogoSize] = useState('medium');
151
+ const [logoOrientation, setLogoOrientation] = useState('square');
152
+ const [selectedModel, setSelectedModel] = useState(availableModels[0].id);
153
+
154
+ // UI State
155
+ const [generatedImageUrls, setGeneratedImageUrls] = useState(null);
156
+ const [loadingGeneration, setLoadingGeneration] = useState(false);
157
+ const [errorGeneration, setErrorGeneration] = useState(null);
158
+ const [isDownloading, setIsDownloading] = useState(false);
159
+ const [activeTab, setActiveTab] = useState('basic');
160
+ const [favoriteLogos, setFavoriteLogos] = useState(new Set());
161
+ const [limitReachedReason, setLimitReachedReason] = useState(null);
162
+
163
+ // User Data State
164
+ const [userProfile, setUserProfile] = useState(null);
165
+ const [userSubscription, setUserSubscription] = useState(null);
166
+ const [isLoadingUserData, setIsLoadingUserData] = useState(true);
167
+
168
+ // Fetch user profile and subscription
169
+ useEffect(() => {
170
+ const fetchUserData = async () => {
171
+ if (!isAuthenticated || !session?.user?.id) {
172
+ setUserProfile(null);
173
+ setUserSubscription(null);
174
+ setIsLoadingUserData(false);
175
+ return;
176
+ }
177
+
178
+ setIsLoadingUserData(true);
179
+ const userId = session.user.id;
180
+
181
+ // Fetch profile
182
+ let { data: profileData, error: profileError } = await supabase
183
+ .from('profiles')
184
+ .select('id, logo_generations_this_month, last_logo_generation_month')
185
+ .eq('id', userId)
186
+ .single();
187
+
188
+ if (profileError && profileError.code === 'PGRST116') {
189
+ const { data: newProfileData, error: insertError } = await supabase
190
+ .from('profiles')
191
+ .insert([{ id: userId }])
192
+ .select('id, logo_generations_this_month, last_logo_generation_month')
193
+ .single();
194
+
195
+ if (insertError) {
196
+ showError(t('accountPage.toast.createProfileError') + `: ${insertError.message}`);
197
+ setUserProfile(null);
198
+ } else {
199
+ profileData = newProfileData;
200
+ }
201
+ } else if (profileError) {
202
+ showError(t('accountPage.toast.fetchProfileError') + `: ${profileError.message}`);
203
+ setUserProfile(null);
204
+ }
205
+
206
+ if (profileData) {
207
+ const currentMonth = new Date();
208
+ const lastMonth = profileData.last_logo_generation_month ? new Date(profileData.last_logo_generation_month) : null;
209
+ const isSameMonth = lastMonth && lastMonth.getMonth() === currentMonth.getMonth() && lastMonth.getFullYear() === currentMonth.getFullYear();
210
+
211
+ if (!isSameMonth) {
212
+ const { error: updateError } = await supabase
213
+ .from('profiles')
214
+ .update({
215
+ logo_generations_this_month: 0,
216
+ last_logo_generation_month: currentMonth.toISOString().split('T')[0]
217
+ })
218
+ .eq('id', userId);
219
+
220
+ if (updateError) {
221
+ showError(t('accountPage.toast.resetCountError'));
222
+ setUserProfile(profileData);
223
+ } else {
224
+ setUserProfile({ ...profileData, logo_generations_this_month: 0, last_logo_generation_month: currentMonth.toISOString().split('T')[0] });
225
+ }
226
+ } else {
227
+ setUserProfile(profileData);
228
+ }
229
+ }
230
+
231
+ // Fetch subscription
232
+ const { data: subscriptionData, error: subscriptionError } = await supabase
233
+ .from('subscriptions')
234
+ .select('id, plan, end_date, is_trial')
235
+ .eq('company_id', userId)
236
+ .gte('end_date', new Date().toISOString().split('T')[0])
237
+ .single();
238
+
239
+ if (subscriptionError && subscriptionError.code !== 'PGRST116') {
240
+ showError(t('accountPage.toast.fetchSubscriptionError') + `: ${subscriptionError.message}`);
241
+ setUserSubscription(null);
242
+ } else {
243
+ setUserSubscription(subscriptionData);
244
+ }
245
+
246
+ setIsLoadingUserData(false);
247
+ };
248
+
249
+ fetchUserData();
250
+ }, [session, isAuthenticated, t]);
251
+
252
+ // Smart suggestions
253
+ const getSmartSuggestions = () => {
254
+ const suggestions = [];
255
+
256
+ if (industry && industryTemplates[industry]) {
257
+ const template = industryTemplates[industry];
258
+ if (!style) {
259
+ suggestions.push({
260
+ type: 'style',
261
+ text: `Try "${template.suggestedStyles[0]}" style for ${industry}`,
262
+ action: () => setStyle(template.suggestedStyles[0])
263
+ });
264
+ }
265
+ if (!keyElements) {
266
+ suggestions.push({
267
+ type: 'elements',
268
+ text: `Consider adding: ${template.suggestedElements}`,
269
+ action: () => setKeyElements(template.suggestedElements)
270
+ });
271
+ }
272
+ }
273
+
274
+ if (brandName && !textInLogo) {
275
+ suggestions.push({
276
+ type: 'text',
277
+ text: `Include "${brandName}" in the logo`,
278
+ action: () => setTextInLogo(brandName)
279
+ });
280
+ }
281
+
282
+ return suggestions;
283
+ };
284
+
285
+ // Progress calculation
286
+ const getFormProgress = () => {
287
+ const fields = [brandName, industry, targetAudience, style, colors, keyElements];
288
+ const filledFields = fields.filter(field => field && field.trim()).length;
289
+ return Math.round((filledFields / fields.length) * 100);
290
+ };
291
+
292
+ // Logo generation
293
+ const handleGenerateLogo = async () => {
294
+ if (loadingGeneration) return;
295
+
296
+ // Validate required fields
297
+ if (!brandName.trim() && !industry.trim() && !keyElements.trim()) {
298
+ setErrorGeneration(t('logoDesignerPage.validation.minimumInput'));
299
+ return;
300
+ }
301
+
302
+ let logoGenerationLimit = 3;
303
+ let currentLogoGenerations = 0;
304
+ let canGenerate = false;
305
+ let limitReason = null;
306
+
307
+ if (!isAuthenticated) {
308
+ const lastGenDate = localStorage.getItem(LOCAL_STORAGE_LOGO_GEN_DATE_KEY);
309
+ const today = new Date().toDateString();
310
+ if (lastGenDate === today) {
311
+ limitReason = 'free_tier';
312
+ } else {
313
+ canGenerate = true;
314
+ logoGenerationLimit = 1;
315
+ }
316
+ } else {
317
+ if (isLoadingUserData || !userProfile) {
318
+ showError(t('logoDesignerPage.toast.userDataLoading'));
319
+ return;
320
+ }
321
+
322
+ currentLogoGenerations = userProfile.logo_generations_this_month || 0;
323
+ const lastMonth = userProfile.last_logo_generation_month ? new Date(userProfile.last_logo_generation_month) : null;
324
+ const currentMonth = new Date();
325
+ const isSameMonth = lastMonth && lastMonth.getMonth() === currentMonth.getMonth() && lastMonth.getFullYear() === currentMonth.getFullYear();
326
+
327
+ if (userSubscription) {
328
+ if (userSubscription.is_trial) {
329
+ logoGenerationLimit = 10;
330
+ } else {
331
+ switch (userSubscription.plan) {
332
+ case '50': logoGenerationLimit = 25; break;
333
+ case '100': logoGenerationLimit = 50; break;
334
+ case 'unlimited': logoGenerationLimit = 'unlimited'; break;
335
+ default: logoGenerationLimit = 3; break;
336
+ }
337
+ }
338
+ }
339
+
340
+ if (logoGenerationLimit !== 'unlimited' && currentLogoGenerations >= logoGenerationLimit && isSameMonth) {
341
+ limitReason = userSubscription ? 'plan_limit' : 'free_tier';
342
+ } else {
343
+ canGenerate = true;
344
+ }
345
+ }
346
+
347
+ if (limitReason) {
348
+ setLimitReachedReason(limitReason);
349
+ return;
350
+ }
351
+
352
+ setLoadingGeneration(true);
353
+ setErrorGeneration(null);
354
+ setGeneratedImageUrls(null);
355
+ const toastId = showLoading(t('logoDesignerPage.toast.generating'));
356
+
357
+ const constructedPrompt = `
358
+ Create a professional logo design for "${brandName.trim() || 'Brand'}".
359
+
360
+ Brand Specifications:
361
+ - Industry: ${industry.trim() || 'General Business'}
362
+ - Target Audience: ${targetAudience.trim() || 'Professional Market'}
363
+
364
+ Design Requirements:
365
+ - Style: ${style.trim() || 'Modern minimalist'}
366
+ - Color Palette: ${colors} with strategic accent colors
367
+ - Typography: ${textInLogo.trim() ? `Include text "${textInLogo.trim()}"` : 'Icon-focused design'}
368
+ - Key Elements: ${keyElements.trim() || 'Clean geometric forms'}
369
+ - Complexity Level: ${logoComplexity[0]}% visual detail
370
+ - Format: ${logoOrientation} layout, optimized for ${logoSize}
371
+
372
+ Technical Specifications:
373
+ - Vector-based design for infinite scalability
374
+ - High contrast for readability at any size
375
+ - Production-ready with proper spacing and proportions
376
+ - Versatile across print and digital media
377
+
378
+ Constraints:
379
+ ${negativeConstraints.trim() || 'Avoid: overcomplicated details, poor legibility, generic clipart, inconsistent styling'}
380
+
381
+ Output: Single definitive logo design that embodies the brand essence while maintaining professional versatility.
382
+ `.trim();
383
+
384
+ try {
385
+ const { data, error: functionError } = await supabase.functions.invoke(
386
+ 'generate-image',
387
+ {
388
+ body: {
389
+ prompt: constructedPrompt,
390
+ modelType: selectedModel,
391
+ outputType: 'multiple'
392
+ }
393
+ }
394
+ );
395
+
396
+ dismissToast(toastId);
397
+
398
+ if (functionError || (data && data.error)) {
399
+ const errorMsg = functionError?.message || data?.error?.message || t('logoDesignerPage.toast.generationError');
400
+ setErrorGeneration(errorMsg);
401
+ } else if (data && data.imageUrls && data.imageUrls.length > 0) {
402
+ setGeneratedImageUrls(data.imageUrls);
403
+ showSuccess(t('logoDesignerPage.toast.generationSuccess'));
404
+
405
+ const logosToInsert = data.imageUrls.map(url => ({
406
+ user_id: session?.user?.id || null,
407
+ prompt: constructedPrompt,
408
+ image_url: url
409
+ }));
410
+
411
+ const { error: insertError } = await supabase
412
+ .from('generated_logos')
413
+ .insert(logosToInsert);
414
+
415
+ if (insertError) {
416
+ showError(t('logoDesignerPage.toast.saveError') + `: ${insertError.message}`);
417
+ } else if (isAuthenticated && session?.user?.id && logoGenerationLimit !== 'unlimited') {
418
+ const userId = session.user.id;
419
+ const { data: latestProfile, error: latestProfileError } = await supabase
420
+ .from('profiles')
421
+ .select('logo_generations_this_month, last_logo_generation_month')
422
+ .eq('id', userId)
423
+ .single();
424
+
425
+ if (latestProfileError && latestProfileError.code !== 'PGRST116') {
426
+ showError(t('logoDesignerPage.toast.incrementCountError'));
427
+ } else {
428
+ const latestGenerations = latestProfile?.logo_generations_this_month || 0;
429
+ const latestLastMonth = latestProfile?.last_logo_generation_month ? new Date(latestProfile.last_logo_generation_month) : null;
430
+ const latestCurrentMonth = new Date();
431
+ const isLatestSameMonth = latestLastMonth && latestLastMonth.getMonth() === latestCurrentMonth.getMonth() && latestLastMonth.getFullYear() === latestCurrentMonth.getFullYear();
432
+
433
+ let generationsToUpdate = latestGenerations;
434
+ let lastMonthToUpdate = latestLastMonth;
435
+
436
+ if (!isLatestSameMonth) {
437
+ generationsToUpdate = 0;
438
+ lastMonthToUpdate = latestCurrentMonth;
439
+ }
440
+
441
+ const { error: updateError } = await supabase
442
+ .from('profiles')
443
+ .update({
444
+ logo_generations_this_month: generationsToUpdate + 1,
445
+ last_logo_generation_month: lastMonthToUpdate?.toISOString().split('T')[0] || latestCurrentMonth.toISOString().split('T')[0]
446
+ })
447
+ .eq('id', userId);
448
+
449
+ if (updateError) {
450
+ showError(t('logoDesignerPage.toast.incrementCountError'));
451
+ } else {
452
+ setUserProfile(prevProfile => ({
453
+ ...prevProfile,
454
+ logo_generations_this_month: generationsToUpdate + 1,
455
+ last_logo_generation_month: lastMonthToUpdate?.toISOString().split('T')[0] || latestCurrentMonth.toISOString().split('T')[0]
456
+ }));
457
+ }
458
+ }
459
+ } else if (!isAuthenticated) {
460
+ localStorage.setItem(LOCAL_STORAGE_LOGO_GEN_DATE_KEY, new Date().toDateString());
461
+ setLimitReachedReason('free_tier');
462
+ }
463
+ } else {
464
+ setErrorGeneration(t('logoDesignerPage.toast.unexpectedResponse'));
465
+ }
466
+ } catch (err) {
467
+ dismissToast(toastId);
468
+ setErrorGeneration(t('logoDesignerPage.toast.generationErrorUnexpected') + `: ${err.message}`);
469
+ } finally {
470
+ setLoadingGeneration(false);
471
+ }
472
+ };
473
+
474
+ // Download image
475
+ const handleDownloadImage = async (imageUrl, format = 'png') => {
476
+ if (!imageUrl || isDownloading) {
477
+ if (!imageUrl) showError(t('logoDesignerPage.toast.downloadErrorEmpty'));
478
+ return;
479
+ }
480
+
481
+ setIsDownloading(true);
482
+ const toastId = showLoading(t('logoDesignerPage.toast.downloading'));
483
+
484
+ try {
485
+ const response = await fetch(imageUrl, { mode: 'cors' });
486
+ const blob = await response.blob();
487
+ const url = window.URL.createObjectURL(blob);
488
+ const link = document.createElement('a');
489
+ link.href = url;
490
+ link.download = `${brandName || 'logo'}-${Date.now()}.${format}`;
491
+ document.body.appendChild(link);
492
+ link.click();
493
+ document.body.removeChild(link);
494
+ window.URL.revokeObjectURL(url);
495
+ dismissToast(toastId);
496
+ showSuccess(t('logoDesignerPage.toast.downloadSuccess'));
497
+ } catch (err) {
498
+ dismissToast(toastId);
499
+ showError(t('logoDesignerPage.toast.downloadError') + `: ${err.message}`);
500
+ } finally {
501
+ setIsDownloading(false);
502
+ }
503
+ };
504
+
505
+ // Toggle favorite logo
506
+ const toggleFavorite = (index) => {
507
+ const newFavorites = new Set(favoriteLogos);
508
+ if (newFavorites.has(index)) {
509
+ newFavorites.delete(index);
510
+ } else {
511
+ newFavorites.add(index);
512
+ }
513
+ setFavoriteLogos(newFavorites);
514
+ };
515
+
516
+ // Reset form
517
+ const handleResetForm = () => {
518
+ setBrandName('');
519
+ setIndustry('');
520
+ setTargetAudience('');
521
+ setStyle('');
522
+ setColors('#6366f1');
523
+ setKeyElements('');
524
+ setTextInLogo('');
525
+ setNegativeConstraints('');
526
+ setLogoComplexity([50]);
527
+ setLogoSize('medium');
528
+ setLogoOrientation('square');
529
+ setSelectedModel(availableModels[0].id);
530
+ setGeneratedImageUrls(null);
531
+ setErrorGeneration(null);
532
+ setFavoriteLogos(new Set());
533
+ };
534
+
535
+ // Auto-save to local storage
536
+ useEffect(() => {
537
+ const formData = {
538
+ brandName, industry, targetAudience, style, colors,
539
+ keyElements, textInLogo, negativeConstraints,
540
+ logoComplexity, logoSize, logoOrientation, selectedModel
541
+ };
542
+ localStorage.setItem('logoDesignerForm', JSON.stringify(formData));
543
+ }, [brandName, industry, targetAudience, style, colors, keyElements, textInLogo, negativeConstraints, logoComplexity, logoSize, logoOrientation, selectedModel]);
544
+
545
+ // Load from local storage
546
+ useEffect(() => {
547
+ const saved = localStorage.getItem('logoDesignerForm');
548
+ if (saved) {
549
+ try {
550
+ const data = JSON.parse(saved);
551
+ setBrandName(data.brandName || '');
552
+ setIndustry(data.industry || '');
553
+ setTargetAudience(data.targetAudience || '');
554
+ setStyle(data.style || '');
555
+ setColors(data.colors || '#6366f1');
556
+ setKeyElements(data.keyElements || '');
557
+ setTextInLogo(data.textInLogo || '');
558
+ setNegativeConstraints(data.negativeConstraints || '');
559
+ setLogoComplexity(data.logoComplexity || [50]);
560
+ setLogoSize(data.logoSize || 'medium');
561
+ setLogoOrientation(data.logoOrientation || 'square');
562
+ setSelectedModel(data.selectedModel || availableModels[0].id);
563
+ } catch (e) {
564
+ console.error('Failed to load saved form data');
565
+ }
566
+ }
567
+ }, []);
568
+
569
+ const suggestions = getSmartSuggestions();
570
+ const progress = getFormProgress();
571
+ let logoGenerationLimitDisplay = isAuthenticated && userSubscription ?
572
+ (userSubscription.is_trial ? 10 :
573
+ userSubscription.plan === 'unlimited' ? t('accountPage.unlimited') :
574
+ userSubscription.plan === '100' ? 50 : 25) : 3;
575
+ const currentLogoGenerationsDisplay = userProfile?.logo_generations_this_month || 0;
576
+ const displayUsageText = isAuthenticated && logoGenerationLimitDisplay !== t('accountPage.unlimited') ?
577
+ `${currentLogoGenerationsDisplay}/${logoGenerationLimitDisplay}` : logoGenerationLimitDisplay;
578
+
579
+ return (
580
+ <TooltipProvider>
581
+ <div className="min-h-screen">
582
+ <div className="container mx-auto p-4 lg:p-8 space-y-8">
583
+ {/* Header */}
584
+ <div className="text-center space-y-4">
585
+ <div className="flex items-center justify-center space-x-3 mb-6">
586
+ <div className="relative">
587
+ <Palette className="h-12 w-12 text-purple-400" />
588
+ <Sparkles className="h-6 w-6 text-yellow-400 absolute -top-1 -right-1 animate-pulse" />
589
+ </div>
590
+ </div>
591
+ <h1 className="text-4xl lg:text-6xl font-bold bg-gradient-to-r from-purple-400 via-pink-400 to-indigo-400 bg-clip-text text-transparent">
592
+ AI Logo Designer
593
+ </h1>
594
+ <p className="text-xl text-slate-300 max-w-2xl mx-auto">
595
+ Create stunning, professional logos in seconds with AI-powered design intelligence
596
+ </p>
597
+ <div className="flex items-center justify-center space-x-8 text-sm text-slate-400 bg-slate-800/50 rounded-full px-6 py-3 backdrop-blur-sm">
598
+ <div className="flex items-center space-x-2">
599
+ <Crown className="h-4 w-4 text-yellow-400" />
600
+ <span>Premium Quality</span>
601
+ </div>
602
+ <div className="flex items-center space-x-2">
603
+ <Zap className="h-4 w-4 text-blue-400" />
604
+ <span>{displayUsageText} generations left</span>
605
+ </div>
606
+ <div className="flex items-center space-x-2">
607
+ <Target className="h-4 w-4 text-green-400" />
608
+ <span>Industry-specific</span>
609
+ </div>
610
+ </div>
611
+ </div>
612
+
613
+ <div className="grid grid-cols-1 xl:grid-cols-5 gap-8">
614
+ {/* Form Section */}
615
+ <div className="xl:col-span-2 space-y-6">
616
+ <Card className="bg-slate-900/50 border-slate-700/50 backdrop-blur-sm">
617
+ <CardHeader>
618
+ <div className="flex items-center justify-between">
619
+ <CardTitle className="text-xl text-white flex items-center space-x-2">
620
+ <Wand2 className="h-5 w-5 text-purple-400" />
621
+ <span>Design Brief</span>
622
+ </CardTitle>
623
+ <Badge variant="outline" className="text-purple-400 border-purple-400">
624
+ {progress}% Complete
625
+ </Badge>
626
+ </div>
627
+ <Progress value={progress} className="h-2" />
628
+ </CardHeader>
629
+
630
+ <CardContent className="space-y-6">
631
+ <Tabs value={activeTab} onValueChange={setActiveTab}>
632
+ <TabsList className="grid w-full grid-cols-2 bg-slate-800">
633
+ <TabsTrigger value="basic" className="text-xs">Basic Info</TabsTrigger>
634
+ <TabsTrigger value="advanced" className="text-xs">Style & Advanced</TabsTrigger>
635
+ </TabsList>
636
+
637
+ <TabsContent value="basic" className="space-y-4 mt-6">
638
+ <div className="space-y-2">
639
+ <Label className="text-white flex items-center space-x-2">
640
+ <Type className="h-4 w-4" />
641
+ <span>Brand Name</span>
642
+ </Label>
643
+ <Input
644
+ value={brandName}
645
+ onChange={(e) => setBrandName(e.target.value)}
646
+ placeholder="Enter your brand name"
647
+ className="bg-slate-800 border-slate-600 text-white placeholder:text-slate-400"
648
+ />
649
+ </div>
650
+
651
+ <div className="space-y-2">
652
+ <Label className="text-white flex items-center space-x-2">
653
+ <Layers className="h-4 w-4" />
654
+ <span>Industry</span>
655
+ </Label>
656
+ <Select value={industry} onValueChange={setIndustry}>
657
+ <SelectTrigger className="bg-slate-800 border-slate-600 text-white">
658
+ <SelectValue placeholder="Select your industry" />
659
+ </SelectTrigger>
660
+ <SelectContent className="bg-slate-800 border-slate-600">
661
+ <SelectItem value="Technology">💻 Technology</SelectItem>
662
+ <SelectItem value="Health & Wellness">🏥 Health & Wellness</SelectItem>
663
+ <SelectItem value="Finance">💰 Finance</SelectItem>
664
+ <SelectItem value="Fashion">👗 Fashion</SelectItem>
665
+ <SelectItem value="Food & Beverage">🍕 Food & Beverage</SelectItem>
666
+ <SelectItem value="Real Estate">🏠 Real Estate</SelectItem>
667
+ <SelectItem value="Education">📚 Education</SelectItem>
668
+ <SelectItem value="Entertainment">🎬 Entertainment</SelectItem>
669
+ <SelectItem value="Sports & Fitness">⚽ Sports & Fitness</SelectItem>
670
+ <SelectItem value="Automotive">🚗 Automotive</SelectItem>
671
+ </SelectContent>
672
+ </Select>
673
+ </div>
674
+
675
+ <div className="space-y-2">
676
+ <Label className="text-white flex items-center space-x-2">
677
+ <Target className="h-4 w-4" />
678
+ <span>Target Audience</span>
679
+ </Label>
680
+ <Select value={targetAudience} onValueChange={setTargetAudience}>
681
+ <SelectTrigger className="bg-slate-800 border-slate-600 text-white">
682
+ <SelectValue placeholder="Who is your target audience?" />
683
+ </SelectTrigger>
684
+ <SelectContent className="bg-slate-800 border-slate-600">
685
+ <SelectItem value="General Consumers">👥 General Consumers</SelectItem>
686
+ <SelectItem value="Small Businesses">🏪 Small Businesses</SelectItem>
687
+ <SelectItem value="Corporate Clients">🏢 Corporate Clients</SelectItem>
688
+ <SelectItem value="Young Adults">🎯 Young Adults (18-35)</SelectItem>
689
+ <SelectItem value="Luxury Market">💎 Luxury Market</SelectItem>
690
+ <SelectItem value="Tech Enthusiasts">⚡ Tech Enthusiasts</SelectItem>
691
+ <SelectItem value="Eco-Conscious">🌱 Eco-Conscious Consumers</SelectItem>
692
+ </SelectContent>
693
+ </Select>
694
+ </div>
695
+
696
+ <div className="space-y-2">
697
+ <Label className="text-white flex items-center space-x-2">
698
+ <Lightbulb className="h-4 w-4" />
699
+ <span>Key Elements</span>
700
+ </Label>
701
+ <Textarea
702
+ value={keyElements}
703
+ onChange={(e) => setKeyElements(e.target.value)}
704
+ placeholder="Describe elements you want in your logo (e.g., mountain, star, abstract shape)"
705
+ className="bg-slate-800 border-slate-600 text-white placeholder:text-slate-400 min-h-[80px]"
706
+ />
707
+ </div>
708
+ </TabsContent>
709
+
710
+ <TabsContent value="advanced" className="space-y-4 mt-6">
711
+ <div className="space-y-2">
712
+ <Label className="text-white">Design Style</Label>
713
+ <Select value={style} onValueChange={setStyle}>
714
+ <SelectTrigger className="bg-slate-800 border-slate-600 text-white">
715
+ <SelectValue placeholder="Choose a design style" />
716
+ </SelectTrigger>
717
+ <SelectContent className="bg-slate-800 border-slate-600">
718
+ <SelectItem value="Minimalist">✨ Minimalist</SelectItem>
719
+ <SelectItem value="Modern">🔥 Modern</SelectItem>
720
+ <SelectItem value="Classic">👑 Classic</SelectItem>
721
+ <SelectItem value="Vintage">📜 Vintage</SelectItem>
722
+ <SelectItem value="Bold">💪 Bold</SelectItem>
723
+ <SelectItem value="Elegant">💫 Elegant</SelectItem>
724
+ <SelectItem value="Playful">🎨 Playful</SelectItem>
725
+ <SelectItem value="Geometric">📐 Geometric</SelectItem>
726
+ <SelectItem value="Abstract">🌀 Abstract</SelectItem>
727
+ </SelectContent>
728
+ </Select>
729
+ </div>
730
+
731
+ <div className="space-y-2">
732
+ <Label className="text-white">Model Selection</Label>
733
+ <Select value={selectedModel} onValueChange={setSelectedModel}>
734
+ <SelectTrigger className="bg-slate-800 border-slate-600 text-white">
735
+ <SelectValue placeholder="Select a model" />
736
+ </SelectTrigger>
737
+ <SelectContent className="bg-slate-800 border-slate-600">
738
+ {availableModels.map((model) => (
739
+ <SelectItem key={model.id} value={model.id}>
740
+ {t(model.nameKey)}
741
+ <br />
742
+ <p className="text-xs text-slate-400">{t(model.description)}</p>
743
+ </SelectItem>
744
+ ))}
745
+ </SelectContent>
746
+ </Select>
747
+ </div>
748
+
749
+ <div className="space-y-3">
750
+ <Label className="text-white">Color Palette</Label>
751
+ <div className="flex items-center space-x-3">
752
+ <input
753
+ type="color"
754
+ value={colors}
755
+ onChange={(e) => setColors(e.target.value)}
756
+ className="w-12 h-10 rounded border-2 border-slate-600 bg-slate-800"
757
+ />
758
+ <Input
759
+ value={colors}
760
+ onChange={(e) => setColors(e.target.value)}
761
+ placeholder="#6366f1"
762
+ className="bg-slate-800 border-slate-600 text-white"
763
+ />
764
+ </div>
765
+ <div className="grid grid-cols-3 gap-2">
766
+ {colorPalettes.map((palette, index) => (
767
+ <Tooltip key={index}>
768
+ <TooltipTrigger asChild>
769
+ <button
770
+ onClick={() => setColors(palette.colors[0])}
771
+ className="flex items-center space-x-1 p-2 rounded bg-slate-800 hover:bg-slate-700 transition-colors"
772
+ >
773
+ {palette.colors.map((color, i) => (
774
+ <div
775
+ key={i}
776
+ className="w-4 h-4 rounded-full border border-slate-600"
777
+ style={{ backgroundColor: color }}
778
+ />
779
+ ))}
780
+ </button>
781
+ </TooltipTrigger>
782
+ <TooltipContent>
783
+ <p>{palette.name}</p>
784
+ </TooltipContent>
785
+ </Tooltip>
786
+ ))}
787
+ </div>
788
+ </div>
789
+
790
+ <div className="space-y-3">
791
+ <Label className="text-white flex items-center justify-between">
792
+ <span>Design Complexity</span>
793
+ <span className="text-sm text-slate-400">{logoComplexity[0]}%</span>
794
+ </Label>
795
+ <Slider
796
+ value={logoComplexity}
797
+ onValueChange={setLogoComplexity}
798
+ max={100}
799
+ step={10}
800
+ className="w-full"
801
+ />
802
+ <div className="flex justify-between text-xs text-slate-400">
803
+ <span>Minimal</span>
804
+ <span>Balanced</span>
805
+ <span>Detailed</span>
806
+ </div>
807
+ </div>
808
+
809
+ <div className="space-y-2">
810
+ <Label className="text-white">Logo Orientation</Label>
811
+ <Select value={logoOrientation} onValueChange={setLogoOrientation}>
812
+ <SelectTrigger className="bg-slate-800 border-slate-600 text-white">
813
+ <SelectValue />
814
+ </SelectTrigger>
815
+ <SelectContent className="bg-slate-800 border-slate-600">
816
+ <SelectItem value="square">⬜ Square</SelectItem>
817
+ <SelectItem value="horizontal">➖ Horizontal</SelectItem>
818
+ <SelectItem value="vertical">📏 Vertical</SelectItem>
819
+ </SelectContent>
820
+ </Select>
821
+ </div>
822
+
823
+ <div className="space-y-2">
824
+ <Label className="text-white">Text in Logo (Optional)</Label>
825
+ <Input
826
+ value={textInLogo}
827
+ onChange={(e) => setTextInLogo(e.target.value)}
828
+ placeholder="Enter text to include in logo"
829
+ className="bg-slate-800 border-slate-600 text-white placeholder:text-slate-400"
830
+ />
831
+ </div>
832
+
833
+ <div className="space-y-2">
834
+ <Label className="text-white">Avoid These Elements</Label>
835
+ <Textarea
836
+ value={negativeConstraints}
837
+ onChange={(e) => setNegativeConstraints(e.target.value)}
838
+ placeholder="What should be avoided in the design? (e.g., too much text, dark colors)"
839
+ className="bg-slate-800 border-slate-600 text-white placeholder:text-slate-400"
840
+ />
841
+ </div>
842
+ </TabsContent>
843
+ </Tabs>
844
+
845
+ {suggestions.length > 0 && (
846
+ <Card className="bg-blue-950/30 border-blue-800/50">
847
+ <CardContent className="p-4">
848
+ <div className="flex items-center space-x-2 text-blue-400 mb-3">
849
+ <Lightbulb className="h-4 w-4" />
850
+ <span className="font-medium">Smart Suggestions</span>
851
+ </div>
852
+ <div className="space-y-2">
853
+ {suggestions.map((suggestion, index) => (
854
+ <button
855
+ key={index}
856
+ onClick={suggestion.action}
857
+ className="flex items-center justify-between w-full p-2 text-left text-sm bg-blue-900/30 hover:bg-blue-900/50 rounded border border-blue-800/30 text-blue-100 transition-colors"
858
+ >
859
+ <span>{suggestion.text}</span>
860
+ <ChevronRight className="h-4 w-4" />
861
+ </button>
862
+ ))}
863
+ </div>
864
+ </CardContent>
865
+ </Card>
866
+ )}
867
+
868
+ <div className="flex space-x-3 pt-4">
869
+ <Button
870
+ onClick={handleGenerateLogo}
871
+ disabled={loadingGeneration || isLoadingUserData}
872
+ className="flex-1 bg-gradient-to-r from-purple-600 to-pink-600 hover:from-purple-700 hover:to-pink-700 text-white font-semibold py-3 rounded-lg transition-all duration-200 transform hover:scale-105 disabled:opacity-50 disabled:cursor-not-allowed"
873
+ >
874
+ {loadingGeneration ? (
875
+ <>
876
+ <RefreshCw className="mr-2 h-4 w-4 animate-spin" />
877
+ Creating Magic...
878
+ </>
879
+ ) : (
880
+ <>
881
+ <Sparkles className="mr-2 h-4 w-4" />
882
+ Generate Logo
883
+ </>
884
+ )}
885
+ </Button>
886
+
887
+ <Button
888
+ variant="outline"
889
+ onClick={handleResetForm}
890
+ className="px-4 border-slate-600 text-slate-300 hover:bg-slate-800"
891
+ >
892
+ <RefreshCw className="h-4 w-4" />
893
+ </Button>
894
+ </div>
895
+
896
+ {errorGeneration && (
897
+ <Alert className="border-red-800 bg-red-950/30">
898
+ <AlertDescription className="text-red-200">
899
+ {errorGeneration}
900
+ </AlertDescription>
901
+ </Alert>
902
+ )}
903
+ </CardContent>
904
+ </Card>
905
+ </div>
906
+
907
+ {/* Results Section */}
908
+ <div className="xl:col-span-3 space-y-6">
909
+ {loadingGeneration && (
910
+ <Card className="bg-slate-900/50 border-slate-700/50 backdrop-blur-sm">
911
+ <CardContent className="p-8">
912
+ <div className="text-center space-y-4">
913
+ <div className="relative mx-auto w-16 h-16">
914
+ <div className="absolute inset-0 rounded-full border-4 border-purple-600/30"></div>
915
+ <div className="absolute inset-0 rounded-full border-4 border-purple-600 border-t-transparent animate-spin"></div>
916
+ <Sparkles className="absolute inset-0 m-auto h-6 w-6 text-purple-400 animate-pulse" />
917
+ </div>
918
+ <div className="space-y-2">
919
+ <h3 className="text-lg font-semibold text-white">Creating Your Logo</h3>
920
+ <p className="text-slate-400">Our AI is crafting unique designs tailored to your brand...</p>
921
+ </div>
922
+ <div className="grid grid-cols-2 gap-4 mt-6">
923
+ {[1, 2, 3, 4].map((i) => (
924
+ <Skeleton key={i} className="aspect-square rounded-lg bg-slate-800" />
925
+ ))}
926
+ </div>
927
+ </div>
928
+ </CardContent>
929
+ </Card>
930
+ )}
931
+
932
+ {generatedImageUrls && !loadingGeneration && (
933
+ <Card className="bg-slate-900/50 border-slate-700/50 backdrop-blur-sm">
934
+ <CardHeader>
935
+ <div className="flex items-center justify-between">
936
+ <CardTitle className="text-xl text-white flex items-center space-x-2">
937
+ <ImageIcon className="h-5 w-5 text-green-400" />
938
+ <span>Your Logo Variations</span>
939
+ </CardTitle>
940
+ <Badge className="bg-green-900/50 text-green-300 border-green-700">
941
+ {generatedImageUrls.length} Designs Created
942
+ </Badge>
943
+ </div>
944
+ </CardHeader>
945
+
946
+ <CardContent className="space-y-6">
947
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
948
+ {generatedImageUrls.map((imageUrl, index) => (
949
+ <div key={index} className="group relative">
950
+ <div className="relative overflow-hidden rounded-lg bg-slate-800 border border-slate-700 hover:border-purple-500 transition-all duration-300">
951
+ <img
952
+ src={imageUrl}
953
+ alt={`Logo variation ${index + 1}`}
954
+ className="w-full aspect-square object-cover transition-transform duration-300 group-hover:scale-105"
955
+ />
956
+
957
+ <div className="absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-center justify-center">
958
+ <div className="flex space-x-3">
959
+ <Button
960
+ size="sm"
961
+ variant="secondary"
962
+ onClick={() => toggleFavorite(index)}
963
+ className={`${favoriteLogos.has(index) ? 'bg-red-600 hover:bg-red-700' : 'bg-slate-700 hover:bg-slate-600'}`}
964
+ >
965
+ <Heart className={`h-4 w-4 ${favoriteLogos.has(index) ? 'fill-current' : ''}`} />
966
+ </Button>
967
+
968
+ <Button
969
+ size="sm"
970
+ onClick={() => handleDownloadImage(imageUrl)}
971
+ disabled={isDownloading}
972
+ className="bg-purple-600 hover:bg-purple-700"
973
+ >
974
+ <Download className="h-4 w-4" />
975
+ </Button>
976
+ </div>
977
+ </div>
978
+
979
+ <div className="absolute top-3 left-3">
980
+ <Badge className="bg-black/70 text-white border-none">
981
+ {index === 0 ? 'Primary' :
982
+ index === 1 ? 'Icon Only' :
983
+ index === 2 ? 'Horizontal' : 'Monochrome'}
984
+ </Badge>
985
+ </div>
986
+
987
+ {favoriteLogos.has(index) && (
988
+ <div className="absolute top-3 right-3">
989
+ <Star className="h-5 w-5 text-yellow-400 fill-current" />
990
+ </div>
991
+ )}
992
+ </div>
993
+
994
+ <div className="mt-3 space-y-2">
995
+ <div className="flex items-center justify-between">
996
+ <span className="text-sm font-medium text-white">
997
+ Variation {index + 1}
998
+ </span>
999
+ <div className="flex space-x-2">
1000
+ <Button
1001
+ size="sm"
1002
+ variant="outline"
1003
+ onClick={() => handleDownloadImage(imageUrl, 'png')}
1004
+ className="text-xs border-slate-600 text-slate-300 hover:bg-slate-800"
1005
+ >
1006
+ PNG
1007
+ </Button>
1008
+ <Button
1009
+ size="sm"
1010
+ variant="outline"
1011
+ onClick={() => handleDownloadImage(imageUrl, 'svg')}
1012
+ className="text-xs border-slate-600 text-slate-300 hover:bg-slate-800"
1013
+ >
1014
+ SVG
1015
+ </Button>
1016
+ </div>
1017
+ </div>
1018
+ </div>
1019
+ </div>
1020
+ ))}
1021
+ </div>
1022
+
1023
+ <div className="flex flex-wrap gap-3 pt-4 border-t border-slate-700">
1024
+ <Button
1025
+ onClick={() => generatedImageUrls.forEach(url => handleDownloadImage(url))}
1026
+ disabled={isDownloading}
1027
+ className="bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-700 hover:to-purple-700"
1028
+ >
1029
+ <Download className="mr-2 h-4 w-4" />
1030
+ Download All
1031
+ </Button>
1032
+
1033
+ <Button
1034
+ variant="outline"
1035
+ onClick={() => setGeneratedImageUrls(null)}
1036
+ className="border-slate-600 text-slate-300 hover:bg-slate-800"
1037
+ >
1038
+ <RefreshCw className="mr-2 h-4 w-4" />
1039
+ Clear Results
1040
+ </Button>
1041
+
1042
+ <Button
1043
+ variant="outline"
1044
+ onClick={handleGenerateLogo}
1045
+ disabled={loadingGeneration}
1046
+ className="border-slate-600 text-slate-300 hover:bg-slate-800"
1047
+ >
1048
+ <Wand2 className="mr-2 h-4 w-4" />
1049
+ Generate More
1050
+ </Button>
1051
+ </div>
1052
+ </CardContent>
1053
+ </Card>
1054
+ )}
1055
+
1056
+ {!generatedImageUrls && !loadingGeneration && (
1057
+ <Card className="bg-slate-900/50 border-slate-700/50 backdrop-blur-sm">
1058
+ <CardContent className="p-12 text-center">
1059
+ <div className="space-y-6">
1060
+ <div className="relative mx-auto w-24 h-24">
1061
+ <div className="absolute inset-0 rounded-full bg-gradient-to-r from-purple-600 to-pink-600 opacity-20"></div>
1062
+ <Palette className="absolute inset-0 m-auto h-12 w-12 text-purple-400" />
1063
+ </div>
1064
+
1065
+ <div className="space-y-3">
1066
+ <h3 className="text-2xl font-bold text-white">Ready to Create Amazing Logos?</h3>
1067
+ <p className="text-slate-400 max-w-md mx-auto">
1068
+ Fill out the design brief on the left and click "Generate Logo" to create professional logos powered by AI.
1069
+ </p>
1070
+ </div>
1071
+
1072
+ <div className="grid grid-cols-1 md:grid-cols-3 gap-4 mt-8 text-sm">
1073
+ <div className="p-4 bg-slate-800/50 rounded-lg border border-slate-700">
1074
+ <Zap className="h-6 w-6 text-yellow-400 mx-auto mb-2" />
1075
+ <div className="font-medium text-white mb-1">Lightning Fast</div>
1076
+ <div className="text-slate-400">Get results in seconds</div>
1077
+ </div>
1078
+
1079
+ <div className="p-4 bg-slate-800/50 rounded-lg border border-slate-700">
1080
+ <Star className="h-6 w-6 text-purple-400 mx-auto mb-2" />
1081
+ <div className="font-medium text-white mb-1">Professional Quality</div>
1082
+ <div className="text-slate-400">Industry-grade designs</div>
1083
+ </div>
1084
+
1085
+ <div className="p-4 bg-slate-800/50 rounded-lg border border-slate-700">
1086
+ <Grid3X3 className="h-6 w-6 text-green-400 mx-auto mb-2" />
1087
+ <div className="font-medium text-white mb-1">Multiple Formats</div>
1088
+ <div className="text-slate-400">PNG, SVG, and more</div>
1089
+ </div>
1090
+ </div>
1091
+ </div>
1092
+ </CardContent>
1093
+ </Card>
1094
+ )}
1095
+ </div>
1096
+ </div>
1097
+
1098
+ <Card className="bg-slate-900/30 border-purple-500/20 backdrop-blur-sm">
1099
+ <CardContent className="p-6">
1100
+ <div className="flex items-start space-x-4">
1101
+ <Lightbulb className="h-6 w-6 text-purple-400 mt-1 flex-shrink-0" />
1102
+ <div className="space-y-2">
1103
+ <h4 className="font-semibold text-white">Pro Tips for Better Logos</h4>
1104
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4 text-sm text-slate-300">
1105
+ <div>
1106
+ <strong className="text-purple-400">Be Specific:</strong> The more details you provide about your brand and industry, the better your results will be.
1107
+ </div>
1108
+ <div>
1109
+ <strong className="text-purple-400">Try Different Styles:</strong> Experiment with various design styles to find what resonates with your brand.
1110
+ </div>
1111
+ <div>
1112
+ <strong className="text-purple-400">Color Psychology:</strong> Choose colors that align with your brand personality and target audience.
1113
+ </div>
1114
+ <div>
1115
+ <strong className="text-purple-400">Keep It Simple:</strong> The best logos work at both large and small sizes - simplicity is key.
1116
+ </div>
1117
+ </div>
1118
+ </div>
1119
+ </div>
1120
+ </CardContent>
1121
+ </Card>
1122
+ </div>
1123
+ </div>
1124
+ </TooltipProvider>
1125
+ );
1126
+ };
1127
+
1128
+ export default LogoDesigner;
MyGeneratedLogo.tsx ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useEffect } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { useSession } from '@supabase/auth-helpers-react';
4
+ import { supabase } from '@/integrations/supabase/client';
5
+ import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card'; // Adjust import based on your UI library
6
+ import { Button } from '@/components/ui/button'; // Adjust import based on your UI library
7
+ import { Download } from 'lucide-react'; // Icon for download button, adjust as needed
8
+ import { Skeleton } from '@/components/ui/skeleton'; // Adjust import based on your UI library
9
+
10
+ interface GeneratedImage {
11
+ id: string;
12
+ created_at: string;
13
+ user_id: string | null;
14
+ prompt: string;
15
+ image_url: string;
16
+ }
17
+
18
+ interface MyGeneratedLogoProps {
19
+ userId?: string;
20
+ }
21
+
22
+ const MyGeneratedLogo: React.FC<MyGeneratedLogoProps> = ({ userId }) => {
23
+ const { t } = useTranslation();
24
+ const session = useSession();
25
+ const [images, setImages] = useState<GeneratedImage[]>([]);
26
+ const [loading, setLoading] = useState(true);
27
+ const [error, setError] = useState<string | null>(null);
28
+ const [isDownloading, setIsDownloading] = useState(false);
29
+
30
+ useEffect(() => {
31
+ const fetchImages = async () => {
32
+ setLoading(true);
33
+ setError(null);
34
+
35
+ try {
36
+ const { data, error } = await supabase
37
+ .from('generated_logos')
38
+ .select('*')
39
+ .eq('user_id', userId ?? '')
40
+ .order('created_at', { ascending: false });
41
+
42
+ if (error) {
43
+ console.error('Error fetching images:', error);
44
+ setError(error.message);
45
+ } else {
46
+ setImages(data || []);
47
+ }
48
+ } catch (err: any) {
49
+ console.error('Unexpected error fetching images:', err);
50
+ setError(err.message);
51
+ } finally {
52
+ setLoading(false);
53
+ }
54
+ };
55
+
56
+ if (userId) {
57
+ fetchImages();
58
+ }
59
+ }, [userId]);
60
+
61
+ const handleDownloadImage = async (imageUrl: string) => {
62
+ setIsDownloading(true);
63
+ try {
64
+ const response = await fetch(imageUrl);
65
+ const blob = await response.blob();
66
+ const url = window.URL.createObjectURL(blob);
67
+ const link = document.createElement('a');
68
+ link.href = url;
69
+ link.download = `generated-image-${Date.now()}.png`;
70
+ document.body.appendChild(link);
71
+ link.click();
72
+ document.body.removeChild(link);
73
+ window.URL.revokeObjectURL(url);
74
+ } catch (err) {
75
+ console.error('Error downloading image:', err);
76
+ } finally {
77
+ setIsDownloading(false);
78
+ }
79
+ };
80
+
81
+ return (
82
+ <Card className="bg-zinc-900 border-zinc-800 text-slate-100 shadow-lg mt-8">
83
+ <CardHeader className="items-center text-center">
84
+ <CardTitle className="text-3xl text-purple-400">{t('My Generated Logos')}</CardTitle>
85
+ <p className="text-slate-400 max-w-2xl mx-auto">
86
+ {t('View and download your previously generated logos.')}
87
+ </p>
88
+ </CardHeader>
89
+ <CardContent className="space-y-6">
90
+ {error ? (
91
+ <div className="text-red-400 text-center">{error}</div>
92
+ ) : loading ? (
93
+ <div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4">
94
+ {[...Array(6)].map((_, i) => (
95
+ <Skeleton key={i} className="w-full h-48 bg-slate-700 rounded-md" />
96
+ ))}
97
+ </div>
98
+ ) : images.length === 0 ? (
99
+ <div className="text-slate-400 text-center">{t('No images created yet.')}</div>
100
+ ) : (
101
+ <div className="columns-1 sm:columns-3 md:columns-3 lg:columns-3 xl:columns-3 gap-1 space-y-1">
102
+ {images.map((image) => (
103
+ <div key={image.id} className="relative group overflow-hidden rounded-md border border-slate-600">
104
+ <img
105
+ src={image.image_url}
106
+ alt={`Generated image for prompt: ${image.created_at}`}
107
+ className="w-full h-full max-w-[200px] max-h-[200px] object-cover transition-transform duration-300 group-hover:scale-105"
108
+ onContextMenu={(e) => e.preventDefault()}
109
+ />
110
+ <div className="absolute inset-0 bg-black bg-opacity-50 flex flex-col items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity duration-300">
111
+ <Button
112
+ onClick={() => handleDownloadImage(image.image_url)}
113
+ size="icon"
114
+ className="bg-white text-gray-800 hover:bg-gray-200"
115
+ disabled={isDownloading}
116
+ >
117
+ <Download className="h-5 w-5" />
118
+ </Button>
119
+ </div>
120
+ </div>
121
+ ))}
122
+ </div>
123
+ )}
124
+ </CardContent>
125
+ </Card>
126
+ );
127
+ };
128
+
129
+ export default MyGeneratedLogo;
Untitled-1.ai ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:747bb2f359c63b1d84868a597b8620ac9539a08770a57dade7cf297be7bc3fb2
3
+ size 426396
Untitled-2.ai ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cd8dbed6f59d03987aacf454649615f5a9c7397208f1c4fbf3b78248b19af2c7
3
+ size 231613
Untitled-3.ai ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a71d1fc082819f79671c3a5008812cf839a9daaddfca0da9965896218ca44899
3
+ size 230925
Untitled-65e43.ai ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c5d8909877daa60ee413280938102d822fa66911d16cf547f3913ea9ceff7b79
3
+ size 236872
Untitled-7689.ai ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a0528074df60218f82113f72368b637bc0b1c9f75106a55f7d5d175a4996ec33
3
+ size 258677
Untitled-dsa.ai ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb72e7fda84ccd3e6f252655bd4558af844f912e6ea0b35ea92fea47c61cd0d6
3
+ size 235103
dfghjk5.ai ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:29154c98bd1929095d9fa71c9fd5685c2ac6d16dc679a7a92c619f53a1165354
3
+ size 236100
fdghjkl4.ai ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2c8dda4ba280d1eb4d8153e13d5d269a72b032989040c278970bea916d4b6cfb
3
+ size 232966
screen1.png ADDED

Git LFS Details

  • SHA256: 49358059d8c1acb36d8d3f1692c9a42c2324d9b95bfad264e5e3aed52fb86adf
  • Pointer size: 132 Bytes
  • Size of remote file: 1.49 MB
screen2.png ADDED

Git LFS Details

  • SHA256: 8ddaa830df58de036d3b224f78269bb1664380c87701ba261e72bac6e9c422fc
  • Pointer size: 132 Bytes
  • Size of remote file: 1.33 MB
screen3.png ADDED

Git LFS Details

  • SHA256: eeae304595aa0970931b522c5006e28c5f1fe1c1ebddcfa6b85d6c6ae2a4c496
  • Pointer size: 132 Bytes
  • Size of remote file: 1.22 MB
screen4.png ADDED

Git LFS Details

  • SHA256: 2b0327f47c6d6d0f7479512f13c4bb56a533e1dedbca271a8fefd64fdadc2fc2
  • Pointer size: 131 Bytes
  • Size of remote file: 420 kB
screen5.png ADDED

Git LFS Details

  • SHA256: 09a017a7474ac946e12cf13c025e64b874f9eca66d8caf5d5502d38bf6c61d9b
  • Pointer size: 132 Bytes
  • Size of remote file: 1.22 MB
screen6.png ADDED

Git LFS Details

  • SHA256: 9374fe9c21e14d20f2882e86ba72168b878a88ec138d2248d423cdb1be5a1c31
  • Pointer size: 131 Bytes
  • Size of remote file: 355 kB
screen7.png ADDED

Git LFS Details

  • SHA256: 03fc847bdc71de46649e7fc51c764afe89346eb97436a580ffbe8aa97bc55099
  • Pointer size: 131 Bytes
  • Size of remote file: 950 kB
screen8.png ADDED

Git LFS Details

  • SHA256: b8293facad8874a92ba0cd11f2fcad06c2273515f299a1e657a53d6458e633c9
  • Pointer size: 132 Bytes
  • Size of remote file: 1.88 MB
yguhijk3.ai ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:195bb15e2c932c9e38993505e8033130f5b4aff18c39bc54109aa05f70688570
3
+ size 223631