essential forum code
This commit is contained in:
31
frontend/src/components/PostStatusBadge.tsx
Normal file
31
frontend/src/components/PostStatusBadge.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import React from 'react';
|
||||
|
||||
interface PostStatusBadgeProps {
|
||||
status: "open" | "solved" | "closed";
|
||||
}
|
||||
|
||||
const PostStatusBadge: React.FC<PostStatusBadgeProps> = ({ status }) => {
|
||||
const getStatusConfig = (stat: string) => {
|
||||
switch (stat) {
|
||||
case 'open':
|
||||
return { label: 'Open', color: 'success', icon: 'bi-circle' };
|
||||
case 'solved':
|
||||
return { label: 'Solved', color: 'info', icon: 'bi-check-circle' };
|
||||
case 'closed':
|
||||
return { label: 'Closed', color: 'secondary', icon: 'bi-x-circle' };
|
||||
default:
|
||||
return { label: status, color: 'secondary', icon: 'bi-circle' };
|
||||
}
|
||||
};
|
||||
|
||||
const config = getStatusConfig(status);
|
||||
|
||||
return (
|
||||
<span className={`badge bg-${config.color}`}>
|
||||
<i className={`bi ${config.icon} me-1`}></i>
|
||||
{config.label}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
export default PostStatusBadge;
|
||||
Reference in New Issue
Block a user