diff --git a/src/components/ApprovalStatusWidget.tsx b/src/components/ApprovalStatusWidget.tsx new file mode 100644 index 0000000..45d7ba5 --- /dev/null +++ b/src/components/ApprovalStatusWidget.tsx @@ -0,0 +1,110 @@ +import { ClockIcon, CheckCircleIcon, XCircleIcon } from "./icons/StatusIcons"; + +interface ApprovalRole { + id: string; + name: string; + avatar?: string; +} + +interface ApprovalStatusWidgetProps { + required: ApprovalRole[]; + given: ApprovalRole[]; + pending: ApprovalRole[]; +} + +export function ApprovalStatusWidget({ + required, + given, + pending, +}: ApprovalStatusWidgetProps) { + const getInitial = (name: string): string => { + return name.charAt(0).toUpperCase(); + }; + + const renderRole = ( + role: ApprovalRole, + status: "pending" | "approved" | "rejected" + ) => { + const statusConfig = { + pending: { icon: ClockIcon, label: "Pending" }, + approved: { icon: CheckCircleIcon, label: "Approved" }, + rejected: { icon: XCircleIcon, label: "Rejected" }, + }; + + const { icon: IconComponent, label } = statusConfig[status]; + + return ( +
+
+ {role.avatar ? ( + {role.name} + ) : ( +
+ {getInitial(role.name)} +
+ )} +
+ +
+

{role.name}

+
+ +
+ + {label} +
+
+ ); + }; + + return ( +
+ {required.length > 0 && ( +
+

+ Required Approvals +

+
+ {required.map((role) => renderRole(role, "approved"))} +
+
+ )} + + {given.length > 0 && ( +
+

+ Given Approvals +

+
+ {given.map((role) => renderRole(role, "approved"))} +
+
+ )} + + {pending.length > 0 && ( +
+

+ Pending Approvals +

+
+ {pending.map((role) => renderRole(role, "pending"))} +
+
+ )} + + {required.length === 0 && given.length === 0 && pending.length === 0 && ( +
+

No approvals to display

+
+ )} +
+ ); +}