Generate invitations PDF asynchronously #311
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user