Files
dashboard/components/mobile/FeedSchedulingScreen.tsx
Alberto-Audrix 32a36cceff
CI / lint-and-test (push) Canceled after 0s
first commit
2026-07-28 08:55:05 +07:00

76 lines
2.7 KiB
TypeScript

import React from 'react';
import { Screen, FeedingEvent } from '../../types.ts';
import { MobileBottomNav } from './MobileLayout.tsx';
interface FeedSchedulingScreenProps {
onNavigate: (screen: Screen) => void;
feedingEvents: FeedingEvent[];
}
const eventConfig = {
completed: {
icon: 'fa-check-circle',
color: 'text-green-500',
bg: 'bg-green-100',
line: 'bg-green-500',
},
upcoming: { icon: 'fa-clock', color: 'text-blue-500', bg: 'bg-blue-100', line: 'bg-gray-300' },
skipped: { icon: 'fa-ban', color: 'text-gray-500', bg: 'bg-gray-100', line: 'bg-gray-300' },
};
const FeedSchedulingScreen: React.FC<FeedSchedulingScreenProps> = ({
onNavigate,
feedingEvents,
}) => {
const today = new Date();
const todaysEvents = feedingEvents
.filter((e) => e.time.toDateString() === today.toDateString())
.sort((a, b) => a.time.getTime() - b.time.getTime());
return (
<div className="bg-gray-50 h-full">
<div className="p-3 pt-8 h-full overflow-y-auto pb-16">
<h1 className="text-xl font-bold text-gray-800">Jadwal Pakan Hari Ini</h1>
<p className="text-xs text-gray-500 mb-4">
{today.toLocaleDateString('id-ID', { weekday: 'long', day: 'numeric', month: 'long' })}
</p>
<div className="relative pl-5">
{/* Vertical Line */}
<div className="absolute left-9 top-0 bottom-0 w-0.5 bg-gray-200"></div>
{todaysEvents.map((event) => {
const config = eventConfig[event.status];
return (
<div key={event.id} className="relative flex items-start mb-4">
<div className="flex-shrink-0 flex flex-col items-center mr-4 z-10">
<div
className={`w-10 h-10 rounded-full flex items-center justify-center ${config.bg}`}
>
<i className={`fa-solid ${config.icon} text-lg ${config.color}`}></i>
</div>
</div>
<div
className={`p-2 rounded-lg w-full ${event.status === 'upcoming' ? 'bg-blue-100 border border-blue-200' : 'bg-white shadow-sm'}`}
>
<p className="font-bold text-gray-800">
{event.time.toLocaleTimeString('id-ID', { hour: '2-digit', minute: '2-digit' })}
</p>
<p className="text-xs text-gray-600">
{event.type} - {event.quantityKg} kg
</p>
<p className="text-xs text-gray-500">Oleh: {event.operatorName}</p>
</div>
</div>
);
})}
</div>
</div>
<MobileBottomNav active="reports" onNavigate={onNavigate} />
</div>
);
};
export default FeedSchedulingScreen;