headplane/app/routes/acls/components/error.tsx

46 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-12-31 10:30:14 +05:30
import { AlertIcon } from '@primer/octicons-react';
2025-04-03 03:00:11 -04:00
import React from 'react';
2024-12-31 10:30:14 +05:30
import Card from '~/components/Card';
2025-04-03 03:00:11 -04:00
interface NoticeViewProps {
title: string;
children: React.ReactNode;
}
2025-04-03 03:00:11 -04:00
export function NoticeView({ children, title }: NoticeViewProps) {
return (
<Card variant="flat" className="max-w-2xl my-8">
<div className="flex items-center justify-between">
<Card.Title className="text-xl mb-0">{title}</Card.Title>
<AlertIcon className="w-8 h-8 text-yellow-500" />
</div>
<Card.Text className="mt-4">{children}</Card.Text>
</Card>
);
}
interface ErrorViewProps {
children: string;
}
export function ErrorView({ children }: ErrorViewProps) {
const [title, ...rest] = children.split(':');
const formattedMessage = rest.length > 0 ? rest.join(':').trim() : children;
return (
2025-04-03 03:00:11 -04:00
<Card variant="flat" className="max-w-2xl mb-4">
<div className="flex items-center justify-between">
2025-04-03 03:00:11 -04:00
<Card.Title className="text-xl mb-0">
{title.trim() ?? 'Error'}
</Card.Title>
2024-12-31 10:30:14 +05:30
<AlertIcon className="w-8 h-8 text-red-500" />
</div>
<Card.Text className="mt-4">
2025-04-03 03:00:11 -04:00
Could not apply changes to the ACL policy:
<br />
2025-04-03 03:00:11 -04:00
<span className="font-mono">{formattedMessage}</span>
</Card.Text>
</Card>
2024-12-31 10:30:14 +05:30
);
}