Generate invitations PDF asynchronously #311

Merged
bustikiller merged 2 commits from generate-invitations-doc-async into main 2025-07-08 17:49:17 +00:00
2 changed files with 16 additions and 4 deletions
Showing only changes of commit 8f5c038f9c - Show all commits

View File

@ -10,6 +10,8 @@ export interface Api<T extends Entity> {
create(serializable: Serializable<T>, object: T, callback: (object: T) => void): void;
update(serializable: Serializable<T>, object: T, callback: () => void): void;
destroy(serializable: Serializable<T>, object: T, callback: () => void): void;
post(serializable: Serializable<T>, path: string, callback: () => void): void;
}
export interface Serializable<T> {
@ -98,4 +100,14 @@ export class AbstractApi<T extends Entity> implements Api<T> {
}).then(callback)
.catch((error) => console.error(error));
}
post(serializable: Serializable<T>, path: string, callback: () => void): void {
fetch(`/api/${getSlug()}/${serializable.apiPath()}/${path}`, {
method: 'POST',
headers: {
'X-CSRF-TOKEN': getCsrfToken(),
}
}).then(callback)
.catch((error) => console.error(error));
}
}

View File

@ -146,9 +146,9 @@ export default function InvitationsBoard({ guests, invitations: originalInvitati
}
function handleDownloadQrCodes() {
api.getAllPdf(serializer, () => {
console.log("QR codes downloaded");
});
api.post(serializer, 'email', () => {
console.log("Email scheduled to be sent with QR codes.");
})
}
return (
@ -180,7 +180,7 @@ export default function InvitationsBoard({ guests, invitations: originalInvitati
onClick={handleDownloadQrCodes}
className={classNames('primary')}
>
Download QR codes
Send QR codes via email
</button>