Improve guard selection by filtering based on availability and overtime
Refactors the guard selection UI to dynamically filter available guards, showing regular hours first and providing an option to display those requiring overtime. Replit-Commit-Author: Agent Replit-Commit-Session-Id: e5565357-90e1-419f-b9a8-6ee8394636df Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/6d543d2c-20b9-4ea6-93fe-70fe9b1d9f80/e5565357-90e1-419f-b9a8-6ee8394636df/qoWuIE4
This commit is contained in:
parent
b782f16797
commit
da547137b7
4
.replit
4
.replit
@ -39,6 +39,10 @@ externalPort = 5000
|
||||
localPort = 43267
|
||||
externalPort = 3003
|
||||
|
||||
[[ports]]
|
||||
localPort = 45469
|
||||
externalPort = 5173
|
||||
|
||||
[env]
|
||||
PORT = "5000"
|
||||
|
||||
|
||||
@ -685,10 +685,19 @@ export default function GeneralPlanning() {
|
||||
</div>
|
||||
|
||||
{/* Select guardia disponibile */}
|
||||
{(() => {
|
||||
// Filtra guardie: mostra solo con ore ordinarie se toggle è off
|
||||
const filteredGuards = availableGuards?.filter(g =>
|
||||
g.isAvailable && (showOvertimeGuards || !g.requiresOvertime)
|
||||
) || [];
|
||||
|
||||
const hasOvertimeGuards = availableGuards?.some(g => g.requiresOvertime && g.isAvailable) || false;
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<Label htmlFor="guard-select">Guardia Disponibile</Label>
|
||||
{!isLoadingGuards && availableGuards && availableGuards.some(g => g.requiresOvertime && g.isAvailable) && (
|
||||
{!isLoadingGuards && hasOvertimeGuards && (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
@ -703,14 +712,6 @@ export default function GeneralPlanning() {
|
||||
{isLoadingGuards ? (
|
||||
<Skeleton className="h-10 w-full" />
|
||||
) : (
|
||||
<>
|
||||
{(() => {
|
||||
// Filtra guardie: mostra solo con ore ordinarie se toggle è off
|
||||
const filteredGuards = availableGuards?.filter(g =>
|
||||
g.isAvailable && (showOvertimeGuards || !g.requiresOvertime)
|
||||
) || [];
|
||||
|
||||
return (
|
||||
<>
|
||||
<Select
|
||||
value={selectedGuardId}
|
||||
@ -738,26 +739,35 @@ export default function GeneralPlanning() {
|
||||
)}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
{filteredGuards.length === 0 && !showOvertimeGuards && availableGuards && availableGuards.some(g => g.isAvailable && g.requiresOvertime) && (
|
||||
{filteredGuards.length === 0 && !showOvertimeGuards && hasOvertimeGuards && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
ℹ️ Alcune guardie disponibili richiedono straordinario. Clicca "Mostra Straordinario" per vederle.
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
})()}
|
||||
</>
|
||||
)}
|
||||
{availableGuards && availableGuards.length > 0 && selectedGuardId && (
|
||||
{filteredGuards.length > 0 && selectedGuardId && (
|
||||
<div className="text-xs space-y-1">
|
||||
{(() => {
|
||||
const guard = availableGuards.find(g => g.guardId === selectedGuardId);
|
||||
const guard = availableGuards?.find(g => g.guardId === selectedGuardId);
|
||||
if (!guard) return null;
|
||||
return (
|
||||
<>
|
||||
<p className="text-muted-foreground">
|
||||
Ore ordinarie: {guard.ordinaryHoursRemaining}h / 40h disponibili
|
||||
{guard.requiresOvertime && ` • Straordinario: ${guard.overtimeHoursRemaining}h / 8h`}
|
||||
</p>
|
||||
<p className="text-muted-foreground">
|
||||
Ore assegnate: {guard.weeklyHoursAssigned}h / {guard.weeklyHoursMax}h (rimangono {guard.weeklyHoursRemaining}h)
|
||||
</p>
|
||||
{guard.nightHoursAssigned > 0 && (
|
||||
<p className="text-muted-foreground">
|
||||
Ore notturne: {guard.nightHoursAssigned}h / 48h settimanali
|
||||
</p>
|
||||
)}
|
||||
{guard.hasRestViolation && (
|
||||
<p className="text-yellow-600 dark:text-yellow-500 font-medium">
|
||||
⚠️ Attenzione: riposo insufficiente dall'ultimo turno
|
||||
</p>
|
||||
)}
|
||||
{guard.conflicts && guard.conflicts.length > 0 && (
|
||||
<p className="text-destructive font-medium">
|
||||
⚠️ Conflitto: {guard.conflicts.map((c: any) =>
|
||||
@ -775,7 +785,11 @@ export default function GeneralPlanning() {
|
||||
})()}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})()}
|
||||
|
||||
{/* Bottone assegna */}
|
||||
<Button
|
||||
|
||||
Loading…
Reference in New Issue
Block a user