feedbackBadges.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import type { ReactNode } from "react";
  2. import { AlertCircle } from "lucide-react";
  3. import type { FeedbackTicketStatus } from "@zcode/shared";
  4. import { formatFeedbackStatusLabel, STATUS_META } from "@/feedback/feedbackMeta.js";
  5. import { cn } from "@/components/lib/utils.js";
  6. import { useZCodeIntl } from "@/i18n/IntlProvider.js";
  7. export function StatusIndicator({
  8. status,
  9. withDot = true,
  10. children,
  11. className,
  12. }: {
  13. status: FeedbackTicketStatus;
  14. withDot?: boolean;
  15. children?: ReactNode;
  16. className?: string;
  17. }) {
  18. const meta = STATUS_META[status];
  19. const { intl } = useZCodeIntl();
  20. return (
  21. <span
  22. className={cn(
  23. "inline-flex items-center gap-1 text-ui-base font-medium",
  24. meta.className,
  25. className,
  26. )}
  27. >
  28. {withDot ? <span className={cn("size-1.5 rounded-full", meta.dot)} /> : null}
  29. {children ?? formatFeedbackStatusLabel(status, intl.formatMessage)}
  30. </span>
  31. );
  32. }
  33. export function FeedbackErrorTip({ message }: { message: string }) {
  34. return (
  35. <div
  36. className="flex items-start gap-2 rounded-xl border border-red-500/25 bg-red-500/10 px-3 py-2 text-ui-base text-red-300"
  37. role="alert"
  38. >
  39. <AlertCircle className="mt-0.5 size-3.5 shrink-0 text-red-400" />
  40. <span className="break-words leading-relaxed">{message}</span>
  41. </div>
  42. );
  43. }