import React, { useState } from "react"; import { FaTimes, FaSave, FaUser, FaUsers } from "react-icons/fa"; import { PmFaultNotification } from "../../../types/pm"; import { mockEmployees } from "../../../mocks/mockEmployees"; import { mockMaintenanceTeams } from "../../../mocks/mockMaintenanceTeams"; interface AssignNotificationModalProps { isOpen: boolean; onClose: () => void; onSave: (assignments: { notificationIds: string[]; assignedTo?: string; teamId?: string; }) => void; notifications: PmFaultNotification[]; } const AssignNotificationModal: React.FC = ({ isOpen, onClose, onSave, notifications, }) => { const [assignmentType, setAssignmentType] = useState<"person" | "team">( "person" ); const [assignedTo, setAssignedTo] = useState(""); const [teamId, setTeamId] = useState(""); const [errors, setErrors] = useState>({}); if (!isOpen || notifications.length === 0) return null; const validateForm = () => { const newErrors: Record = {}; if (assignmentType === "person" && !assignedTo) { newErrors.assignedTo = "Kişi seçimi gerekli"; } if (assignmentType === "team" && !teamId) { newErrors.teamId = "Ekip seçimi gerekli"; } setErrors(newErrors); return Object.keys(newErrors).length === 0; }; const handleSave = () => { if (validateForm()) { const assignmentData = { notificationIds: notifications.map((n) => n.id), ...(assignmentType === "person" ? { assignedTo } : { teamId }), }; onSave(assignmentData); onClose(); // Reset form setAssignmentType("person"); setAssignedTo(""); setTeamId(""); setErrors({}); } }; return (
{/* Header */}

Atama Yap

{/* Content */}
{/* Notification Summary */}

Seçili Arıza Bildirimleri ({notifications.length})

{notifications.map((notification) => (
{notification.notificationCode} {" - "} {notification.title} {" ("} {notification.workCenter.code} {")"}
))}
{/* Assignment Type */}
{/* Person Assignment */} {assignmentType === "person" && (
{errors.assignedTo && (

{errors.assignedTo}

)}
)} {/* Team Assignment */} {assignmentType === "team" && (
{errors.teamId && (

{errors.teamId}

)}
)} {/* Assignment Preview */} {(assignedTo || teamId) && (

Atama Özeti

{notifications.length} arıza bildirimi{" "} {assignmentType === "person" ? ( <> { mockEmployees.find( (emp) => emp.fullName === assignedTo )?.fullName } kişisine atanacak ) : ( <> { mockMaintenanceTeams.find( (team) => team.id === teamId )?.name } ekibine atanacak )}

)}
{/* Footer */}
); }; export default AssignNotificationModal;