diff --git a/admin-spa/src/routes/Settings/Notifications/EditTemplate.tsx b/admin-spa/src/routes/Settings/Notifications/EditTemplate.tsx index 8320211..953a4c2 100644 --- a/admin-spa/src/routes/Settings/Notifications/EditTemplate.tsx +++ b/admin-spa/src/routes/Settings/Notifications/EditTemplate.tsx @@ -9,6 +9,8 @@ import { Input } from '@/components/ui/input'; import { RichTextEditor } from '@/components/ui/rich-text-editor'; import { Label } from '@/components/ui/label'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; +import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog'; +import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'; import { ArrowLeft, Eye, Edit, RotateCcw, Plus, CheckCircle, Info, AlertCircle, Image } from 'lucide-react'; import { toast } from 'sonner'; import { __ } from '@/lib/i18n'; @@ -35,6 +37,12 @@ export default function EditTemplate() { const [variables, setVariables] = useState<{ [key: string]: string }>({}); const [activeTab, setActiveTab] = useState('editor'); const [codeMode, setCodeMode] = useState(false); + + // Button dialog state + const [buttonDialogOpen, setButtonDialogOpen] = useState(false); + const [buttonText, setButtonText] = useState('Click Here'); + const [buttonLink, setButtonLink] = useState('{order_url}'); + const [buttonType, setButtonType] = useState<'solid' | 'outline'>('solid'); // Fetch template const { data: template, isLoading, error } = useQuery({ @@ -143,9 +151,18 @@ ${content || '

Card Title

\n

Card content goes here...

'} toast.success(__('Card inserted')); }; + const openButtonDialog = () => { + setButtonText('Click Here'); + setButtonLink('{order_url}'); + setButtonType('solid'); + setButtonDialogOpen(true); + }; + const insertButton = () => { - const buttonHtml = `

Button Text

`; + const buttonClass = buttonType === 'solid' ? 'button' : 'button-outline'; + const buttonHtml = `

${buttonText}

`; setBody(body + buttonHtml + '\n'); + setButtonDialogOpen(false); toast.success(__('Button inserted')); }; @@ -240,6 +257,7 @@ ${content || '

Card Title

\n

Card content goes here...

'} h3 { font-size: 16px; margin-top: 0; margin-bottom: 8px; color: #333; } p { font-size: 16px; line-height: 1.6; color: #555; margin-bottom: 16px; } .button { display: inline-block; background: #7f54b3; color: #fff !important; padding: 14px 28px; border-radius: 6px; text-decoration: none; font-weight: 600; } + .button-outline { display: inline-block; background: transparent; color: #7f54b3 !important; padding: 12px 26px; border: 2px solid #7f54b3; border-radius: 6px; text-decoration: none; font-weight: 600; } .info-box { background: #f6f6f6; border-radius: 6px; padding: 20px; margin: 16px 0; } .footer { padding: 32px; text-align: center; color: #888; font-size: 13px; } @@ -428,7 +446,7 @@ ${content || '

Card Title

\n

Card content goes here...

'} type="button" variant="outline" size="sm" - onClick={insertButton} + onClick={openButtonDialog} className="h-7 text-xs gap-1" > @@ -464,6 +482,83 @@ ${content || '

Card Title

\n

Card content goes here...

'} )} + {/* Button Insert Dialog */} + + + + {__('Insert Button')} + + {__('Configure your call-to-action button. Use variables like {order_url} for dynamic links.')} + + + +
+ {/* Button Text */} +
+ + setButtonText(e.target.value)} + placeholder={__('e.g., View Order, Track Shipment')} + /> +
+ + {/* Button Link */} +
+ + setButtonLink(e.target.value)} + placeholder={__('e.g., {order_url}, {product_url}')} + /> +

+ {__('Use variables like {order_url} or enter a full URL')} +

+
+ + {/* Button Type */} +
+ + setButtonType(value)}> +
+ + +
+
+ + +
+
+
+
+ + + + + +
+
+ {/* Preview Tab */} {activeTab === 'preview' && (