V 1.2.1 Berechnugn der Resttsage auch beim Start
This commit is contained in:
@@ -5,6 +5,10 @@ import { checkAblauf } from '@/lib/checkAblauf';
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { Tablette, DataResponse } from '@/types/tablette';
|
import { Tablette, DataResponse } from '@/types/tablette';
|
||||||
|
|
||||||
|
// Verhindert Caching der Route
|
||||||
|
export const dynamic = 'force-dynamic';
|
||||||
|
export const revalidate = 0;
|
||||||
|
|
||||||
function formatDate(dt: Date | string | null): string {
|
function formatDate(dt: Date | string | null): string {
|
||||||
if (!dt) return '';
|
if (!dt) return '';
|
||||||
const d = moment(dt);
|
const d = moment(dt);
|
||||||
@@ -24,22 +28,26 @@ export async function GET(req: NextRequest) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const [rows] = await pool.query<RowDataPacket[]>(
|
const [rows] = await pool.query<RowDataPacket[]>(
|
||||||
`SELECT tab, pday, cnt, at, akt, until, warn, rem, \`order\`
|
`SELECT tab, pday, cnt, at, rem, \`order\`
|
||||||
FROM tabletten
|
FROM tabletten
|
||||||
ORDER BY ${col} ${sord}, rem DESC, tab ASC`
|
ORDER BY ${col} ${sord}, rem DESC, tab ASC`
|
||||||
);
|
);
|
||||||
|
|
||||||
const values: Tablette[] = rows.map((r) => ({
|
const values: Tablette[] = rows.map((r) => {
|
||||||
|
// Berechne die aktuellen Werte dynamisch basierend auf dem heutigen Datum
|
||||||
|
const calculated = checkAblauf({ cnt: r.cnt, pday: r.pday, at: r.at });
|
||||||
|
return {
|
||||||
tab: r.tab,
|
tab: r.tab,
|
||||||
pday: r.pday,
|
pday: r.pday,
|
||||||
cnt: r.cnt,
|
cnt: r.cnt,
|
||||||
at: formatDate(r.at),
|
at: formatDate(r.at),
|
||||||
akt: r.akt,
|
akt: calculated.akt,
|
||||||
until: formatDate(r.until),
|
until: formatDate(calculated.until),
|
||||||
warn: r.warn === 1 || r.warn === true,
|
warn: calculated.warn,
|
||||||
rem: r.rem,
|
rem: r.rem,
|
||||||
order: r.order,
|
order: r.order,
|
||||||
}));
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const result: DataResponse = {
|
const result: DataResponse = {
|
||||||
total: 1,
|
total: 1,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState } from 'react';
|
import { useState } from 'react';
|
||||||
import LogoutButton from '@/components/LogoutButton';
|
import LogoutButton from '@/components/LogoutButton';
|
||||||
import packageJson from '@/package.json';
|
import packageJson from '@/package.json';
|
||||||
|
|
||||||
@@ -10,13 +10,9 @@ interface AppLayoutProps {
|
|||||||
|
|
||||||
export default function AppLayout({ children }: AppLayoutProps) {
|
export default function AppLayout({ children }: AppLayoutProps) {
|
||||||
const version = packageJson.version;
|
const version = packageJson.version;
|
||||||
const [buildDate, setBuildDate] = useState(process.env.NEXT_PUBLIC_BUILD_DATE || '');
|
const [buildDate] = useState(() =>
|
||||||
|
process.env.NEXT_PUBLIC_BUILD_DATE || new Date().toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit', year: 'numeric' })
|
||||||
useEffect(() => {
|
);
|
||||||
if (!buildDate) {
|
|
||||||
setBuildDate(new Date().toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit', year: 'numeric' }));
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="app-wrapper">
|
<div className="app-wrapper">
|
||||||
|
|||||||
Reference in New Issue
Block a user