260322:1648 Correct Coresspondence / Doing RFA / Correct CI
This commit is contained in:
@@ -16,12 +16,7 @@ interface CanProps {
|
||||
// Common use case: <Can permission="x">
|
||||
}
|
||||
|
||||
export function Can({
|
||||
permission,
|
||||
role,
|
||||
children,
|
||||
fallback = null,
|
||||
}: CanProps) {
|
||||
export function Can({ permission, role, children, fallback = null }: CanProps) {
|
||||
const { hasPermission, hasRole } = useAuthStore();
|
||||
|
||||
let allowed = true;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"use client";
|
||||
'use client';
|
||||
|
||||
import {
|
||||
AlertDialog,
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
} from '@/components/ui/alert-dialog';
|
||||
|
||||
interface ConfirmDialogProps {
|
||||
open: boolean;
|
||||
@@ -27,8 +27,8 @@ export function ConfirmDialog({
|
||||
title,
|
||||
description,
|
||||
onConfirm,
|
||||
confirmText = "Confirm",
|
||||
cancelText = "Cancel",
|
||||
confirmText = 'Confirm',
|
||||
cancelText = 'Cancel',
|
||||
}: ConfirmDialogProps) {
|
||||
return (
|
||||
<AlertDialog open={open} onOpenChange={onOpenChange}>
|
||||
@@ -39,9 +39,7 @@ export function ConfirmDialog({
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{cancelText}</AlertDialogCancel>
|
||||
<AlertDialogAction onClick={onConfirm}>
|
||||
{confirmText}
|
||||
</AlertDialogAction>
|
||||
<AlertDialogAction onClick={onConfirm}>{confirmText}</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ChevronLeft, ChevronRight } from "lucide-react";
|
||||
import { useRouter, useSearchParams, usePathname } from "next/navigation";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
||||
import { useRouter, useSearchParams, usePathname } from 'next/navigation';
|
||||
|
||||
interface PaginationProps {
|
||||
currentPage: number;
|
||||
@@ -10,18 +10,14 @@ interface PaginationProps {
|
||||
total: number;
|
||||
}
|
||||
|
||||
export function Pagination({
|
||||
currentPage,
|
||||
totalPages,
|
||||
total,
|
||||
}: PaginationProps) {
|
||||
export function Pagination({ currentPage, totalPages, total }: PaginationProps) {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
const createPageURL = (pageNumber: number) => {
|
||||
const params = new URLSearchParams(searchParams);
|
||||
params.set("page", pageNumber.toString());
|
||||
params.set('page', pageNumber.toString());
|
||||
return `${pathname}?${params.toString()}`;
|
||||
};
|
||||
|
||||
@@ -50,7 +46,7 @@ export function Pagination({
|
||||
return (
|
||||
<Button
|
||||
key={pageNum}
|
||||
variant={pageNum === currentPage ? "default" : "outline"}
|
||||
variant={pageNum === currentPage ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
onClick={() => router.push(createPageURL(pageNum))}
|
||||
>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface StatusBadgeProps {
|
||||
status: string;
|
||||
@@ -7,56 +7,53 @@ interface StatusBadgeProps {
|
||||
}
|
||||
|
||||
const statusConfig: Record<string, { label: string; variant: string }> = {
|
||||
DRAFT: { label: "Draft", variant: "secondary" },
|
||||
PENDING: { label: "Pending", variant: "warning" }, // Note: Shadcn/UI might not have 'warning' variant by default, may need custom CSS or use 'secondary'
|
||||
IN_REVIEW: { label: "In Review", variant: "default" }, // Using 'default' (primary) for In Review
|
||||
APPROVED: { label: "Approved", variant: "success" }, // Note: 'success' might need custom CSS
|
||||
REJECTED: { label: "Rejected", variant: "destructive" },
|
||||
CLOSED: { label: "Closed", variant: "outline" },
|
||||
DRAFT: { label: 'Draft', variant: 'secondary' },
|
||||
PENDING: { label: 'Pending', variant: 'warning' }, // Note: Shadcn/UI might not have 'warning' variant by default, may need custom CSS or use 'secondary'
|
||||
IN_REVIEW: { label: 'In Review', variant: 'default' }, // Using 'default' (primary) for In Review
|
||||
APPROVED: { label: 'Approved', variant: 'success' }, // Note: 'success' might need custom CSS
|
||||
REJECTED: { label: 'Rejected', variant: 'destructive' },
|
||||
CLOSED: { label: 'Closed', variant: 'outline' },
|
||||
};
|
||||
|
||||
// Fallback for unknown statuses
|
||||
const defaultStatus = { label: "Unknown", variant: "outline" };
|
||||
const _defaultStatus = { label: 'Unknown', variant: 'outline' };
|
||||
|
||||
export function StatusBadge({ status, className }: StatusBadgeProps) {
|
||||
const config = statusConfig[status] || { label: status, variant: "default" };
|
||||
const config = statusConfig[status] || { label: status, variant: 'default' };
|
||||
|
||||
// Mapping custom variants to Shadcn Badge variants if needed
|
||||
// For now, we'll assume standard variants or rely on className overrides for colors
|
||||
let badgeVariant: "default" | "secondary" | "destructive" | "outline" = "default";
|
||||
let customClass = "";
|
||||
let badgeVariant: 'default' | 'secondary' | 'destructive' | 'outline' = 'default';
|
||||
let customClass = '';
|
||||
|
||||
switch (config.variant) {
|
||||
case "secondary":
|
||||
badgeVariant = "secondary";
|
||||
case 'secondary':
|
||||
badgeVariant = 'secondary';
|
||||
break;
|
||||
case "destructive":
|
||||
badgeVariant = "destructive";
|
||||
case 'destructive':
|
||||
badgeVariant = 'destructive';
|
||||
break;
|
||||
case "outline":
|
||||
badgeVariant = "outline";
|
||||
case 'outline':
|
||||
badgeVariant = 'outline';
|
||||
break;
|
||||
case "warning":
|
||||
badgeVariant = "secondary"; // Fallback
|
||||
customClass = "bg-yellow-500 hover:bg-yellow-600 text-white";
|
||||
case 'warning':
|
||||
badgeVariant = 'secondary'; // Fallback
|
||||
customClass = 'bg-yellow-500 hover:bg-yellow-600 text-white';
|
||||
break;
|
||||
case "success":
|
||||
badgeVariant = "default"; // Fallback
|
||||
customClass = "bg-green-500 hover:bg-green-600 text-white";
|
||||
case 'success':
|
||||
badgeVariant = 'default'; // Fallback
|
||||
customClass = 'bg-green-500 hover:bg-green-600 text-white';
|
||||
break;
|
||||
case "info":
|
||||
badgeVariant = "default";
|
||||
customClass = "bg-blue-500 hover:bg-blue-600 text-white";
|
||||
case 'info':
|
||||
badgeVariant = 'default';
|
||||
customClass = 'bg-blue-500 hover:bg-blue-600 text-white';
|
||||
break;
|
||||
default:
|
||||
badgeVariant = "default";
|
||||
badgeVariant = 'default';
|
||||
}
|
||||
|
||||
return (
|
||||
<Badge
|
||||
variant={badgeVariant}
|
||||
className={cn("uppercase", customClass, className)}
|
||||
>
|
||||
<Badge variant={badgeVariant} className={cn('uppercase', customClass, className)}>
|
||||
{config.label}
|
||||
</Badge>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user