Compare commits
1 Commits
369f498d5f
...
999c232c7a
Author | SHA1 | Date | |
---|---|---|---|
|
999c232c7a |
@ -1,26 +1,9 @@
|
||||
/* Copyright (C) 2024 Manuel Bustillo*/
|
||||
|
||||
'use client'
|
||||
|
||||
import { GlobalSummary as Summary } from '@/app/lib/definitions';
|
||||
import { getSlug } from '@/app/lib/utils';
|
||||
import GlobalSummary from '@/app/ui/dashboard/global-summary';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
export default function Page() {
|
||||
const [globalSummary, setGlobalSummary] = useState<Summary | undefined>(undefined);
|
||||
|
||||
function refreshSummary() {
|
||||
fetch(`/api/${getSlug()}/summary`)
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
setGlobalSummary(data);
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(refreshSummary, []);
|
||||
|
||||
return(
|
||||
globalSummary && <GlobalSummary summary={globalSummary} />
|
||||
<GlobalSummary />
|
||||
);
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
/* Copyright (C) 2024 Manuel Bustillo*/
|
||||
|
||||
import { AttendanceSummary } from "./group";
|
||||
import { Guest } from "./guest";
|
||||
|
||||
export interface Entity {
|
||||
@ -39,22 +38,3 @@ export type Captcha = {
|
||||
export type StructuredErrors = {
|
||||
[key: string]: string[] | string;
|
||||
};
|
||||
|
||||
export type GlobalSummary = {
|
||||
expenses: ExpenseSummary;
|
||||
guests: AttendanceSummary
|
||||
}
|
||||
|
||||
export type ExpenseSummary = {
|
||||
projected: ExpensePossibleSummary;
|
||||
confirmed: ExpensePossibleSummary;
|
||||
status: StatusSummary;
|
||||
}
|
||||
|
||||
export type ExpensePossibleSummary = {
|
||||
total: number;
|
||||
guests: number;
|
||||
}
|
||||
export type StatusSummary = {
|
||||
paid: number;
|
||||
}
|
@ -21,7 +21,7 @@ const colorClasses = (style: Style) => {
|
||||
}
|
||||
}
|
||||
|
||||
export function MainCard({ amount, title, subtitle, style, iconName }:
|
||||
export async function MainCard({ amount, title, subtitle, style, iconName }:
|
||||
{
|
||||
amount: string,
|
||||
title: string,
|
||||
@ -42,7 +42,7 @@ export function MainCard({ amount, title, subtitle, style, iconName }:
|
||||
);
|
||||
}
|
||||
|
||||
export function SecondaryCard({ amount, title, iconName, style }: { amount: string, title: string, iconName: keyof typeof HeroIcon, style: Style }) {
|
||||
export async function SecondaryCard({ amount, title, iconName, style }: { amount: string, title: string, iconName: keyof typeof HeroIcon, style: Style }) {
|
||||
return (
|
||||
<div className={`h-12 w-80 m-1 p-2 text-white flex flex-row items-center ${colorClasses(style)}`}>
|
||||
<Icon className="m-3 h-7 w-7" name={iconName} />
|
||||
|
@ -1,41 +1,45 @@
|
||||
/* Copyright (C) 2024 Manuel Bustillo*/
|
||||
|
||||
import { GlobalSummary as Summary} from '@/app/lib/definitions';
|
||||
import { MainCard, SecondaryCard } from '../components/dashboard-cards';
|
||||
|
||||
export default function GlobalSummary({ summary }: { summary: Summary }) {
|
||||
export default async function GlobalSummary() {
|
||||
return (
|
||||
<div className="my-4">
|
||||
<div className="flex flex-row w-full my-2">
|
||||
<div className="flex flex-col">
|
||||
<MainCard amount={`${summary.expenses.projected.total}€`} title="Projected" subtitle={`${summary.expenses.projected.guests} guests`} style="blue" iconName="ArrowTrendingUpIcon" />
|
||||
<MainCard amount={`${Math.round(summary.expenses.projected.total / summary.expenses.projected.guests)}€`} title="/ guest" iconName="UserIcon" style='blue' />
|
||||
</div>
|
||||
<div className="flex flex-col">
|
||||
<MainCard amount={`${summary.expenses.confirmed.total}€`} title="Min." subtitle={`${summary.expenses.confirmed.guests} guests`} iconName="ChevronDoubleDownIcon" style="green" />
|
||||
<MainCard amount={`${Math.round(summary.expenses.confirmed.total / summary.expenses.confirmed.guests)}€`} title="/ guest" iconName="UserIcon" style='green' />
|
||||
|
||||
<div className="flex flex-row w-full my-2">
|
||||
<MainCard style="green" amount="65000€" title="Projected" subtitle="150 guests" iconName="ArrowTrendingUpIcon" />
|
||||
|
||||
<div className="flex flex-col">
|
||||
<MainCard amount="10000€" title="Paid already" iconName="Square3Stack3DIcon" style='blue' />
|
||||
<MainCard amount="198€" title="/ guest" iconName="UserIcon" style='blue' />
|
||||
</div>
|
||||
<div className="flex flex-col">
|
||||
<MainCard amount={`${summary.expenses.status.paid}€`} title="Paid already" subtitle={`${Math.round(summary.expenses.status.paid / summary.expenses.projected.total * 100)}% of projected`} iconName="CheckIcon" style='blue' />
|
||||
<MainCard amount={`${summary.expenses.projected.total - summary.expenses.status.paid}€`} title="To pay" subtitle={`${100 - Math.round(summary.expenses.status.paid / summary.expenses.projected.total * 100)}% of projected`} iconName="BanknotesIcon" style="orange" />
|
||||
<MainCard amount="78000€" title="Max." subtitle='200 guests' iconName="ChevronDoubleUpIcon" style="orange" />
|
||||
<MainCard amount="45000€" title="Min." subtitle="125 guests" iconName="ChevronDoubleDownIcon" style="green" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div className="flex flex-row w-full my-2">
|
||||
<MainCard style="blue" amount={summary.guests.total.toString()} title="Invites sent" iconName="UsersIcon" />
|
||||
<MainCard style="blue" amount="150" title="Invites sent" iconName="UsersIcon" />
|
||||
|
||||
<div className="flex flex-col">
|
||||
<SecondaryCard amount={`${Math.round(summary.guests.confirmed / summary.guests.total * 100)}%`} title={`confirmed (${summary.guests.confirmed} guests)`} iconName="CheckIcon" style='green' />
|
||||
<SecondaryCard amount={`${Math.round(summary.guests.declined / summary.guests.total * 100)}%`} title={`declined (${summary.guests.declined} guests)`} iconName="XMarkIcon" style='red' />
|
||||
<SecondaryCard amount="31%" title="confirmed (27 guests)" iconName="CheckIcon" style='green' />
|
||||
<SecondaryCard amount="5%" title="declined (8 guests)" iconName="XMarkIcon" style='red' />
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col">
|
||||
<SecondaryCard amount={`${Math.round(summary.guests.tentative / summary.guests.total * 100)}%`} title={`tentative (${summary.guests.tentative} guests)`} iconName="QuestionMarkCircleIcon" style='orange' />
|
||||
<SecondaryCard amount={`${Math.round(summary.guests.invited / summary.guests.total * 100)}%`} title={`awaiting (${summary.guests.invited} guests)`} iconName="EllipsisHorizontalIcon" style='gray' />
|
||||
<SecondaryCard amount="17%" title="tentative (14 guests)" iconName="QuestionMarkCircleIcon" style='orange' />
|
||||
<SecondaryCard amount="65%" title="awaiting (72 guests)" iconName="EllipsisHorizontalIcon" style='gray' />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-row w-full my-2">
|
||||
<MainCard style="blue" amount="5" title="Table simulations" iconName="ServerStackIcon" />
|
||||
<MainCard style="blue" amount="9" title="Bus simulations" iconName="TruckIcon" />
|
||||
<MainCard style="blue" amount="98" title="QR codes" iconName="QrCodeIcon" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
@ -17,7 +17,7 @@ export default function SideNav() {
|
||||
<div className="flex h-full flex-col px-3 py-4 md:px-2">
|
||||
<Link
|
||||
className="mb-2 flex h-20 items-center justify-start rounded-md bg-blue-600 p-4 md:h-20"
|
||||
href={`/${getSlug()}/dashboard`}
|
||||
href="/dashboard/guests"
|
||||
>
|
||||
<div className={`${gloriaHallelujah.className} "w-32 text-white md:w-40 antialiased`}>
|
||||
<h1>Wedding Planner</h1>
|
||||
|
@ -27,7 +27,7 @@
|
||||
"@playwright/test": "^1.46.0",
|
||||
"@types/bcrypt": "^5.0.2",
|
||||
"@types/node": "22.10.1",
|
||||
"@types/react": "18.3.16",
|
||||
"@types/react": "18.3.15",
|
||||
"@types/react-dom": "18.3.1"
|
||||
},
|
||||
"engines": {
|
||||
|
56
pnpm-lock.yaml
generated
56
pnpm-lock.yaml
generated
@ -25,10 +25,10 @@ importers:
|
||||
version: 2.1.1
|
||||
next:
|
||||
specifier: 15.0.3
|
||||
version: 15.0.3(@playwright/test@1.49.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.0.3(@playwright/test@1.49.0)(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.25
|
||||
version: 5.0.0-beta.25(next@15.0.3(@playwright/test@1.49.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.25(next@15.0.3(@playwright/test@1.49.0)(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.4.49
|
||||
version: 8.4.49
|
||||
@ -37,7 +37,7 @@ importers:
|
||||
version: 7.0.0
|
||||
primereact:
|
||||
specifier: ^10.8.2
|
||||
version: 10.8.5(@types/react@18.3.16)(react-dom@19.0.0-rc-f38c22b244-20240704(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704)
|
||||
version: 10.8.5(@types/react@18.3.15)(react-dom@19.0.0-rc-f38c22b244-20240704(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704)
|
||||
react:
|
||||
specifier: 19.0.0-rc-f38c22b244-20240704
|
||||
version: 19.0.0-rc-f38c22b244-20240704
|
||||
@ -59,7 +59,7 @@ importers:
|
||||
devDependencies:
|
||||
'@playwright/test':
|
||||
specifier: ^1.46.0
|
||||
version: 1.49.1
|
||||
version: 1.49.0
|
||||
'@types/bcrypt':
|
||||
specifier: ^5.0.2
|
||||
version: 5.0.2
|
||||
@ -67,8 +67,8 @@ importers:
|
||||
specifier: 22.10.1
|
||||
version: 22.10.1
|
||||
'@types/react':
|
||||
specifier: 18.3.16
|
||||
version: 18.3.16
|
||||
specifier: 18.3.15
|
||||
version: 18.3.15
|
||||
'@types/react-dom':
|
||||
specifier: 18.3.1
|
||||
version: 18.3.1
|
||||
@ -306,8 +306,8 @@ packages:
|
||||
resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}
|
||||
engines: {node: '>=14'}
|
||||
|
||||
'@playwright/test@1.49.1':
|
||||
resolution: {integrity: sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g==}
|
||||
'@playwright/test@1.49.0':
|
||||
resolution: {integrity: sha512-DMulbwQURa8rNIQrf94+jPJQ4FmOVdpE5ZppRNvWVjvhC+6sOeo28r8MgIpQRYouXRtt/FCCXU7zn20jnHR4Qw==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
@ -340,8 +340,8 @@ packages:
|
||||
'@types/react-transition-group@4.4.11':
|
||||
resolution: {integrity: sha512-RM05tAniPZ5DZPzzNFP+DmrcOdD0efDUxMy3145oljWSl3x9ZV5vhme98gTxFrj2lhXvmGNnUiuDyJgY9IKkNA==}
|
||||
|
||||
'@types/react@18.3.16':
|
||||
resolution: {integrity: sha512-oh8AMIC4Y2ciKufU8hnKgs+ufgbA/dhPTACaZPM86AbwX9QwnFtSoPWEeRUj8fge+v6kFt78BXcDhAU1SrrAsw==}
|
||||
'@types/react@18.3.15':
|
||||
resolution: {integrity: sha512-XQzbwkCwrsabawgWsvDDwsDTRuH1sf6Uj1fnFYoG03ZXfT54/aBvlylKR9ix70pXAtTn8dFzj358zVcZN4m83w==}
|
||||
|
||||
abbrev@1.1.1:
|
||||
resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==}
|
||||
@ -835,13 +835,13 @@ packages:
|
||||
resolution: {integrity: sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==}
|
||||
engines: {node: '>= 6'}
|
||||
|
||||
playwright-core@1.49.1:
|
||||
resolution: {integrity: sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg==}
|
||||
playwright-core@1.49.0:
|
||||
resolution: {integrity: sha512-R+3KKTQF3npy5GTiKH/T+kdhoJfJojjHESR1YEWhYuEKRVfVaxH3+4+GvXE5xyCngCxhxnykk0Vlah9v8fs3jA==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
playwright@1.49.1:
|
||||
resolution: {integrity: sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA==}
|
||||
playwright@1.49.0:
|
||||
resolution: {integrity: sha512-eKpmys0UFDnfNb3vfsf8Vx2LEOtflgRebl0Im2eQQnYMA4Aqd+Zw8bEOB+7ZKvN76901mRnqdsiOGKxzVTbi7A==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
@ -1337,9 +1337,9 @@ snapshots:
|
||||
'@pkgjs/parseargs@0.11.0':
|
||||
optional: true
|
||||
|
||||
'@playwright/test@1.49.1':
|
||||
'@playwright/test@1.49.0':
|
||||
dependencies:
|
||||
playwright: 1.49.1
|
||||
playwright: 1.49.0
|
||||
|
||||
'@swc/counter@0.1.3': {}
|
||||
|
||||
@ -1366,13 +1366,13 @@ snapshots:
|
||||
|
||||
'@types/react-dom@18.3.1':
|
||||
dependencies:
|
||||
'@types/react': 18.3.16
|
||||
'@types/react': 18.3.15
|
||||
|
||||
'@types/react-transition-group@4.4.11':
|
||||
dependencies:
|
||||
'@types/react': 18.3.16
|
||||
'@types/react': 18.3.15
|
||||
|
||||
'@types/react@18.3.16':
|
||||
'@types/react@18.3.15':
|
||||
dependencies:
|
||||
'@types/prop-types': 15.7.12
|
||||
csstype: 3.1.3
|
||||
@ -1729,13 +1729,13 @@ snapshots:
|
||||
|
||||
nanoid@3.3.7: {}
|
||||
|
||||
next-auth@5.0.0-beta.25(next@15.0.3(@playwright/test@1.49.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.25(next@15.0.3(@playwright/test@1.49.0)(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.37.2
|
||||
next: 15.0.3(@playwright/test@1.49.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.0.3(@playwright/test@1.49.0)(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.0.3(@playwright/test@1.49.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.0.3(@playwright/test@1.49.0)(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.0.3
|
||||
'@swc/counter': 0.1.3
|
||||
@ -1755,7 +1755,7 @@ snapshots:
|
||||
'@next/swc-linux-x64-musl': 15.0.3
|
||||
'@next/swc-win32-arm64-msvc': 15.0.3
|
||||
'@next/swc-win32-x64-msvc': 15.0.3
|
||||
'@playwright/test': 1.49.1
|
||||
'@playwright/test': 1.49.0
|
||||
sharp: 0.33.5
|
||||
transitivePeerDependencies:
|
||||
- '@babel/core'
|
||||
@ -1815,11 +1815,11 @@ snapshots:
|
||||
|
||||
pirates@4.0.6: {}
|
||||
|
||||
playwright-core@1.49.1: {}
|
||||
playwright-core@1.49.0: {}
|
||||
|
||||
playwright@1.49.1:
|
||||
playwright@1.49.0:
|
||||
dependencies:
|
||||
playwright-core: 1.49.1
|
||||
playwright-core: 1.49.0
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.2
|
||||
|
||||
@ -1877,14 +1877,14 @@ snapshots:
|
||||
|
||||
primeicons@7.0.0: {}
|
||||
|
||||
primereact@10.8.5(@types/react@18.3.16)(react-dom@19.0.0-rc-f38c22b244-20240704(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704):
|
||||
primereact@10.8.5(@types/react@18.3.15)(react-dom@19.0.0-rc-f38c22b244-20240704(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704):
|
||||
dependencies:
|
||||
'@types/react-transition-group': 4.4.11
|
||||
react: 19.0.0-rc-f38c22b244-20240704
|
||||
react-dom: 19.0.0-rc-f38c22b244-20240704(react@19.0.0-rc-f38c22b244-20240704)
|
||||
react-transition-group: 4.4.5(react-dom@19.0.0-rc-f38c22b244-20240704(react@19.0.0-rc-f38c22b244-20240704))(react@19.0.0-rc-f38c22b244-20240704)
|
||||
optionalDependencies:
|
||||
'@types/react': 18.3.16
|
||||
'@types/react': 18.3.15
|
||||
|
||||
prop-types@15.8.1:
|
||||
dependencies:
|
||||
|
Loading…
x
Reference in New Issue
Block a user