Compare commits
1 Commits
9e16a2f2dd
...
7e6d2d3674
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7e6d2d3674 |
@ -10,8 +10,6 @@ export interface Api<T extends Entity> {
|
|||||||
create(serializable: Serializable<T>, object: T, callback: (object: T) => void): void;
|
create(serializable: Serializable<T>, object: T, callback: (object: T) => void): void;
|
||||||
update(serializable: Serializable<T>, object: T, callback: () => void): void;
|
update(serializable: Serializable<T>, object: T, callback: () => void): void;
|
||||||
destroy(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> {
|
export interface Serializable<T> {
|
||||||
@ -100,14 +98,4 @@ export class AbstractApi<T extends Entity> implements Api<T> {
|
|||||||
}).then(callback)
|
}).then(callback)
|
||||||
.catch((error) => console.error(error));
|
.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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import { LinkIcon, TrashIcon } from "@heroicons/react/24/outline";
|
|||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { classNames } from "../components/button";
|
import { classNames } from "../components/button";
|
||||||
import { Toast } from "primereact/toast";
|
|
||||||
|
|
||||||
function InvitationCard({ invitation, allGuests, onGuestAdded, onDestroy }: {
|
function InvitationCard({ invitation, allGuests, onGuestAdded, onDestroy }: {
|
||||||
invitation: Invitation,
|
invitation: Invitation,
|
||||||
@ -118,7 +117,6 @@ export default function InvitationsBoard({ guests, invitations: originalInvitati
|
|||||||
guests: Array<Guest>,
|
guests: Array<Guest>,
|
||||||
invitations: Array<Invitation>
|
invitations: Array<Invitation>
|
||||||
}) {
|
}) {
|
||||||
const toast = useRef<Toast>(null);
|
|
||||||
const api = new AbstractApi<Invitation>();
|
const api = new AbstractApi<Invitation>();
|
||||||
const serializer = new InvitationSerializer();
|
const serializer = new InvitationSerializer();
|
||||||
|
|
||||||
@ -148,19 +146,14 @@ export default function InvitationsBoard({ guests, invitations: originalInvitati
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleDownloadQrCodes() {
|
function handleDownloadQrCodes() {
|
||||||
api.post(serializer, 'email', () => {
|
api.getAllPdf(serializer, () => {
|
||||||
toast.current?.show({
|
console.log("QR codes downloaded");
|
||||||
severity: 'success',
|
|
||||||
summary: 'Email scheduled',
|
|
||||||
detail: 'A document with the QR codes will be sent to the organizer\'s email.'
|
|
||||||
});
|
});
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-screen">
|
<div className="flex h-screen">
|
||||||
{/* Left Column: Guests */}
|
{/* Left Column: Guests */}
|
||||||
<Toast ref={toast} />
|
|
||||||
<div className="w-1/4 h-full overflow-auto border-r border-gray-300 p-4">
|
<div className="w-1/4 h-full overflow-auto border-r border-gray-300 p-4">
|
||||||
<h2 className="text-lg font-semibold mb-4">{unassignedGuests.length} guests without invitation</h2>
|
<h2 className="text-lg font-semibold mb-4">{unassignedGuests.length} guests without invitation</h2>
|
||||||
<div>
|
<div>
|
||||||
@ -187,7 +180,7 @@ export default function InvitationsBoard({ guests, invitations: originalInvitati
|
|||||||
onClick={handleDownloadQrCodes}
|
onClick={handleDownloadQrCodes}
|
||||||
className={classNames('primary')}
|
className={classNames('primary')}
|
||||||
>
|
>
|
||||||
Send QR codes via email
|
Download QR codes
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user