diff --git a/ui/src/views/hr/components/BadgeManagement.tsx b/ui/src/views/hr/components/BadgeManagement.tsx index 5310467f..c43b4ea7 100644 --- a/ui/src/views/hr/components/BadgeManagement.tsx +++ b/ui/src/views/hr/components/BadgeManagement.tsx @@ -1,64 +1,55 @@ -import React, { useState } from "react"; -import { FaAward, FaPlus, FaEdit, FaTrash, FaUsers } from "react-icons/fa"; -import { HrBadge, HrEmployeeBadge } from "../../../types/hr"; -import DataTable, { Column } from "../../../components/common/DataTable"; -import { mockEmployees } from "../../../mocks/mockEmployees"; -import { mockBadges } from "../../../mocks/mockBadges"; -import BadgeEditModal from "./BadgeEditModal"; -import BadgeAssignmentModal, { - BadgeAssignmentFormData, -} from "./BadgeAssignmentModal"; -import Widget from "../../../components/common/Widget"; -import { getIconComponent } from "../../../utils/erp"; +import React, { useState } from 'react' +import { FaAward, FaPlus, FaEdit, FaTrash, FaUsers } from 'react-icons/fa' +import { HrBadge, HrEmployeeBadge } from '../../../types/hr' +import DataTable, { Column } from '../../../components/common/DataTable' +import { mockEmployees } from '../../../mocks/mockEmployees' +import { mockBadges } from '../../../mocks/mockBadges' +import BadgeEditModal from './BadgeEditModal' +import BadgeAssignmentModal, { BadgeAssignmentFormData } from './BadgeAssignmentModal' +import Widget from '../../../components/common/Widget' +import { getIconComponent } from '../../../utils/erp' +import { Container } from '@/components/shared' const BadgeManagement: React.FC = () => { - const [activeTab, setActiveTab] = useState<"badges" | "assignments">( - "badges" - ); - const [searchTerm, setSearchTerm] = useState(""); - const [searchAssignTerm, setSearchAssignTerm] = useState(""); + const [activeTab, setActiveTab] = useState<'badges' | 'assignments'>('badges') + const [searchTerm, setSearchTerm] = useState('') + const [searchAssignTerm, setSearchAssignTerm] = useState('') // Modal states - const [isBadgeModalOpen, setIsBadgeModalOpen] = useState(false); - const [isAssignmentModalOpen, setIsAssignmentModalOpen] = useState(false); - const [editingBadge, setEditingBadge] = useState(null); + const [isBadgeModalOpen, setIsBadgeModalOpen] = useState(false) + const [isAssignmentModalOpen, setIsAssignmentModalOpen] = useState(false) + const [editingBadge, setEditingBadge] = useState(null) // Mock data - In real app, this would come from API - const [badges, setBadges] = useState(mockBadges); - const [employeeBadges, setEmployeeBadges] = useState([]); + const [badges, setBadges] = useState(mockBadges) + const [employeeBadges, setEmployeeBadges] = useState([]) // Handlers const handleAddBadge = () => { - setEditingBadge(null); - setIsBadgeModalOpen(true); - }; + setEditingBadge(null) + setIsBadgeModalOpen(true) + } const handleEditBadge = (badge: HrBadge) => { - setEditingBadge(badge); - setIsBadgeModalOpen(true); - }; + setEditingBadge(badge) + setIsBadgeModalOpen(true) + } const handleDeleteBadge = (id: string) => { - if (window.confirm("Bu rozeti silmek istediğinizden emin misiniz?")) { - setBadges(badges.filter((badge) => badge.id !== id)); - alert("Rozet başarıyla silindi!"); + if (window.confirm('Bu rozeti silmek istediğinizden emin misiniz?')) { + setBadges(badges.filter((badge) => badge.id !== id)) + alert('Rozet başarıyla silindi!') } - }; + } const handleRevokeBadge = (employeeBadgeId: string) => { - if ( - window.confirm( - "Bu rozet atamasını iptal etmek istediğinizden emin misiniz?" - ) - ) { + if (window.confirm('Bu rozet atamasını iptal etmek istediğinizden emin misiniz?')) { setEmployeeBadges((prev) => - prev.map((eb) => - eb.id === employeeBadgeId ? { ...eb, isActive: false } : eb - ) - ); - alert("Rozet ataması iptal edildi!"); + prev.map((eb) => (eb.id === employeeBadgeId ? { ...eb, isActive: false } : eb)), + ) + alert('Rozet ataması iptal edildi!') } - }; + } const handleBadgeSubmit = (badgeData: HrBadge) => { if (editingBadge) { @@ -71,29 +62,27 @@ const BadgeManagement: React.FC = () => { ...badgeData, lastModificationTime: new Date(), } - : badge - ) - ); - alert("Rozet başarıyla güncellendi!"); + : badge, + ), + ) + alert('Rozet başarıyla güncellendi!') } else { // Create new badge const newBadge: HrBadge = { ...badgeData, creationTime: new Date(), lastModificationTime: new Date(), - }; - setBadges((prev) => [...prev, newBadge]); - alert("Yeni rozet başarıyla oluşturuldu!"); + } + setBadges((prev) => [...prev, newBadge]) + alert('Yeni rozet başarıyla oluşturuldu!') } - setIsBadgeModalOpen(false); - setEditingBadge(null); - }; + setIsBadgeModalOpen(false) + setEditingBadge(null) + } const handleAssignmentSubmit = (assignmentData: BadgeAssignmentFormData) => { - const employee = mockEmployees.find( - (emp) => emp.id === assignmentData.employeeId - ); - const badge = badges.find((b) => b.id === assignmentData.badgeId); + const employee = mockEmployees.find((emp) => emp.id === assignmentData.employeeId) + const badge = badges.find((b) => b.id === assignmentData.badgeId) if (employee && badge) { const newAssignment: HrEmployeeBadge = { @@ -103,42 +92,40 @@ const BadgeManagement: React.FC = () => { badgeId: assignmentData.badgeId, badge: badge, earnedDate: new Date(assignmentData.earnedDate), - expiryDate: assignmentData.expiryDate - ? new Date(assignmentData.expiryDate) - : undefined, + expiryDate: assignmentData.expiryDate ? new Date(assignmentData.expiryDate) : undefined, reason: assignmentData.reason, notes: assignmentData.notes, isActive: true, creationTime: new Date(), lastModificationTime: new Date(), - }; + } - setEmployeeBadges((prev) => [...prev, newAssignment]); - alert("Rozet başarıyla atandı!"); + setEmployeeBadges((prev) => [...prev, newAssignment]) + alert('Rozet başarıyla atandı!') } - setIsAssignmentModalOpen(false); - }; + setIsAssignmentModalOpen(false) + } const openAssignmentModal = () => { - setIsAssignmentModalOpen(true); - }; + setIsAssignmentModalOpen(true) + } const filteredBadges = badges.filter( (badge) => badge.name.toLowerCase().includes(searchTerm.toLowerCase()) || - badge.description.toLowerCase().includes(searchTerm.toLowerCase()) - ); + badge.description.toLowerCase().includes(searchTerm.toLowerCase()), + ) const filteredEmployeeBadges = employeeBadges.filter((eb) => - eb.employee?.fullName.toLowerCase().includes(searchAssignTerm.toLowerCase()) - ); + eb.employee?.fullName.toLowerCase().includes(searchAssignTerm.toLowerCase()), + ) const badgeColumns: Column[] = [ { - key: "icon", - header: "Simge", + key: 'icon', + header: 'Simge', render: (badge: HrBadge) => { - const IconComponent = getIconComponent(badge.icon); + const IconComponent = getIconComponent(badge.icon) return (
{ >
- ); + ) }, }, { - key: "name", - header: "Rozet Adı", + key: 'name', + header: 'Rozet Adı', sortable: true, render: (badge: HrBadge) => (
{badge.name}
-
- {badge.description} -
+
{badge.description}
), }, { - key: "criteria", - header: "Kazanma Kriteri", + key: 'criteria', + header: 'Kazanma Kriteri', render: (badge: HrBadge) => ( -
- {badge.criteria} -
+
{badge.criteria}
), }, { - key: "assignedCount", - header: "Atanan Sayısı", + key: 'assignedCount', + header: 'Atanan Sayısı', render: (badge: HrBadge) => { - const count = employeeBadges.filter( - (eb) => eb.badgeId === badge.id && eb.isActive - ).length; + const count = employeeBadges.filter((eb) => eb.badgeId === badge.id && eb.isActive).length return (
{count}
- ); + ) }, }, { - key: "status", - header: "Durum", + key: 'status', + header: 'Durum', render: (badge: HrBadge) => ( - {badge.isActive ? "Aktif" : "Pasif"} + {badge.isActive ? 'Aktif' : 'Pasif'} ), }, { - key: "actions", - header: "İşlemler", + key: 'actions', + header: 'İşlemler', render: (badge: HrBadge) => (
), }, - ]; + ] const assignmentColumns: Column[] = [ { - key: "employee", - header: "Personel", + key: 'employee', + header: 'Personel', render: (assignment: HrEmployeeBadge) => (
-
- {assignment.employee?.fullName} -
-
- {assignment.employee?.code} -
+
{assignment.employee?.fullName}
+
{assignment.employee?.code}
), }, { - key: "badge", - header: "Rozet", + key: 'badge', + header: 'Rozet', render: (assignment: HrEmployeeBadge) => { - const IconComponent = getIconComponent( - assignment.badge?.icon || "award" - ); + const IconComponent = getIconComponent(assignment.badge?.icon || 'award') return (
{
{assignment.badge?.name}
- ); + ) }, }, { - key: "earnedDate", - header: "Kazanıldığı Tarih", + key: 'earnedDate', + header: 'Kazanıldığı Tarih', render: (assignment: HrEmployeeBadge) => - new Date(assignment.earnedDate).toLocaleDateString("tr-TR"), + new Date(assignment.earnedDate).toLocaleDateString('tr-TR'), }, { - key: "expiryDate", - header: "Geçerlilik Süresi", + key: 'expiryDate', + header: 'Geçerlilik Süresi', render: (assignment: HrEmployeeBadge) => assignment.expiryDate - ? new Date(assignment.expiryDate).toLocaleDateString("tr-TR") - : "Süresiz", + ? new Date(assignment.expiryDate).toLocaleDateString('tr-TR') + : 'Süresiz', }, { - key: "status", - header: "Durum", + key: 'status', + header: 'Durum', render: (assignment: HrEmployeeBadge) => { - const isExpired = - assignment.expiryDate && new Date(assignment.expiryDate) < new Date(); + const isExpired = assignment.expiryDate && new Date(assignment.expiryDate) < new Date() return ( - {!assignment.isActive - ? "İptal Edildi" - : isExpired - ? "Süresi Dolmuş" - : "Aktif"} + {!assignment.isActive ? 'İptal Edildi' : isExpired ? 'Süresi Dolmuş' : 'Aktif'} - ); + ) }, }, { - key: "actions", - header: "İşlemler", + key: 'actions', + header: 'İşlemler', render: (assignment: HrEmployeeBadge) => (
{assignment.isActive && ( @@ -316,156 +284,145 @@ const BadgeManagement: React.FC = () => {
), }, - ]; + ] return ( -
- {/* Header */} -
-
-

Rozet Yönetimi

-

- Personel başarı rozetleri ve ödüllendirme sistemi -

+ +
+ {/* Header */} +
+
+

Rozet Yönetimi

+

+ Personel başarı rozetleri ve ödüllendirme sistemi +

+
-
- {/* Stats Cards */} -
- + {/* Stats Cards */} +
+ - b.isActive).length} - color="yellow" - icon="FaTrophy" - /> + b.isActive).length} + color="yellow" + icon="FaTrophy" + /> - + - ab.employeeId)).size - } - color="purple" - icon="FaStar" - /> -
- - {/* Tabs */} -
- -
- - {/* Tab Content */} - {activeTab === "badges" && ( -
- {/* Search */} - -
- setSearchTerm(e.target.value)} - className="w-full px-2 py-1 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" - /> + ab.employeeId)).size} + color="purple" + icon="FaStar" + /> +
+ {/* Tabs */} +
+
- - {/* Badges Table */} -
- -
+ +
- )} - {activeTab === "assignments" && ( -
-
+ {/* Tab Content */} + {activeTab === 'badges' && ( +
+ {/* Search */} +
setSearchAssignTerm(e.target.value)} + value={searchTerm} + onChange={(e) => setSearchTerm(e.target.value)} className="w-full px-2 py-1 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" />
-
- {/* Assignments Table */} -
- + {/* Badges Table */} +
+ +
-
- )} + )} - {(activeTab === "badges" ? filteredBadges : filteredEmployeeBadges) - .length === 0 && ( -
- -

- {activeTab === "badges" - ? "Rozet bulunamadı" - : "Rozet ataması bulunamadı"} -

-

- {activeTab === "badges" - ? "Henüz rozet tanımlanmamış." - : "Henüz rozet ataması yapılmamış."} -

-
- )} + {activeTab === 'assignments' && ( +
+
+
+ setSearchAssignTerm(e.target.value)} + className="w-full px-2 py-1 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" + /> + + +
+
+ + {/* Assignments Table */} +
+ +
+
+ )} + + {(activeTab === 'badges' ? filteredBadges : filteredEmployeeBadges).length === 0 && ( +
+ +

+ {activeTab === 'badges' ? 'Rozet bulunamadı' : 'Rozet ataması bulunamadı'} +

+

+ {activeTab === 'badges' + ? 'Henüz rozet tanımlanmamış.' + : 'Henüz rozet ataması yapılmamış.'} +

+
+ )} +
{/* Badge Edit Modal */} { onClose={() => setIsBadgeModalOpen(false)} badge={editingBadge} onSubmit={handleBadgeSubmit} - mode={editingBadge ? "edit" : "create"} + mode={editingBadge ? 'edit' : 'create'} /> {/* Badge Assignment Modal */} @@ -482,8 +439,8 @@ const BadgeManagement: React.FC = () => { onClose={() => setIsAssignmentModalOpen(false)} onSubmit={handleAssignmentSubmit} /> -
- ); -}; +
+ ) +} -export default BadgeManagement; +export default BadgeManagement diff --git a/ui/src/views/hr/components/CostCenterManagement.tsx b/ui/src/views/hr/components/CostCenterManagement.tsx index 4cd1c5a1..e3cf12f9 100644 --- a/ui/src/views/hr/components/CostCenterManagement.tsx +++ b/ui/src/views/hr/components/CostCenterManagement.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useState } from 'react' import { FaPlus, FaEdit, @@ -9,64 +9,54 @@ import { FaEye, FaList, FaTh, -} from "react-icons/fa"; -import { HrCostCenter, CostCenterType } from "../../../types/hr"; -import DataTable, { Column } from "../../../components/common/DataTable"; -import { mockCostCenters } from "../../../mocks/mockCostCenters"; -import { mockEmployees } from "../../../mocks/mockEmployees"; -import CostCenterFormModal from "./CostCenterFormModal"; -import CostCenterViewModal from "./CostCenterViewModal"; -import Widget from "../../../components/common/Widget"; -import { - getCostCenterTypeColor, - getCostCenterTypeText, -} from "../../../utils/erp"; +} from 'react-icons/fa' +import { HrCostCenter, CostCenterType } from '../../../types/hr' +import DataTable, { Column } from '../../../components/common/DataTable' +import { mockCostCenters } from '../../../mocks/mockCostCenters' +import { mockEmployees } from '../../../mocks/mockEmployees' +import CostCenterFormModal from './CostCenterFormModal' +import CostCenterViewModal from './CostCenterViewModal' +import Widget from '../../../components/common/Widget' +import { getCostCenterTypeColor, getCostCenterTypeText } from '../../../utils/erp' +import { Container } from '@/components/shared' const CostCenterManagement: React.FC = () => { - const [costCenters, setCostCenters] = - useState(mockCostCenters); - const [searchTerm, setSearchTerm] = useState(""); - const [selectedType, setSelectedType] = useState("all"); - const [viewMode, setViewMode] = useState<"list" | "cards">("list"); - const [isFormModalOpen, setIsFormModalOpen] = useState(false); - const [isViewModalOpen, setIsViewModalOpen] = useState(false); - const [selectedCostCenter, setSelectedCostCenter] = - useState(null); - const [editingCostCenter, setEditingCostCenter] = useState< - HrCostCenter | undefined - >(undefined); + const [costCenters, setCostCenters] = useState(mockCostCenters) + const [searchTerm, setSearchTerm] = useState('') + const [selectedType, setSelectedType] = useState('all') + const [viewMode, setViewMode] = useState<'list' | 'cards'>('list') + const [isFormModalOpen, setIsFormModalOpen] = useState(false) + const [isViewModalOpen, setIsViewModalOpen] = useState(false) + const [selectedCostCenter, setSelectedCostCenter] = useState(null) + const [editingCostCenter, setEditingCostCenter] = useState(undefined) // Cost center bağlantılarını kur mockCostCenters.forEach((cc) => { if (cc.responsibleEmployeeId) { - cc.responsibleEmployee = mockEmployees.find( - (emp) => emp.id === cc.responsibleEmployeeId - ); + cc.responsibleEmployee = mockEmployees.find((emp) => emp.id === cc.responsibleEmployeeId) } - }); + }) const handleAdd = () => { - setEditingCostCenter(undefined); - setIsFormModalOpen(true); - }; + setEditingCostCenter(undefined) + setIsFormModalOpen(true) + } const handleEdit = (costCenter: HrCostCenter) => { - setEditingCostCenter(costCenter); - setIsFormModalOpen(true); - }; + setEditingCostCenter(costCenter) + setIsFormModalOpen(true) + } const handleView = (costCenter: HrCostCenter) => { - setSelectedCostCenter(costCenter); - setIsViewModalOpen(true); - }; + setSelectedCostCenter(costCenter) + setIsViewModalOpen(true) + } const handleDelete = (id: string) => { - if ( - window.confirm("Bu maliyet merkezini silmek istediğinizden emin misiniz?") - ) { - setCostCenters(costCenters.filter((cc) => cc.id !== id)); + if (window.confirm('Bu maliyet merkezini silmek istediğinizden emin misiniz?')) { + setCostCenters(costCenters.filter((cc) => cc.id !== id)) } - }; + } const handleSave = (costCenterData: Partial) => { if (editingCostCenter) { @@ -79,9 +69,9 @@ const CostCenterManagement: React.FC = () => { ...costCenterData, lastModificationTime: new Date(), } - : cc - ) - ); + : cc, + ), + ) } else { // Add new const newCostCenter: HrCostCenter = { @@ -90,12 +80,12 @@ const CostCenterManagement: React.FC = () => { subCostCenters: [], creationTime: new Date(), lastModificationTime: new Date(), - } as HrCostCenter; - setCostCenters([...costCenters, newCostCenter]); + } as HrCostCenter + setCostCenters([...costCenters, newCostCenter]) } - setIsFormModalOpen(false); - setEditingCostCenter(undefined); - }; + setIsFormModalOpen(false) + setEditingCostCenter(undefined) + } const filteredCostCenters = costCenters.filter((costCenter) => { if ( @@ -103,37 +93,37 @@ const CostCenterManagement: React.FC = () => { !costCenter.name.toLowerCase().includes(searchTerm.toLowerCase()) && !costCenter.code.toLowerCase().includes(searchTerm.toLowerCase()) ) { - return false; + return false } - if (selectedType !== "all" && costCenter.costCenterType !== selectedType) { - return false; + if (selectedType !== 'all' && costCenter.costCenterType !== selectedType) { + return false } - return true; - }); + return true + }) const getVariancePercentage = (budgeted: number, actual: number): number => { - if (budgeted === 0) return 0; - return ((actual - budgeted) / budgeted) * 100; - }; + if (budgeted === 0) return 0 + return ((actual - budgeted) / budgeted) * 100 + } const columns: Column[] = [ { - key: "code", - header: "Maliyet Merkezi Kodu", + key: 'code', + header: 'Maliyet Merkezi Kodu', sortable: true, }, { - key: "name", - header: "Maliyet Merkezi Adı", + key: 'name', + header: 'Maliyet Merkezi Adı', sortable: true, }, { - key: "costCenterType", - header: "Tip", + key: 'costCenterType', + header: 'Tip', render: (costCenter: HrCostCenter) => ( {getCostCenterTypeText(costCenter.costCenterType)} @@ -141,14 +131,13 @@ const CostCenterManagement: React.FC = () => { ), }, { - key: "responsibleEmployee", - header: "Sorumlu", - render: (costCenter: HrCostCenter) => - costCenter.responsibleEmployee?.fullName || "-", + key: 'responsibleEmployee', + header: 'Sorumlu', + render: (costCenter: HrCostCenter) => costCenter.responsibleEmployee?.fullName || '-', }, { - key: "budgetedAmount", - header: "Bütçe", + key: 'budgetedAmount', + header: 'Bütçe', render: (costCenter: HrCostCenter) => (
@@ -157,8 +146,8 @@ const CostCenterManagement: React.FC = () => { ), }, { - key: "actualAmount", - header: "Gerçekleşen", + key: 'actualAmount', + header: 'Gerçekleşen', render: (costCenter: HrCostCenter) => (
@@ -167,47 +156,38 @@ const CostCenterManagement: React.FC = () => { ), }, { - key: "variance", - header: "Fark (%)", + key: 'variance', + header: 'Fark (%)', render: (costCenter: HrCostCenter) => { - const variance = getVariancePercentage( - costCenter.budgetedAmount, - costCenter.actualAmount - ); - const isPositive = variance > 0; + const variance = getVariancePercentage(costCenter.budgetedAmount, costCenter.actualAmount) + const isPositive = variance > 0 return (
- - {isPositive ? "+" : ""} + + {isPositive ? '+' : ''} {variance.toFixed(1)}%
- ); + ) }, }, { - key: "status", - header: "Durum", + key: 'status', + header: 'Durum', render: (costCenter: HrCostCenter) => ( - {costCenter.isActive ? "Aktif" : "Pasif"} + {costCenter.isActive ? 'Aktif' : 'Pasif'} ), }, { - key: "actions", - header: "İşlemler", + key: 'actions', + header: 'İşlemler', render: (costCenter: HrCostCenter) => (
), }, - ]; + ] - const totalBudget = costCenters.reduce( - (sum, cc) => sum + cc.budgetedAmount, - 0 - ); - const totalActual = costCenters.reduce((sum, cc) => sum + cc.actualAmount, 0); - const totalVariance = getVariancePercentage(totalBudget, totalActual); + const totalBudget = costCenters.reduce((sum, cc) => sum + cc.budgetedAmount, 0) + const totalActual = costCenters.reduce((sum, cc) => sum + cc.actualAmount, 0) + const totalVariance = getVariancePercentage(totalBudget, totalActual) const renderCards = () => (
{filteredCostCenters.map((costCenter) => { - const variance = getVariancePercentage( - costCenter.budgetedAmount, - costCenter.actualAmount - ); - const isPositive = variance > 0; + const variance = getVariancePercentage(costCenter.budgetedAmount, costCenter.actualAmount) + const isPositive = variance > 0 return (
{
-

- {costCenter.name} -

+

{costCenter.name}

{costCenter.code}

{getCostCenterTypeText(costCenter.costCenterType)} @@ -275,32 +247,22 @@ const CostCenterManagement: React.FC = () => {
{costCenter.description && ( -

- {costCenter.description} -

+

{costCenter.description}

)}
Bütçe: - - ₺{costCenter.budgetedAmount.toLocaleString()} - + ₺{costCenter.budgetedAmount.toLocaleString()}
Gerçekleşen: - - ₺{costCenter.actualAmount.toLocaleString()} - + ₺{costCenter.actualAmount.toLocaleString()}
Fark: - - {isPositive ? "+" : ""} + + {isPositive ? '+' : ''} {variance.toFixed(1)}%
@@ -318,12 +280,10 @@ const CostCenterManagement: React.FC = () => {
- {costCenter.isActive ? "Aktif" : "Pasif"} + {costCenter.isActive ? 'Aktif' : 'Pasif'}
@@ -352,162 +312,156 @@ const CostCenterManagement: React.FC = () => {
- ); + ) })}
- ); + ) return ( -
- {/* Header */} -
-
-

- Maliyet Merkezi Yönetimi -

-

- Maliyet merkezlerini ve bütçe takibini yönetin -

+ +
+ {/* Header */} +
+
+

Maliyet Merkezi Yönetimi

+

+ Maliyet merkezlerini ve bütçe takibini yönetin +

+
+
- -
- {/* Stats Cards */} -
- + {/* Stats Cards */} +
+ - + - + - 0 ? "+" : ""}${totalVariance.toFixed(1)}%`} - color={totalVariance > 0 ? "red" : "green"} - icon="FaPercentage" - /> -
+ 0 ? '+' : ''}${totalVariance.toFixed(1)}%`} + color={totalVariance > 0 ? 'red' : 'green'} + icon="FaPercentage" + /> +
- {/* Filters and View Mode */} -
-
-
- setSearchTerm(e.target.value)} - className="w-full px-3 py-1.5 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" - /> + {/* Filters and View Mode */} +
+
+
+ setSearchTerm(e.target.value)} + className="w-full px-3 py-1.5 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" + /> +
+ +
- + {/* View Mode Toggle */} +
+ + +
- {/* View Mode Toggle */} -
- - -
+ {/* Content */} + {viewMode === 'list' ? ( +
+ +
+ ) : ( + renderCards() + )} + + {filteredCostCenters.length === 0 && ( +
+ +

Maliyet merkezi bulunamadı

+

Arama kriterlerinizi değiştirmeyi deneyin.

+
+ )}
- {/* Content */} - {viewMode === "list" ? ( -
- -
- ) : ( - renderCards() - )} - - {filteredCostCenters.length === 0 && ( -
- -

- Maliyet merkezi bulunamadı -

-

- Arama kriterlerinizi değiştirmeyi deneyin. -

-
- )} - {/* Modals */} { - setIsFormModalOpen(false); - setEditingCostCenter(undefined); + setIsFormModalOpen(false) + setEditingCostCenter(undefined) }} onSave={handleSave} costCenter={editingCostCenter} - title={ - editingCostCenter ? "Maliyet Merkezi Düzenle" : "Yeni Maliyet Merkezi" - } + title={editingCostCenter ? 'Maliyet Merkezi Düzenle' : 'Yeni Maliyet Merkezi'} /> { - setIsViewModalOpen(false); - setSelectedCostCenter(null); + setIsViewModalOpen(false) + setSelectedCostCenter(null) }} costCenter={selectedCostCenter} /> -
- ); -}; + + ) +} -export default CostCenterManagement; +export default CostCenterManagement diff --git a/ui/src/views/hr/components/Degree360Evaluation.tsx b/ui/src/views/hr/components/Degree360Evaluation.tsx index 712a27d5..2b9cb43e 100644 --- a/ui/src/views/hr/components/Degree360Evaluation.tsx +++ b/ui/src/views/hr/components/Degree360Evaluation.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useState } from 'react' import { FaUsers, FaEye, @@ -9,7 +9,7 @@ import { FaSave, FaPlay, FaPoll, -} from "react-icons/fa"; +} from 'react-icons/fa' import { HrEvaluation360, CampaignStatusEnum, @@ -20,15 +20,15 @@ import { HrEvaluation360Result, HrGroupScore, HrAssessorTypeScore, -} from "../../../types/hr"; -import DataTable, { Column } from "../../../components/common/DataTable"; -import { mockEvaluation360 } from "../../../mocks/mockEvaluation360"; -import { mockEvaluation360Results } from "../../../mocks/mockEvaluation360Results"; -import { mockEmployees } from "../../../mocks/mockEmployees"; -import { mockDepartments } from "../../../mocks/mockDepartments"; -import { mockEvaluation360Templates } from "../../../mocks/mockEvaluation360Templates"; -import { mockBusinessParties } from "../../../mocks/mockBusinessParties"; -import Widget from "../../../components/common/Widget"; +} from '../../../types/hr' +import DataTable, { Column } from '../../../components/common/DataTable' +import { mockEvaluation360 } from '../../../mocks/mockEvaluation360' +import { mockEvaluation360Results } from '../../../mocks/mockEvaluation360Results' +import { mockEmployees } from '../../../mocks/mockEmployees' +import { mockDepartments } from '../../../mocks/mockDepartments' +import { mockEvaluation360Templates } from '../../../mocks/mockEvaluation360Templates' +import { mockBusinessParties } from '../../../mocks/mockBusinessParties' +import Widget from '../../../components/common/Widget' import { getAssessorTypeDescription, getAssessorTypeText, @@ -36,220 +36,186 @@ import { getParticipantStatusText, getCampaignStatusColor, getCampaignStatusText, -} from "../../../utils/erp"; +} from '../../../utils/erp' +import { Container } from '@/components/shared' const Degree360Evaluation: React.FC = () => { - const [activeTab, setActiveTab] = useState<"campaigns" | "results">( - "campaigns" - ); - const [selectedStatus, setSelectedStatus] = useState("all"); - const [selectedEmployee, setSelectedEmployee] = useState("all"); - const [selectedDepartment, setSelectedDepartment] = useState("all"); + const [activeTab, setActiveTab] = useState<'campaigns' | 'results'>('campaigns') + const [selectedStatus, setSelectedStatus] = useState('all') + const [selectedEmployee, setSelectedEmployee] = useState('all') + const [selectedDepartment, setSelectedDepartment] = useState('all') // Results tab filters - const [selectedResultsStatus, setSelectedResultsStatus] = - useState("all"); - const [selectedResultsEmployee, setSelectedResultsEmployee] = - useState("all"); - const [selectedResultsDepartment, setSelectedResultsDepartment] = - useState("all"); - const [selectedResultsCampaign, setSelectedResultsCampaign] = - useState("all"); + const [selectedResultsStatus, setSelectedResultsStatus] = useState('all') + const [selectedResultsEmployee, setSelectedResultsEmployee] = useState('all') + const [selectedResultsDepartment, setSelectedResultsDepartment] = useState('all') + const [selectedResultsCampaign, setSelectedResultsCampaign] = useState('all') // Modal states - const [showCampaignModal, setShowCampaignModal] = useState(false); - const [showViewModal, setShowViewModal] = useState(false); - const [showEvaluationModal, setShowEvaluationModal] = useState(false); - const [showResultDetailModal, setShowResultDetailModal] = useState(false); - const [showResultEditModal, setShowResultEditModal] = useState(false); - const [selectedCampaign, setSelectedCampaign] = - useState(null); + const [showCampaignModal, setShowCampaignModal] = useState(false) + const [showViewModal, setShowViewModal] = useState(false) + const [showEvaluationModal, setShowEvaluationModal] = useState(false) + const [showResultDetailModal, setShowResultDetailModal] = useState(false) + const [showResultEditModal, setShowResultEditModal] = useState(false) + const [selectedCampaign, setSelectedCampaign] = useState(null) const [selectedResult, setSelectedResult] = useState<{ - resultId: string; - evaluatedEmployeeName: string; - evaluatorName: string; - campaignName: string; - overallScore: number; - scorePercentage: number; - evaluatedEmployeeId: string; - evaluatorId: string; - campaignId: string; - evaluatorType: AssessorTypeEnum; - status: ParticipantStatusEnum; - completedDate?: Date; - } | null>(null); + resultId: string + evaluatedEmployeeName: string + evaluatorName: string + campaignName: string + overallScore: number + scorePercentage: number + evaluatedEmployeeId: string + evaluatorId: string + campaignId: string + evaluatorType: AssessorTypeEnum + status: ParticipantStatusEnum + completedDate?: Date + } | null>(null) // Evaluation states - const [evaluationTarget, setEvaluationTarget] = useState(""); - const [evaluationEvaluator, setEvaluationEvaluator] = useState(""); - const [selectedAssessorType, setSelectedAssessorType] = - useState(null); - const [externalEvaluatorName, setExternalEvaluatorName] = - useState(""); - const [externalEvaluatorEmail, setExternalEvaluatorEmail] = - useState(""); - const [selectedCustomerId, setSelectedCustomerId] = useState(""); - const [evaluatorSearchTerm, setEvaluatorSearchTerm] = useState(""); + const [evaluationTarget, setEvaluationTarget] = useState('') + const [evaluationEvaluator, setEvaluationEvaluator] = useState('') + const [selectedAssessorType, setSelectedAssessorType] = useState(null) + const [externalEvaluatorName, setExternalEvaluatorName] = useState('') + const [externalEvaluatorEmail, setExternalEvaluatorEmail] = useState('') + const [selectedCustomerId, setSelectedCustomerId] = useState('') + const [evaluatorSearchTerm, setEvaluatorSearchTerm] = useState('') const [currentCampaignForEvaluation, setCurrentCampaignForEvaluation] = - useState(null); + useState(null) // Evaluation responses state - const [evaluationResponses, setEvaluationResponses] = useState< - Record - >({}); + const [evaluationResponses, setEvaluationResponses] = useState>( + {}, + ) // Edit modal states - const [editResponses, setEditResponses] = useState< - Record - >({}); - const [editManagerComments, setEditManagerComments] = useState(""); - const [editHrComments, setEditHrComments] = useState(""); - const [editResultStatus, setEditResultStatus] = useState("PENDING"); + const [editResponses, setEditResponses] = useState>({}) + const [editManagerComments, setEditManagerComments] = useState('') + const [editHrComments, setEditHrComments] = useState('') + const [editResultStatus, setEditResultStatus] = useState('PENDING') // Form states const [campaignFormData, setCampaignFormData] = useState({ - name: "", - description: "", - templateId: "", - departmentId: "", + name: '', + description: '', + templateId: '', + departmentId: '', targetEmployees: [] as string[], - startDate: "", - endDate: "", - }); + startDate: '', + endDate: '', + }) // Event handlers const handleCloseModal = () => { - setShowCampaignModal(false); - setShowViewModal(false); - setShowEvaluationModal(false); - setShowResultDetailModal(false); - setShowResultEditModal(false); - setSelectedCampaign(null); - setSelectedResult(null); - setEvaluationTarget(""); - setEvaluationEvaluator(""); - setSelectedAssessorType(null); - setExternalEvaluatorName(""); - setExternalEvaluatorEmail(""); - setSelectedCustomerId(""); - setEvaluatorSearchTerm(""); - setCurrentCampaignForEvaluation(null); - setEvaluationResponses({}); - setEditResponses({}); - setEditManagerComments(""); - setEditHrComments(""); - setEditResultStatus("PENDING"); + setShowCampaignModal(false) + setShowViewModal(false) + setShowEvaluationModal(false) + setShowResultDetailModal(false) + setShowResultEditModal(false) + setSelectedCampaign(null) + setSelectedResult(null) + setEvaluationTarget('') + setEvaluationEvaluator('') + setSelectedAssessorType(null) + setExternalEvaluatorName('') + setExternalEvaluatorEmail('') + setSelectedCustomerId('') + setEvaluatorSearchTerm('') + setCurrentCampaignForEvaluation(null) + setEvaluationResponses({}) + setEditResponses({}) + setEditManagerComments('') + setEditHrComments('') + setEditResultStatus('PENDING') setCampaignFormData({ - name: "", - description: "", - templateId: "", - departmentId: "", + name: '', + description: '', + templateId: '', + departmentId: '', targetEmployees: [], - startDate: "", - endDate: "", - }); - }; + startDate: '', + endDate: '', + }) + } // Response handling functions const handleResponseChange = (questionId: string, value: string | number) => { setEvaluationResponses((prev) => ({ ...prev, [questionId]: value, - })); - }; + })) + } // Edit response handling function - const handleEditResponseChange = ( - questionId: string, - value: string | number - ) => { + const handleEditResponseChange = (questionId: string, value: string | number) => { setEditResponses((prev) => ({ ...prev, [questionId]: value, - })); - }; + })) + } // Evaluation kaydetme fonksiyonu const handleSaveEvaluation = () => { - if ( - !currentCampaignForEvaluation || - !evaluationTarget || - !evaluationEvaluator - ) { - alert("Tüm alanları doldurun!"); - return; + if (!currentCampaignForEvaluation || !evaluationTarget || !evaluationEvaluator) { + alert('Tüm alanları doldurun!') + return } const template = mockEvaluation360Templates.find( - (t) => t.id === currentCampaignForEvaluation.templateId - ); + (t) => t.id === currentCampaignForEvaluation.templateId, + ) if (!template) { - alert("Template bulunamadı!"); - return; + alert('Template bulunamadı!') + return } // Responses oluştur - const responses = Object.entries(evaluationResponses).map( - ([questionId, responseValue]) => { - const question = template.questionGroups - .flatMap((g) => g.questions) - .find((q) => q.id === questionId); + const responses = Object.entries(evaluationResponses).map(([questionId, responseValue]) => { + const question = template.questionGroups + .flatMap((g) => g.questions) + .find((q) => q.id === questionId) - let score = 0; - if (question) { - if (question.questionType === QuestionTypeEnum.Rating) { - score = Number(responseValue); - } else if (question.questionType === QuestionTypeEnum.YesNo) { - score = - responseValue === "yes" - ? question.maxRating || 5 - : question.minRating || 1; - } else if ( - question.questionType === QuestionTypeEnum.MultipleChoice - ) { - const option = question.options?.find( - (o) => o.value === Number(responseValue) - ); - score = option?.value || 0; - } + let score = 0 + if (question) { + if (question.questionType === QuestionTypeEnum.Rating) { + score = Number(responseValue) + } else if (question.questionType === QuestionTypeEnum.YesNo) { + score = responseValue === 'yes' ? question.maxRating || 5 : question.minRating || 1 + } else if (question.questionType === QuestionTypeEnum.MultipleChoice) { + const option = question.options?.find((o) => o.value === Number(responseValue)) + score = option?.value || 0 } - - return { - id: `response-${Date.now()}-${Math.random()}`, - participantId: `participant-${Date.now()}`, - questionId, - question, - responseValue, - responseText: - typeof responseValue === "string" ? responseValue : undefined, - score, - submittedDate: new Date(), - }; } - ); + + return { + id: `response-${Date.now()}-${Math.random()}`, + participantId: `participant-${Date.now()}`, + questionId, + question, + responseValue, + responseText: typeof responseValue === 'string' ? responseValue : undefined, + score, + submittedDate: new Date(), + } + }) // Puanları hesapla - const totalScore = responses.reduce( - (sum, response) => sum + response.score, - 0 - ); + const totalScore = responses.reduce((sum, response) => sum + response.score, 0) const maxScore = template.questionGroups .flatMap((g) => g.questions) - .reduce((sum, q) => sum + (q.maxRating || 5), 0); + .reduce((sum, q) => sum + (q.maxRating || 5), 0) - const scorePercentage = maxScore > 0 ? (totalScore / maxScore) * 100 : 0; + const scorePercentage = maxScore > 0 ? (totalScore / maxScore) * 100 : 0 // Grup skorlarını hesapla const groupScores: HrGroupScore[] = template.questionGroups.map((group) => { const groupResponses = responses.filter((r) => - group.questions.some((q) => q.id === r.questionId) - ); - const groupScore = groupResponses.reduce((sum, r) => sum + r.score, 0); - const groupMaxScore = group.questions.reduce( - (sum, q) => sum + (q.maxRating || 5), - 0 - ); + group.questions.some((q) => q.id === r.questionId), + ) + const groupScore = groupResponses.reduce((sum, r) => sum + r.score, 0) + const groupMaxScore = group.questions.reduce((sum, q) => sum + (q.maxRating || 5), 0) return { groupId: group.id, @@ -258,8 +224,8 @@ const Degree360Evaluation: React.FC = () => { maxScore: groupMaxScore, percentage: groupMaxScore > 0 ? (groupScore / groupMaxScore) * 100 : 0, responseCount: groupResponses.length, - }; - }); + } + }) // Assessor type skorlarını hesapla const assessorTypeScores: HrAssessorTypeScore[] = [ @@ -270,7 +236,7 @@ const Degree360Evaluation: React.FC = () => { maxScore: maxScore, percentage: scorePercentage, }, - ]; + ] // Evaluation360Result oluştur const evaluationResult: HrEvaluation360Result = { @@ -283,9 +249,7 @@ const Degree360Evaluation: React.FC = () => { id: `participant-${Date.now()}`, campaignId: currentCampaignForEvaluation.id, evaluatedEmployeeId: evaluationTarget, - evaluatedEmployee: mockEmployees.find( - (e) => e.id === evaluationTarget - ), + evaluatedEmployee: mockEmployees.find((e) => e.id === evaluationTarget), evaluatorId: evaluationEvaluator, evaluator: selectedAssessorType === AssessorTypeEnum.External || @@ -299,7 +263,7 @@ const Degree360Evaluation: React.FC = () => { completedDate: new Date(), responses, overallScore: totalScore, - notes: "", + notes: '', }, ], overallScore: totalScore, @@ -307,81 +271,76 @@ const Degree360Evaluation: React.FC = () => { scorePercentage, groupScores, assessorTypeScores, - strengths: ["Güçlü iletişim", "Takım çalışması"], // Örnek veriler - developmentAreas: ["Zaman yönetimi", "Teknik beceriler"], // Örnek veriler - actionPlan: ["Zaman yönetimi kursu alma", "Teknik eğitimlere katılma"], // Örnek veriler - managerComments: "", - hrComments: "", + strengths: ['Güçlü iletişim', 'Takım çalışması'], // Örnek veriler + developmentAreas: ['Zaman yönetimi', 'Teknik beceriler'], // Örnek veriler + actionPlan: ['Zaman yönetimi kursu alma', 'Teknik eğitimlere katılma'], // Örnek veriler + managerComments: '', + hrComments: '', status: ResultStatusEnum.Pending, generatedDate: new Date(), approvedBy: undefined, approvedDate: undefined, - }; + } // Console'a yazdır - console.log("Evaluation360Result:", evaluationResult); + console.log('Evaluation360Result:', evaluationResult) - alert("Değerlendirme başarıyla kaydedildi! Sonuç konsola yazdırıldı."); - handleCloseModal(); - }; + alert('Değerlendirme başarıyla kaydedildi! Sonuç konsola yazdırıldı.') + handleCloseModal() + } const handleNewCampaign = () => { - setSelectedCampaign(null); - setShowCampaignModal(true); - }; + setSelectedCampaign(null) + setShowCampaignModal(true) + } const handleEditCampaign = (campaign: HrEvaluation360 | null) => { if (campaign) { - setSelectedCampaign(campaign); + setSelectedCampaign(campaign) setCampaignFormData({ name: campaign.name, description: campaign.description, templateId: campaign.templateId, - departmentId: campaign.departmentId || "", + departmentId: campaign.departmentId || '', targetEmployees: campaign.targetEmployees, - startDate: campaign.startDate.toISOString().split("T")[0], - endDate: campaign.endDate.toISOString().split("T")[0], - }); - setShowCampaignModal(true); + startDate: campaign.startDate.toISOString().split('T')[0], + endDate: campaign.endDate.toISOString().split('T')[0], + }) + setShowCampaignModal(true) } - }; + } const handleViewCampaign = (campaign: HrEvaluation360) => { - setSelectedCampaign(campaign); - setShowViewModal(true); - }; + setSelectedCampaign(campaign) + setShowViewModal(true) + } const handleSaveCampaign = () => { - console.log("Değerlendirme kaydediliyor:", campaignFormData); - handleCloseModal(); - }; + console.log('Değerlendirme kaydediliyor:', campaignFormData) + handleCloseModal() + } const handleDepartmentChange = (departmentId: string) => { - setSelectedDepartment(departmentId); + setSelectedDepartment(departmentId) setCampaignFormData({ ...campaignFormData, departmentId, targetEmployees: [], - }); - }; + }) + } // Değerlendirme yapma handler'ı const handleStartEvaluation = () => { - setCurrentCampaignForEvaluation(null); - setEvaluationTarget(""); - setEvaluationEvaluator(""); - setShowEvaluationModal(true); - }; + setCurrentCampaignForEvaluation(null) + setEvaluationTarget('') + setEvaluationEvaluator('') + setShowEvaluationModal(true) + } // Otomatik değerlendirici belirleme fonksiyonu (360° metodolojisi) - const getEvaluatorsByType = ( - targetEmployeeId: string, - assessorType: AssessorTypeEnum - ) => { - const targetEmployee = mockEmployees.find( - (emp) => emp.id === targetEmployeeId - ); - if (!targetEmployee) return []; + const getEvaluatorsByType = (targetEmployeeId: string, assessorType: AssessorTypeEnum) => { + const targetEmployee = mockEmployees.find((emp) => emp.id === targetEmployeeId) + if (!targetEmployee) return [] switch (assessorType) { case AssessorTypeEnum.Self: { @@ -391,31 +350,29 @@ const Degree360Evaluation: React.FC = () => { name: targetEmployee.fullName, title: targetEmployee.jobPosition?.name, department: - mockDepartments.find((d) => d.id === targetEmployee.departmantId) - ?.name || "", - type: "employee", + mockDepartments.find((d) => d.id === targetEmployee.departmantId)?.name || '', + type: 'employee', }, - ]; + ] } case AssessorTypeEnum.Manager: { const managers = mockEmployees.filter( (emp) => emp.departmantId === targetEmployee.departmantId && - (typeof emp.jobPosition?.level === "number" && - typeof targetEmployee.jobPosition?.level === "number" + (typeof emp.jobPosition?.level === 'number' && + typeof targetEmployee.jobPosition?.level === 'number' ? emp.jobPosition?.level > targetEmployee.jobPosition?.level - : emp.jobPosition?.name.includes("Müdür") || - emp.jobPosition?.name.includes("Manager")) - ); + : emp.jobPosition?.name.includes('Müdür') || + emp.jobPosition?.name.includes('Manager')), + ) return managers.map((emp) => ({ id: emp.id, name: emp.fullName, title: emp.jobPosition?.name, - department: - mockDepartments.find((d) => d.id === emp.departmantId)?.name || "", - type: "employee", - })); + department: mockDepartments.find((d) => d.id === emp.departmantId)?.name || '', + type: 'employee', + })) } case AssessorTypeEnum.Peer: { @@ -423,244 +380,221 @@ const Degree360Evaluation: React.FC = () => { (emp) => emp.id !== targetEmployeeId && emp.departmantId === targetEmployee.departmantId && - emp.jobPosition?.level === targetEmployee.jobPosition?.level - ); + emp.jobPosition?.level === targetEmployee.jobPosition?.level, + ) return peers.map((emp) => ({ id: emp.id, name: emp.fullName, title: emp.jobPosition?.name, - department: - mockDepartments.find((d) => d.id === emp.departmantId)?.name || "", - type: "employee", - })); + department: mockDepartments.find((d) => d.id === emp.departmantId)?.name || '', + type: 'employee', + })) } case AssessorTypeEnum.Subordinate: { const subordinates = mockEmployees.filter( (emp) => emp.departmantId === targetEmployee.departmantId && - (typeof emp.jobPosition?.level === "number" && - typeof targetEmployee.jobPosition?.level === "number" + (typeof emp.jobPosition?.level === 'number' && + typeof targetEmployee.jobPosition?.level === 'number' ? emp.jobPosition?.level < targetEmployee.jobPosition?.level - : !emp.jobPosition?.name.includes("Müdür") && - !emp.jobPosition?.name.includes("Manager")) - ); + : !emp.jobPosition?.name.includes('Müdür') && + !emp.jobPosition?.name.includes('Manager')), + ) return subordinates.map((emp) => ({ id: emp.id, name: emp.fullName, title: emp.jobPosition?.name, - department: - mockDepartments.find((d) => d.id === emp.departmantId)?.name || "", - type: "employee", - })); + department: mockDepartments.find((d) => d.id === emp.departmantId)?.name || '', + type: 'employee', + })) } case AssessorTypeEnum.Customer: { return mockBusinessParties.map((customer) => ({ id: customer.id, name: customer.name, - title: "Müşteri Temsilcisi", - department: "Müşteri", - type: "customer", - })); + title: 'Müşteri Temsilcisi', + department: 'Müşteri', + type: 'customer', + })) } case AssessorTypeEnum.External: { return [ { - id: "external", - name: "Dış Değerlendirici", - title: "Harici", - department: "Dış Paydaş", - type: "external", + id: 'external', + name: 'Dış Değerlendirici', + title: 'Harici', + department: 'Dış Paydaş', + type: 'external', }, - ]; + ] } case AssessorTypeEnum.HRUpperManagement: { const hrEmployees = mockEmployees.filter( (emp) => - emp.id !== targetEmployeeId && - (emp.departmantId === "hr" || emp.departmantId === "3") // HR departmanı - ); + emp.id !== targetEmployeeId && (emp.departmantId === 'hr' || emp.departmantId === '3'), // HR departmanı + ) return hrEmployees.map((emp) => ({ id: emp.id, name: emp.fullName, title: emp.jobPosition?.name, - department: - mockDepartments.find((d) => d.id === emp.departmantId)?.name || "", - type: "employee", - })); + department: mockDepartments.find((d) => d.id === emp.departmantId)?.name || '', + type: 'employee', + })) } case AssessorTypeEnum.OtherDepartment: { const otherDepartmentEmployees = mockEmployees.filter( - (emp) => - emp.id !== targetEmployeeId && - emp.departmantId !== targetEmployee.departmantId - ); + (emp) => emp.id !== targetEmployeeId && emp.departmantId !== targetEmployee.departmantId, + ) return otherDepartmentEmployees.map((emp) => ({ id: emp.id, name: emp.fullName, title: emp.jobPosition?.name, - department: - mockDepartments.find((d) => d.id === emp.departmantId)?.name || "", - type: "employee", - })); + department: mockDepartments.find((d) => d.id === emp.departmantId)?.name || '', + type: 'employee', + })) } default: - return []; + return [] } - }; + } // Değerlendiren bilgisini getiren fonksiyon const getEvaluatorInfo = () => { - if (evaluationEvaluator === "external") { - return externalEvaluatorName; + if (evaluationEvaluator === 'external') { + return externalEvaluatorName } if (selectedAssessorType === AssessorTypeEnum.Customer) { - const customer = mockBusinessParties.find( - (c) => c.id === selectedCustomerId - ); - return customer ? customer.name : "Müşteri Bulunamadı"; + const customer = mockBusinessParties.find((c) => c.id === selectedCustomerId) + return customer ? customer.name : 'Müşteri Bulunamadı' } - const employee = mockEmployees.find((e) => e.id === evaluationEvaluator); - return employee ? employee.fullName : "Çalışan Bulunamadı"; - }; + const employee = mockEmployees.find((e) => e.id === evaluationEvaluator) + return employee ? employee.fullName : 'Çalışan Bulunamadı' + } // Template'deki izin verilen assessor tiplerini getir const getAllowedAssessorTypes = () => { - if (!currentCampaignForEvaluation) return []; + if (!currentCampaignForEvaluation) return [] const template = mockEvaluation360Templates.find( - (t) => t.id === currentCampaignForEvaluation.templateId - ); + (t) => t.id === currentCampaignForEvaluation.templateId, + ) - return template?.assessorTypes || []; - }; + return template?.assessorTypes || [] + } // Helper function to get participants for a campaign from results const getCampaignParticipants = (campaignId: string) => { return mockEvaluation360Results .filter((result) => result.campaignId === campaignId) - .flatMap((result) => result.participants); - }; + .flatMap((result) => result.participants) + } // Filtered data const filteredCampaigns = mockEvaluation360.filter((campaign) => { - if (selectedStatus !== "all" && campaign.status !== selectedStatus) - return false; - if ( - selectedDepartment !== "all" && - campaign.departmentId !== selectedDepartment - ) - return false; - if (selectedEmployee !== "all") { - const participants = getCampaignParticipants(campaign.id); + if (selectedStatus !== 'all' && campaign.status !== selectedStatus) return false + if (selectedDepartment !== 'all' && campaign.departmentId !== selectedDepartment) return false + if (selectedEmployee !== 'all') { + const participants = getCampaignParticipants(campaign.id) const hasEmployee = participants.some( - (p) => - p.evaluatedEmployeeId === selectedEmployee || - p.evaluatorId === selectedEmployee - ); - if (!hasEmployee) return false; + (p) => p.evaluatedEmployeeId === selectedEmployee || p.evaluatorId === selectedEmployee, + ) + if (!hasEmployee) return false } - return true; - }); + return true + }) const filteredEmployeesByDepartment = mockEmployees.filter( - (emp) => - selectedDepartment === "all" || emp.departmantId === selectedDepartment - ); + (emp) => selectedDepartment === 'all' || emp.departmantId === selectedDepartment, + ) // Statistics const totalActiveCampaigns = mockEvaluation360.filter( - (c) => c.status === CampaignStatusEnum.Active - ).length; + (c) => c.status === CampaignStatusEnum.Active, + ).length - const allParticipants = mockEvaluation360Results.flatMap( - (result) => result.participants - ); + const allParticipants = mockEvaluation360Results.flatMap((result) => result.participants) const totalCompletedEvaluations = allParticipants.filter( - (p) => p.status === ParticipantStatusEnum.Completed - ).length; + (p) => p.status === ParticipantStatusEnum.Completed, + ).length const totalPendingEvaluations = allParticipants.filter( - (p) => - p.status === ParticipantStatusEnum.Invited || - p.status === ParticipantStatusEnum.Started - ).length; + (p) => p.status === ParticipantStatusEnum.Invited || p.status === ParticipantStatusEnum.Started, + ).length - const totalParticipants = allParticipants.length; + const totalParticipants = allParticipants.length // Results helper functions // Participant evaluation helper functions const handleViewEvaluationDetail = (result: { - resultId: string; - evaluatedEmployeeName: string; - evaluatorName: string; - campaignName: string; - overallScore: number; - scorePercentage: number; - evaluatedEmployeeId: string; - evaluatorId: string; - campaignId: string; - evaluatorType: AssessorTypeEnum; - status: ParticipantStatusEnum; - completedDate?: Date; + resultId: string + evaluatedEmployeeName: string + evaluatorName: string + campaignName: string + overallScore: number + scorePercentage: number + evaluatedEmployeeId: string + evaluatorId: string + campaignId: string + evaluatorType: AssessorTypeEnum + status: ParticipantStatusEnum + completedDate?: Date }) => { // Değerlendirme detaylarını görüntüle - console.log("Viewing evaluation detail:", result); - setSelectedResult(result); - setShowResultDetailModal(true); - }; + console.log('Viewing evaluation detail:', result) + setSelectedResult(result) + setShowResultDetailModal(true) + } const handleEditEvaluationDetail = (result: { - resultId: string; - evaluatedEmployeeName: string; - evaluatorName: string; - campaignName: string; - overallScore: number; - scorePercentage: number; - evaluatedEmployeeId: string; - evaluatorId: string; - campaignId: string; - evaluatorType: AssessorTypeEnum; - status: ParticipantStatusEnum; - completedDate?: Date; + resultId: string + evaluatedEmployeeName: string + evaluatorName: string + campaignName: string + overallScore: number + scorePercentage: number + evaluatedEmployeeId: string + evaluatorId: string + campaignId: string + evaluatorType: AssessorTypeEnum + status: ParticipantStatusEnum + completedDate?: Date }) => { // Değerlendirme detaylarını düzenle - console.log("Editing evaluation detail:", result); + console.log('Editing evaluation detail:', result) // Mevcut evaluation result'ını bul - const evaluationResult = mockEvaluation360Results.find( - (r) => r.id === result.resultId - ); + const evaluationResult = mockEvaluation360Results.find((r) => r.id === result.resultId) if (evaluationResult) { // Mevcut cevapları yükle - const currentResponses: Record = {}; + const currentResponses: Record = {} evaluationResult.participants.forEach((participant) => { participant.responses.forEach((response) => { - currentResponses[response.questionId] = response.responseValue; - }); - }); + currentResponses[response.questionId] = response.responseValue + }) + }) - setEditResponses(currentResponses); - setEditManagerComments(evaluationResult.managerComments || ""); - setEditHrComments(evaluationResult.hrComments || ""); - setEditResultStatus(evaluationResult.status); + setEditResponses(currentResponses) + setEditManagerComments(evaluationResult.managerComments || '') + setEditHrComments(evaluationResult.hrComments || '') + setEditResultStatus(evaluationResult.status) } - setSelectedResult(result); - setShowResultEditModal(true); - }; + setSelectedResult(result) + setShowResultEditModal(true) + } const getAssessorTypeLabel = (assessorType: AssessorTypeEnum): string => { - return getAssessorTypeText(assessorType); - }; + return getAssessorTypeText(assessorType) + } const getAllEvaluationParticipants = () => { // Tüm sonuçlardan participant verilerini al @@ -669,97 +603,82 @@ const Degree360Evaluation: React.FC = () => { ...participant, resultId: result.id, evaluatedEmployeeName: - mockEmployees.find((e) => e.id === participant.evaluatedEmployeeId) - ?.fullName || "Bilinmiyor", + mockEmployees.find((e) => e.id === participant.evaluatedEmployeeId)?.fullName || + 'Bilinmiyor', evaluatorName: - mockEmployees.find((e) => e.id === participant.evaluatorId) - ?.fullName || "Bilinmiyor", + mockEmployees.find((e) => e.id === participant.evaluatorId)?.fullName || 'Bilinmiyor', campaignName: - mockEvaluation360.find((c) => c.id === participant.campaignId) - ?.name || "Bilinmiyor", + mockEvaluation360.find((c) => c.id === participant.campaignId)?.name || 'Bilinmiyor', overallScore: result.overallScore, scorePercentage: result.scorePercentage, result: result, - })) - ); + })), + ) // Filtreleme işlemi return allParticipants.filter((participant) => { // Durum filtresi - if ( - selectedResultsStatus !== "all" && - participant.status !== selectedResultsStatus - ) { - return false; + if (selectedResultsStatus !== 'all' && participant.status !== selectedResultsStatus) { + return false } // Kampanya filtresi - if ( - selectedResultsCampaign !== "all" && - participant.campaignId !== selectedResultsCampaign - ) { - return false; + if (selectedResultsCampaign !== 'all' && participant.campaignId !== selectedResultsCampaign) { + return false } // Değerlendirilecek kişi filtresi if ( - selectedResultsEmployee !== "all" && + selectedResultsEmployee !== 'all' && participant.evaluatedEmployeeId !== selectedResultsEmployee ) { - return false; + return false } // Departman filtresi - if (selectedResultsDepartment !== "all") { + if (selectedResultsDepartment !== 'all') { const evaluatedEmployee = mockEmployees.find( - (e) => e.id === participant.evaluatedEmployeeId - ); - if ( - !evaluatedEmployee || - evaluatedEmployee.departmantId !== selectedResultsDepartment - ) { - return false; + (e) => e.id === participant.evaluatedEmployeeId, + ) + if (!evaluatedEmployee || evaluatedEmployee.departmantId !== selectedResultsDepartment) { + return false } } - return true; - }); - }; + return true + }) + } // Columns for campaigns table const campaignColumns: Column[] = [ { - key: "name", - header: "Değerlendirme Adı", + key: 'name', + header: 'Değerlendirme Adı', sortable: true, }, { - key: "departmentId", - header: "Departman", + key: 'departmentId', + header: 'Departman', render: (item: HrEvaluation360) => { - const department = mockDepartments.find( - (d) => d.id === item.departmentId - ); - return department?.name || "Tüm Departmanlar"; + const department = mockDepartments.find((d) => d.id === item.departmentId) + return department?.name || 'Tüm Departmanlar' }, }, { - key: "templateId", - header: "Şablon", + key: 'templateId', + header: 'Şablon', render: (item: HrEvaluation360) => { - const template = mockEvaluation360Templates.find( - (t) => t.id === item.templateId - ); - return template?.name || "Bilinmiyor"; + const template = mockEvaluation360Templates.find((t) => t.id === item.templateId) + return template?.name || 'Bilinmiyor' }, }, { - key: "status", - header: "Durum", + key: 'status', + header: 'Durum', render: (item: HrEvaluation360) => ( {getCampaignStatusText(item.status)} @@ -767,28 +686,26 @@ const Degree360Evaluation: React.FC = () => { ), }, { - key: "startDate", - header: "Başlangıç", - render: (item: HrEvaluation360) => - item.startDate.toLocaleDateString("tr-TR"), + key: 'startDate', + header: 'Başlangıç', + render: (item: HrEvaluation360) => item.startDate.toLocaleDateString('tr-TR'), }, { - key: "endDate", - header: "Bitiş", - render: (item: HrEvaluation360) => - item.endDate.toLocaleDateString("tr-TR"), + key: 'endDate', + header: 'Bitiş', + render: (item: HrEvaluation360) => item.endDate.toLocaleDateString('tr-TR'), }, { - key: "participants", - header: "Katılımcı", + key: 'participants', + header: 'Katılımcı', render: (item: HrEvaluation360) => { - const participants = getCampaignParticipants(item.id); - return `${participants.length} kişi`; + const participants = getCampaignParticipants(item.id) + return `${participants.length} kişi` }, }, { - key: "id", - header: "İşlemler", + key: 'id', + header: 'İşlemler', render: (item: HrEvaluation360) => (
), }, - ]; + ] return ( -
- {/* Header */} -
-
-

- 360° Değerlendirme Sistemi -

-

- Çok yönlü performans değerlendirme sistemi -

-
-
- - {/* Statistics Cards */} -
- - - - - - - -
- - {/* Tabs */} -
-
- + +
+ {/* Header */} +
+
+

360° Değerlendirme Sistemi

+

Çok yönlü performans değerlendirme sistemi

+
-
- {activeTab === "campaigns" && ( -
- {/* Filters and Actions */} -
-
- + {/* Statistics Cards */} +
+ - + - -
+ -
- - -
-
+ +
- {/* Campaigns Table */} - -
- )} + {/* Tabs */} +
+
+ +
- {activeTab === "results" && ( -
- {/* Results Filters */} -
-
- +
+ {activeTab === 'campaigns' && ( +
+ {/* Filters and Actions */} +
+
+ - - - - - -
-
- - {/* Results Summary */} - -
-
- - - - - - - - - - - - - - - {getAllEvaluationParticipants().map((result) => ( - - - - - - - - - - + -
- Değerlendirme Adı - - Değerlendirilecek Kişi - - Değerlendiren - - Toplam İlerleme - - Değerlendirme Durumu - - Toplam Puan - - Puan Yüzdesi - - İşlemler -
-
- - {result.campaignName} - - - {result.completedDate - ? new Date( - result.completedDate - ).toLocaleDateString("tr-TR") - : "-"} - -
-
- {result.evaluatedEmployeeName} - -
- - {result.evaluatorName} - - - {getAssessorTypeLabel(result.evaluatorType)} - -
-
-
-
-
-
- - {result.status === - ParticipantStatusEnum.Completed - ? 100 - : 50} - % - -
-
- - {getParticipantStatusText(result.status)} - - - {result.overallScore}/100 - - %{result.scorePercentage} - -
- - -
-
+ + + +
+ +
+ + +
+
+ + {/* Campaigns Table */} + +
+ )} + + {activeTab === 'results' && ( +
+ {/* Results Filters */} +
+
+ + + + + + + +
+
+ + {/* Results Summary */} + +
+
+ + + + + + + + + + + + + + + {getAllEvaluationParticipants().map((result) => ( + + + + + + + + + + + ))} + +
+ Değerlendirme Adı + + Değerlendirilecek Kişi + + Değerlendiren + + Toplam İlerleme + + Değerlendirme Durumu + + Toplam Puan + + Puan Yüzdesi + + İşlemler +
+
+ + {result.campaignName} + + + {result.completedDate + ? new Date(result.completedDate).toLocaleDateString('tr-TR') + : '-'} + +
+
+ {result.evaluatedEmployeeName} + +
+ + {result.evaluatorName} + + + {getAssessorTypeLabel(result.evaluatorType)} + +
+
+
+
+
+
+ + {result.status === ParticipantStatusEnum.Completed ? 100 : 50}% + +
+
+ + {getParticipantStatusText(result.status)} + + + {result.overallScore}/100 + + %{result.scorePercentage} + +
+ + +
+
+
-
- )} + )} +
@@ -1171,9 +1054,7 @@ const Degree360Evaluation: React.FC = () => {

- {selectedCampaign - ? "Değerlendirme Düzenle" - : "Yeni Değerlendirme"} + {selectedCampaign ? 'Değerlendirme Düzenle' : 'Yeni Değerlendirme'}

- +