import React, { useState } from "react"; import { FwToggle, FwButton, FwModal,…
- User
import React, { useState } from "react"; import { FwToggle, FwButton, FwModal, FwModalTitle, FwModalContent, FwModalFooter, } from "@freshworks/crayons/react"; import { getAgents } from '../common';
// Function to calculate the time since the rule was last modified const calculateLastModified = (updated_at) => { const updatedDate = new Date(updated_at); const currentDate = new Date(); const diffInMilliseconds = currentDate - updatedDate; const seconds = Math.floor(diffInMilliseconds / 1000); const minutes = Math.floor(seconds / 60); const hours = Math.floor(minutes / 60); const days = Math.floor(hours / 24); const months = Math.floor(days / 30); const years = Math.floor(days / 365);
if (years > 0) return years === 1 ? "a year ago" :
${years} years ago; if (months > 0) return months === 1 ? "a month ago" :${months} months ago; if (days > 0) return${days} day${days > 1 ? "s" : ""} ago; if (hours > 0) return${hours} hour${hours > 1 ? "s" : ""} ago; if (minutes > 0) return${minutes} minute${minutes > 1 ? "s" : ""} ago; return "Just now"; };const AutomationCard = ({ rule = {}, index, isFirstInGroup = false, onDelete, agent, activeTab }) => { const { id, name = "Default Rule Name", description = "Default Rule Description", updated_at = "N/A", last_updated_by = "Unknown", affected_tickets_count = "--", active = false, position = index + 1,
automation_type_id } = rule;const [menuOpen, setMenuOpen] = useState(false); const [modalOpen, setModalOpen] = useState(false);
// // Function called to show the delete confirmation modal // const handleDeleteClick = () => { // console.log("Choosed Automation Rule ID:", id); // console.log("Automation Type ID:", automation_type_id);
// };
const handleConfirmDelete = () => { setModalOpen(false); onDelete(rule); // Pass full rule object, not just ID };
return ( <div className="fw-card-1 fw-flex fw-flex-column" style={{ overflow: "hidden", border: "0.5px solid #ddd", backgroundColor: isFirstInGroup ? "#fff" : "#e5f2fd", }} > <section className="fw-flex-grow fw-px-16 fw-flex fw-flex-row" style={{ justifyContent: "space-between", alignItems: "center" }} > <div style={{ paddingLeft: "16px" }}> {position}. {name} {description}
<div style={{ display: "flex", alignItems: "center", gap: "8px", padding: "8px 16px", position: "relative", }} > <FwToggle size="medium" checked={active} /> <div style={{ position: "relative" }}> {menuOpen && ( <div className="dropdown-menu" style={{ position: "absolute", marginTop: "30px", top: "50%", right: "40px", transform: "translateY(-50%)", background: "white", boxShadow: "0px 4px 6px rgba(0,0,0,0.1)", borderRadius: "5px", padding: "8px 0", width: "120px", zIndex: 10, }} > <div style={{ padding: "8px 16px", cursor: "pointer", textAlign: "left", }} onClick={() => alert("Edit clicked")} > Edit </div> <div style={{ padding: "8px 16px", cursor: "pointer", color: "red", textAlign: "left", }} onClick={() => { handleConfirmDelete(); }} > Delete </div> </div> )} <div className="ember-basic-dropdown-trigger" role="button" tabIndex="0" onClick={() => setMenuOpen(!menuOpen)} > <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" className="app-icon dropdown-toggle" > <path fillRule="evenodd" d="M12 5c-1.38 0-2.5-1.12-2.5-2.5S10.62 0 12 0s2.5 1.12 2.5 2.5S13.38 5 12 5zM12 14c-1.38 0-2.5-1.12-2.5-2.5S10.62 9 12 9s2.5 1.12 2.5 2.5S13.38 14 12 14zM12 24c-1.38 0-2.5-1.12-2.5-2.5S10.62 19 12 19s2.5 1.12 2.5 2.5S13.38 24 12 24z" ></path> </svg> </div> </div> </div> </section> <section className="fw-type-xs fw-flex fw-flex-row fw-items-center options" style={{ width: "100%", background: "#f5f5f5", padding: "10px 16px", borderRadius: "5px", }} > <div style={{ display: "flex", alignItems: "center", justifyContent: "space-evenly", width: "100%", fontSize: "14px", color: "#666", textAlign: "center", }} > <span> Last Modified: <strong>{calculateLastModified(updated_at)}</strong> </span> <span>|</span> <span>By: {agent.map(e => { if (e.value === last_updated_by) return e.text })}</span> <span>|</span> <span> Impacted tickets (Last 7 days): {affected_tickets_count} </span> </div> </section> </div> - Assistant
- User
- Assistant
- User
- Assistant
- User
summary is not showing please fix that
- Assistant
- User
not working at all
- Assistant