Skip to content

Commit 9f2ab60

Browse files
committed
Fix Test button - use pdfData when templateUrl not available
1 parent ee8ea11 commit 9f2ab60

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

frontend/src/components/CertificateDesigner.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ export default function CertificateDesigner({ eventId, initialConfig, onClose, o
194194
};
195195

196196
const handleTestCertificate = async () => {
197-
if (!templateUrl || mapping.length === 0) {
197+
const template = templateUrl || pdfData;
198+
if (!template || mapping.length === 0) {
198199
toast.error('Please upload a template and place at least one field');
199200
return;
200201
}
@@ -204,7 +205,7 @@ export default function CertificateDesigner({ eventId, initialConfig, onClose, o
204205

205206
const response = await api.post(
206207
`/admin/events/${eventId}/certificates/test`,
207-
{ templateUrl, mapping },
208+
{ templateUrl: template, mapping },
208209
{ responseType: 'blob' }
209210
);
210211

@@ -243,9 +244,9 @@ export default function CertificateDesigner({ eventId, initialConfig, onClose, o
243244
</label>
244245
<button
245246
onClick={handleTestCertificate}
246-
disabled={!templateUrl || mapping.length === 0 || saving}
247+
disabled={(!templateUrl && !pdfData) || mapping.length === 0}
247248
className={`flex items-center gap-2 px-4 py-2 rounded-lg transition-colors ${
248-
templateUrl && mapping.length > 0 && !saving
249+
(templateUrl || pdfData) && mapping.length > 0
249250
? 'bg-blue-600 hover:bg-blue-500 text-white'
250251
: 'bg-gray-600 text-gray-400 cursor-not-allowed'
251252
}`}

0 commit comments

Comments
 (0)