All files / components/accounts ViewAccountDialog.tsx

83.33% Statements 5/6
100% Branches 2/2
66.66% Functions 2/3
80% Lines 4/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80                                            43x   1x 1x     1x                                                                                                      
/**
 * View account dialog component
 * Displays account details in read-only mode
 */
 
import { AppDialog } from '@/components/common/AppDialog';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
import { Label } from '@/components/ui/label';
import type { AccountListItem } from '@/services/accounts.service';
 
interface ViewAccountDialogProps {
    open: boolean;
    onOpenChange: (open: boolean) => void;
    account: AccountListItem | null;
}
 
export default function ViewAccountDialog({
    open,
    onOpenChange,
    account,
}: ViewAccountDialogProps) {
    if (!account) return null;
 
    const formatDate = (dateString: string) => {
        return new Date(dateString).toLocaleString();
    };
 
    return (
        <AppDialog
            open={open}
            onOpenChange={onOpenChange}
            title="Account Details"
            description={`Detailed information for account ${account.account_code}`}
            className="max-w-md"
            footer={
                <Button variant="outline" onClick={() => onOpenChange(false)}>
                    Close
                </Button>
            }
        >
            <div className="space-y-4">
                <div className="grid grid-cols-2 gap-4">
                    <div className="space-y-1">
                        <Label className="text-muted-foreground text-xs uppercase">Account Code</Label>
                        <div className="font-mono font-medium">{account.account_code}</div>
                    </div>
                    <div className="space-y-1">
                        <Label className="text-muted-foreground text-xs uppercase">Status</Label>
                        <div>
                            <Badge variant="default">{account.status}</Badge>
                        </div>
                    </div>
                </div>
 
                <div className="space-y-1">
                    <Label className="text-muted-foreground text-xs uppercase">Name</Label>
                    <div className="text-base font-semibold">{account.name}</div>
                </div>
 
                <div className="space-y-1">
                    <Label className="text-muted-foreground text-xs uppercase">Slug</Label>
                    <div className="text-sm">{account.slug}</div>
                </div>
 
                <div className="grid grid-cols-2 gap-4">
                    <div className="space-y-1">
                        <Label className="text-muted-foreground text-xs uppercase">User Count</Label>
                        <div className="text-sm font-medium">{account.user_count}</div>
                    </div>
                    <div className="space-y-1">
                        <Label className="text-muted-foreground text-xs uppercase">Created At</Label>
                        <div className="text-sm">{formatDate(account.created_at)}</div>
                    </div>
                </div>
            </div>
        </AppDialog>
    );
}