Compare commits
3 Commits
6e9f6e899f
...
0a7b435398
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0a7b435398 | ||
7e31629de6 | |||
b4ec903ce0 |
@ -3,6 +3,7 @@
|
||||
import { Entity } from '@/app/lib/definitions';
|
||||
import { getCsrfToken, getSlug } from '@/app/lib/utils';
|
||||
|
||||
|
||||
export interface Api<T extends Entity> {
|
||||
getAll(serializable: Serializable<T>, callback: (objets: T[]) => void): void;
|
||||
get(serializable: Serializable<T>, id: string, callback: (object: T) => void): void;
|
||||
@ -30,6 +31,18 @@ export class AbstractApi<T extends Entity> implements Api<T> {
|
||||
});
|
||||
}
|
||||
|
||||
getAllPdf(serializable: Serializable<T>, callback: () => void): void {
|
||||
fetch(`/api/${getSlug()}/${serializable.apiPath()}`, {
|
||||
headers: {
|
||||
'Accept': 'application/pdf',
|
||||
}
|
||||
}).then(res => res.blob())
|
||||
.then(blob => {
|
||||
var file = window.URL.createObjectURL(blob);
|
||||
window.location.assign(file);
|
||||
});
|
||||
}
|
||||
|
||||
get(serializable: Serializable<T>, id: (string | undefined), callback: (object: T) => void): void {
|
||||
const endpoint = id ? `/api/${getSlug()}/${serializable.apiPath()}/${id}` : `/api/${getSlug()}/${serializable.apiPath()}`;
|
||||
fetch(endpoint)
|
||||
|
@ -5,7 +5,7 @@ import clsx from "clsx";
|
||||
type ButtonColor = 'primary' | 'blue' | 'green' | 'red' | 'yellow' | 'gray';
|
||||
|
||||
export function classNames(type: ButtonColor) {
|
||||
return (clsx("text-white py-1 px-2 mx-1 rounded disabled:opacity-50 disabled:cursor-not-allowed", {
|
||||
return (clsx("text-white py-1 px-2 m-2 rounded disabled:opacity-50 disabled:cursor-not-allowed", {
|
||||
'bg-blue-400 hover:bg-blue-600': type === 'primary' || type === 'blue',
|
||||
'bg-green-500 hover:bg-green-600': type === 'green',
|
||||
'bg-red-500 hover:bg-red-600': type === 'red',
|
||||
|
@ -10,6 +10,7 @@ import { draggable, dropTargetForElements } from '@atlaskit/pragmatic-drag-and-d
|
||||
import { LinkIcon, TrashIcon } from "@heroicons/react/24/outline";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useState } from "react";
|
||||
import { classNames } from "../components/button";
|
||||
|
||||
function InvitationCard({ invitation, allGuests, onGuestAdded, onDestroy }: {
|
||||
invitation: Invitation,
|
||||
@ -144,6 +145,12 @@ export default function InvitationsBoard({ guests, invitations: originalInvitati
|
||||
});
|
||||
}
|
||||
|
||||
function handleDownloadQrCodes() {
|
||||
api.getAllPdf(serializer, () => {
|
||||
console.log("QR codes downloaded");
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex h-screen">
|
||||
{/* Left Column: Guests */}
|
||||
@ -164,11 +171,18 @@ export default function InvitationsBoard({ guests, invitations: originalInvitati
|
||||
|
||||
<button
|
||||
onClick={handleCreateInvitation}
|
||||
className="mb-4 px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"
|
||||
className={classNames('primary')}
|
||||
>
|
||||
Create New Invitation
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={handleDownloadQrCodes}
|
||||
className={classNames('primary')}
|
||||
>
|
||||
Download QR codes
|
||||
</button>
|
||||
|
||||
|
||||
<div className="grid grid-cols-4 gap-6">
|
||||
|
||||
|
36
pnpm-lock.yaml
generated
36
pnpm-lock.yaml
generated
@ -40,10 +40,10 @@ importers:
|
||||
version: 3.2.6
|
||||
next:
|
||||
specifier: 15.3.4
|
||||
version: 15.3.4(@playwright/test@1.53.1)(react-dom@19.0.0-rc-f38c22b244-20240704(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704)
|
||||
version: 15.3.4(@playwright/test@1.53.2)(react-dom@19.0.0-rc-f38c22b244-20240704(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704)
|
||||
next-auth:
|
||||
specifier: 5.0.0-beta.29
|
||||
version: 5.0.0-beta.29(next@15.3.4(@playwright/test@1.53.1)(react-dom@19.0.0-rc-f38c22b244-20240704(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704)
|
||||
version: 5.0.0-beta.29(next@15.3.4(@playwright/test@1.53.2)(react-dom@19.0.0-rc-f38c22b244-20240704(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704)
|
||||
postcss:
|
||||
specifier: 8.5.6
|
||||
version: 8.5.6
|
||||
@ -77,7 +77,7 @@ importers:
|
||||
devDependencies:
|
||||
'@playwright/test':
|
||||
specifier: ^1.52.0
|
||||
version: 1.53.1
|
||||
version: 1.53.2
|
||||
'@types/bcrypt':
|
||||
specifier: ^5.0.2
|
||||
version: 5.0.2
|
||||
@ -337,8 +337,8 @@ packages:
|
||||
resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}
|
||||
engines: {node: '>=14'}
|
||||
|
||||
'@playwright/test@1.53.1':
|
||||
resolution: {integrity: sha512-Z4c23LHV0muZ8hfv4jw6HngPJkbbtZxTkxPNIg7cJcTc9C28N/p2q7g3JZS2SiKBBHJ3uM1dgDye66bB7LEk5w==}
|
||||
'@playwright/test@1.53.2':
|
||||
resolution: {integrity: sha512-tEB2U5z74ebBeyfGNZ3Jfg29AnW+5HlWhvHtb/Mqco9pFdZU1ZLNdVb2UtB5CvmiilNr2ZfVH/qMmAROG/XTzw==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
@ -1028,13 +1028,13 @@ packages:
|
||||
resolution: {integrity: sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==}
|
||||
engines: {node: '>= 6'}
|
||||
|
||||
playwright-core@1.53.1:
|
||||
resolution: {integrity: sha512-Z46Oq7tLAyT0lGoFx4DOuB1IA9D1TPj0QkYxpPVUnGDqHHvDpCftu1J2hM2PiWsNMoZh8+LQaarAWcDfPBc6zg==}
|
||||
playwright-core@1.53.2:
|
||||
resolution: {integrity: sha512-ox/OytMy+2w1jcYEYlOo1Hhp8hZkLCximMTUTMBXjGUA1KoFfiSZ+DU+3a739jsPY0yoKH2TFy9S2fsJas8yAw==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
playwright@1.53.1:
|
||||
resolution: {integrity: sha512-LJ13YLr/ocweuwxyGf1XNFWIU4M2zUSo149Qbp+A4cpwDjsxRPj7k6H25LBrEHiEwxvRbD8HdwvQmRMSvquhYw==}
|
||||
playwright@1.53.2:
|
||||
resolution: {integrity: sha512-6K/qQxVFuVQhRQhFsVZ9fGeatxirtrpPgxzBYWyZLEXJzqYwuL4fuNmfOfD5et1tJE4GScKyPNeLhZeRwuTU3A==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
@ -1565,9 +1565,9 @@ snapshots:
|
||||
'@pkgjs/parseargs@0.11.0':
|
||||
optional: true
|
||||
|
||||
'@playwright/test@1.53.1':
|
||||
'@playwright/test@1.53.2':
|
||||
dependencies:
|
||||
playwright: 1.53.1
|
||||
playwright: 1.53.2
|
||||
|
||||
'@popperjs/core@2.11.8': {}
|
||||
|
||||
@ -2160,13 +2160,13 @@ snapshots:
|
||||
|
||||
nanoid@3.3.11: {}
|
||||
|
||||
next-auth@5.0.0-beta.29(next@15.3.4(@playwright/test@1.53.1)(react-dom@19.0.0-rc-f38c22b244-20240704(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704):
|
||||
next-auth@5.0.0-beta.29(next@15.3.4(@playwright/test@1.53.2)(react-dom@19.0.0-rc-f38c22b244-20240704(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704):
|
||||
dependencies:
|
||||
'@auth/core': 0.40.0
|
||||
next: 15.3.4(@playwright/test@1.53.1)(react-dom@19.0.0-rc-f38c22b244-20240704(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704)
|
||||
next: 15.3.4(@playwright/test@1.53.2)(react-dom@19.0.0-rc-f38c22b244-20240704(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704)
|
||||
react: 19.0.0-rc-f38c22b244-20240704
|
||||
|
||||
next@15.3.4(@playwright/test@1.53.1)(react-dom@19.0.0-rc-f38c22b244-20240704(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704):
|
||||
next@15.3.4(@playwright/test@1.53.2)(react-dom@19.0.0-rc-f38c22b244-20240704(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704):
|
||||
dependencies:
|
||||
'@next/env': 15.3.4
|
||||
'@swc/counter': 0.1.3
|
||||
@ -2186,7 +2186,7 @@ snapshots:
|
||||
'@next/swc-linux-x64-musl': 15.3.4
|
||||
'@next/swc-win32-arm64-msvc': 15.3.4
|
||||
'@next/swc-win32-x64-msvc': 15.3.4
|
||||
'@playwright/test': 1.53.1
|
||||
'@playwright/test': 1.53.2
|
||||
sharp: 0.34.1
|
||||
transitivePeerDependencies:
|
||||
- '@babel/core'
|
||||
@ -2227,11 +2227,11 @@ snapshots:
|
||||
|
||||
pirates@4.0.6: {}
|
||||
|
||||
playwright-core@1.53.1: {}
|
||||
playwright-core@1.53.2: {}
|
||||
|
||||
playwright@1.53.1:
|
||||
playwright@1.53.2:
|
||||
dependencies:
|
||||
playwright-core: 1.53.1
|
||||
playwright-core: 1.53.2
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.2
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user