featuer change for calendar
This commit is contained in:
@@ -1,61 +0,0 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import {
|
||||
Alert,
|
||||
AlertTitle,
|
||||
Box,
|
||||
CircularProgress,
|
||||
Divider,
|
||||
Link,
|
||||
Typography,
|
||||
} from '@mui/material';
|
||||
import { NotificationsActive as NotificationsActiveIcon } from '@mui/icons-material';
|
||||
import { Link as RouterLink } from 'react-router-dom';
|
||||
import { atemschutzApi } from '../../services/atemschutz';
|
||||
import type { User } from '../../types/auth.types';
|
||||
import type { AtemschutzUebersicht } from '../../types/atemschutz.types';
|
||||
|
||||
// ── Constants ─────────────────────────────────────────────────────────────────
|
||||
|
||||
/** Show a warning banner if a deadline is within this many days. */
|
||||
const WARNING_THRESHOLD_DAYS = 60;
|
||||
|
||||
// ── Types ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
interface PersonalWarning {
|
||||
key: string;
|
||||
/** Negative = overdue, 0 = today, positive = days remaining. */
|
||||
tageRest: number;
|
||||
label: string;
|
||||
/** Short description of what the user should do */
|
||||
action: string;
|
||||
}
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────────
|
||||
|
||||
function buildWarnings(record: AtemschutzUebersicht): PersonalWarning[] {
|
||||
const warnings: PersonalWarning[] = [];
|
||||
|
||||
if (record.untersuchung_tage_rest \!== null && record.untersuchung_tage_rest <= WARNING_THRESHOLD_DAYS) {
|
||||
warnings.push({
|
||||
key: 'untersuchung',
|
||||
tageRest: record.untersuchung_tage_rest,
|
||||
label: 'Atemschutz-Untersuchung',
|
||||
action: 'Termin beim Betriebsarzt vereinbaren',
|
||||
});
|
||||
}
|
||||
|
||||
if (record.leistungstest_tage_rest \!== null && record.leistungstest_tage_rest <= WARNING_THRESHOLD_DAYS) {
|
||||
warnings.push({
|
||||
key: 'leistungstest',
|
||||
tageRest: record.leistungstest_tage_rest,
|
||||
label: 'Leistungstest',
|
||||
action: 'Atemschutzwart kontaktieren',
|
||||
});
|
||||
}
|
||||
|
||||
return warnings;
|
||||
}
|
||||
|
||||
function tageText(tage: number): string {
|
||||
if (tage < 0) {
|
||||
const abs = Math.abs(tage);
|
||||
@@ -35,7 +35,7 @@ interface PersonalWarning {
|
||||
function buildWarnings(record: AtemschutzUebersicht): PersonalWarning[] {
|
||||
const warnings: PersonalWarning[] = [];
|
||||
|
||||
if (record.untersuchung_tage_rest \!== null && record.untersuchung_tage_rest <= WARNING_THRESHOLD_DAYS) {
|
||||
if (record.untersuchung_tage_rest !== null && record.untersuchung_tage_rest <= WARNING_THRESHOLD_DAYS) {
|
||||
warnings.push({
|
||||
key: 'untersuchung',
|
||||
tageRest: record.untersuchung_tage_rest,
|
||||
@@ -44,7 +44,7 @@ function buildWarnings(record: AtemschutzUebersicht): PersonalWarning[] {
|
||||
});
|
||||
}
|
||||
|
||||
if (record.leistungstest_tage_rest \!== null && record.leistungstest_tage_rest <= WARNING_THRESHOLD_DAYS) {
|
||||
if (record.leistungstest_tage_rest !== null && record.leistungstest_tage_rest <= WARNING_THRESHOLD_DAYS) {
|
||||
warnings.push({
|
||||
key: 'leistungstest',
|
||||
tageRest: record.leistungstest_tage_rest,
|
||||
|
||||
@@ -41,8 +41,8 @@ function Header({ onMenuClick }: HeaderProps) {
|
||||
if (\!record) return;
|
||||
let count = 0;
|
||||
const THRESHOLD = 60;
|
||||
if (record.untersuchung_tage_rest \!== null && record.untersuchung_tage_rest <= THRESHOLD) count++;
|
||||
if (record.leistungstest_tage_rest \!== null && record.leistungstest_tage_rest <= THRESHOLD) count++;
|
||||
if (record.untersuchung_tage_rest !== null && record.untersuchung_tage_rest <= THRESHOLD) count++;
|
||||
if (record.leistungstest_tage_rest !== null && record.leistungstest_tage_rest <= THRESHOLD) count++;
|
||||
setWarningCount(count);
|
||||
})
|
||||
.catch(() => { /* non-critical */ });
|
||||
|
||||
Reference in New Issue
Block a user