2025-10-20 13:41:31 +00:00
|
|
|
import React from 'react'
|
|
|
|
|
import { FaCalendarAlt, FaPlus } from 'react-icons/fa'
|
2025-10-29 13:45:58 +00:00
|
|
|
import { LeaveDto } from '@/proxy/intranet/models'
|
2025-11-11 13:23:12 +00:00
|
|
|
import useLocale from '@/utils/hooks/useLocale'
|
|
|
|
|
import { currentLocalDate } from '@/utils/dateUtils'
|
2025-12-13 14:51:35 +00:00
|
|
|
import { LeaveStatusEnum, LeaveTypeEnum } from '@/types/intranet'
|
2026-01-27 08:25:39 +00:00
|
|
|
import { useLocalization } from '@/utils/hooks/useLocalization'
|
2025-10-20 13:41:31 +00:00
|
|
|
|
|
|
|
|
interface LeaveManagementProps {
|
2025-10-29 13:45:58 +00:00
|
|
|
leaves: LeaveDto[]
|
2025-10-20 13:41:31 +00:00
|
|
|
onNewLeave: () => void
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-29 13:45:58 +00:00
|
|
|
const LeaveManagement: React.FC<LeaveManagementProps> = ({ leaves, onNewLeave }) => {
|
2025-11-11 13:23:12 +00:00
|
|
|
const currentLocale = useLocale()
|
2026-01-27 08:25:39 +00:00
|
|
|
const { translate } = useLocalization();
|
2025-11-11 13:23:12 +00:00
|
|
|
|
2025-10-20 13:41:31 +00:00
|
|
|
return (
|
|
|
|
|
<div className="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700">
|
2025-10-25 20:35:01 +00:00
|
|
|
<div className="p-4 border-b border-gray-200 dark:border-gray-700">
|
2025-10-20 13:41:31 +00:00
|
|
|
<h2 className="text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2">
|
|
|
|
|
<FaCalendarAlt className="w-5 h-5" />
|
2026-01-27 08:25:39 +00:00
|
|
|
{translate('::App.Platform.Intranet.Widgets.LeaveManagement.Title')}
|
2025-10-20 13:41:31 +00:00
|
|
|
</h2>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="p-4 space-y-3">
|
|
|
|
|
{/* İzin bakiye özeti */}
|
|
|
|
|
<div className="grid grid-cols-2 gap-2 mb-4">
|
|
|
|
|
<div className="p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-200 dark:border-blue-800">
|
2026-01-27 08:25:39 +00:00
|
|
|
<p className="text-xs text-gray-600 dark:text-gray-400">{translate('::App.Platform.Intranet.Widgets.LeaveManagement.AnnualLeave')}</p>
|
|
|
|
|
<p className="text-lg font-bold text-blue-600 dark:text-blue-400">12 {translate('::App.Platform.Intranet.Widgets.LeaveManagement.Day')}</p>
|
2025-10-20 13:41:31 +00:00
|
|
|
</div>
|
|
|
|
|
<div className="p-3 bg-green-50 dark:bg-green-900/20 rounded-lg border border-green-200 dark:border-green-800">
|
2026-01-27 08:25:39 +00:00
|
|
|
<p className="text-xs text-gray-600 dark:text-gray-400">{translate('::App.Platform.Intranet.Widgets.LeaveManagement.SickLeave')}</p>
|
|
|
|
|
<p className="text-lg font-bold text-green-600 dark:text-green-400">8 {translate('::App.Platform.Intranet.Widgets.LeaveManagement.Day')}</p>
|
2025-10-20 13:41:31 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Son izin talepleri */}
|
|
|
|
|
<div className="space-y-2">
|
2025-10-29 13:45:58 +00:00
|
|
|
{leaves.slice(0, 3).map((leave) => (
|
2025-10-20 13:41:31 +00:00
|
|
|
<div
|
|
|
|
|
key={leave.id}
|
|
|
|
|
className="p-3 rounded-lg bg-gray-50 dark:bg-gray-900/20 border border-gray-200 dark:border-gray-700"
|
|
|
|
|
>
|
|
|
|
|
<div className="flex items-start justify-between mb-1">
|
|
|
|
|
<h4 className="text-sm font-medium text-gray-900 dark:text-white">
|
2025-10-29 13:45:58 +00:00
|
|
|
{leave.leaveType === LeaveTypeEnum.Annual
|
2026-01-27 08:25:39 +00:00
|
|
|
? `🏖️ ${translate('::App.Platform.Intranet.Widgets.LeaveManagement.Annual')}`
|
2025-10-29 13:45:58 +00:00
|
|
|
: leave.leaveType === LeaveTypeEnum.Sick
|
2026-01-27 08:25:39 +00:00
|
|
|
? `🏥 ${translate('::App.Platform.Intranet.Widgets.LeaveManagement.Sick')}`
|
2025-10-29 13:45:58 +00:00
|
|
|
: leave.leaveType === LeaveTypeEnum.Unpaid
|
2026-01-27 08:25:39 +00:00
|
|
|
? `💼 ${translate('::App.Platform.Intranet.Widgets.LeaveManagement.Unpaid')}`
|
|
|
|
|
: `📋 ${translate('::App.Platform.Intranet.Widgets.LeaveManagement.Other')}`}{' '}
|
|
|
|
|
{translate('::App.Platform.Intranet.Widgets.LeaveManagement.Leave')}
|
2025-10-20 13:41:31 +00:00
|
|
|
</h4>
|
|
|
|
|
<span
|
|
|
|
|
className={`text-xs px-2 py-1 rounded-full ${
|
|
|
|
|
leave.status === LeaveStatusEnum.Approved
|
|
|
|
|
? 'bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300'
|
|
|
|
|
: leave.status === LeaveStatusEnum.Pending
|
|
|
|
|
? 'bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300'
|
|
|
|
|
: 'bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300'
|
|
|
|
|
}`}
|
|
|
|
|
>
|
2025-10-29 13:45:58 +00:00
|
|
|
{leave.status === LeaveStatusEnum.Approved
|
2026-01-27 08:25:39 +00:00
|
|
|
? translate('::App.Platform.Intranet.Widgets.LeaveManagement.Status.Approved')
|
2025-10-29 13:45:58 +00:00
|
|
|
: leave.status === LeaveStatusEnum.Pending
|
2026-01-27 08:25:39 +00:00
|
|
|
? translate('::App.Platform.Intranet.Widgets.LeaveManagement.Status.Pending')
|
|
|
|
|
: translate('::App.Platform.Intranet.Widgets.LeaveManagement.Status.Rejected')}
|
2025-10-20 13:41:31 +00:00
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<p className="text-xs text-gray-600 dark:text-gray-400">
|
2025-11-11 13:23:12 +00:00
|
|
|
{currentLocalDate(leave.startDate, currentLocale || 'tr')} - {currentLocalDate(leave.endDate, currentLocale || 'tr')}{' '}
|
2026-01-27 08:25:39 +00:00
|
|
|
({leave.totalDays} {translate('::App.Platform.Intranet.Widgets.LeaveManagement.Day')})
|
2025-10-20 13:41:31 +00:00
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
onClick={onNewLeave}
|
|
|
|
|
className="w-full mt-3 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm rounded-lg transition-colors flex items-center justify-center gap-2"
|
|
|
|
|
>
|
|
|
|
|
<FaPlus className="w-4 h-4" />
|
2026-01-27 08:25:39 +00:00
|
|
|
{translate('::App.Platform.Intranet.Widgets.LeaveManagement.NewLeaveRequest')}
|
2025-10-20 13:41:31 +00:00
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default LeaveManagement
|