restore: old src/ components, subscriptions, audit-log, client detail pages; fix tsconfig @/* paths; merge api.ts
This commit is contained in:
31
src/components/ui/Badge.tsx
Normal file
31
src/components/ui/Badge.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface BadgeProps {
|
||||
children: React.ReactNode;
|
||||
variant?: "default" | "success" | "warning" | "danger" | "info" | "muted" | "purple";
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const variantClasses: Record<string, string> = {
|
||||
default: "bg-blue-100 text-blue-800",
|
||||
success: "bg-green-100 text-green-800",
|
||||
warning: "bg-amber-100 text-amber-800",
|
||||
danger: "bg-red-100 text-red-800",
|
||||
info: "bg-sky-100 text-sky-800",
|
||||
muted: "bg-gray-100 text-gray-700",
|
||||
purple: "bg-purple-100 text-purple-800",
|
||||
};
|
||||
|
||||
export function Badge({ children, variant = "default", className }: BadgeProps) {
|
||||
return (
|
||||
<span
|
||||
className={cn(
|
||||
"inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",
|
||||
variantClasses[variant],
|
||||
className
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
50
src/components/ui/Button.tsx
Normal file
50
src/components/ui/Button.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
import { ButtonHTMLAttributes, forwardRef } from "react";
|
||||
|
||||
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
||||
variant?: "primary" | "secondary" | "danger" | "ghost" | "outline";
|
||||
size?: "sm" | "md" | "lg";
|
||||
isLoading?: boolean;
|
||||
}
|
||||
|
||||
const variantClasses: Record<string, string> = {
|
||||
primary: "bg-blue-600 hover:bg-blue-700 text-white border-transparent",
|
||||
secondary: "bg-gray-100 hover:bg-gray-200 text-gray-700 border-transparent",
|
||||
danger: "bg-red-600 hover:bg-red-700 text-white border-transparent",
|
||||
ghost: "bg-transparent hover:bg-gray-100 text-gray-700 border-transparent",
|
||||
outline: "bg-white hover:bg-gray-50 text-gray-700 border-gray-300",
|
||||
};
|
||||
|
||||
const sizeClasses: Record<string, string> = {
|
||||
sm: "px-3 py-1.5 text-sm",
|
||||
md: "px-4 py-2 text-sm",
|
||||
lg: "px-6 py-3 text-base",
|
||||
};
|
||||
|
||||
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
({ variant = "primary", size = "md", isLoading, className, children, disabled, ...props }, ref) => {
|
||||
return (
|
||||
<button
|
||||
ref={ref}
|
||||
disabled={disabled || isLoading}
|
||||
className={cn(
|
||||
"inline-flex items-center justify-center gap-2 rounded-lg border font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 disabled:opacity-50 disabled:cursor-not-allowed",
|
||||
variantClasses[variant],
|
||||
sizeClasses[size],
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{isLoading && (
|
||||
<svg className="animate-spin h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
||||
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
||||
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" />
|
||||
</svg>
|
||||
)}
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
Button.displayName = "Button";
|
||||
34
src/components/ui/Card.tsx
Normal file
34
src/components/ui/Card.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface CardProps {
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
export function Card({ children, className, onClick }: CardProps) {
|
||||
return (
|
||||
<div
|
||||
className={cn("rounded-xl border border-gray-200 bg-white shadow-sm", className)}
|
||||
onClick={onClick}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function CardHeader({ children, className }: CardProps) {
|
||||
return (
|
||||
<div className={cn("flex items-center justify-between border-b border-gray-100 px-6 py-4", className)}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function CardTitle({ children, className }: CardProps) {
|
||||
return <h3 className={cn("text-base font-semibold text-gray-900", className)}>{children}</h3>;
|
||||
}
|
||||
|
||||
export function CardContent({ children, className }: CardProps) {
|
||||
return <div className={cn("px-6 py-4", className)}>{children}</div>;
|
||||
}
|
||||
39
src/components/ui/Input.tsx
Normal file
39
src/components/ui/Input.tsx
Normal file
@@ -0,0 +1,39 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
import { InputHTMLAttributes, forwardRef } from "react";
|
||||
|
||||
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
||||
label?: string;
|
||||
error?: string;
|
||||
hint?: string;
|
||||
}
|
||||
|
||||
export const Input = forwardRef<HTMLInputElement, InputProps>(
|
||||
({ label, error, hint, className, id, ...props }, ref) => {
|
||||
const inputId = id || label?.toLowerCase().replace(/\s+/g, "-");
|
||||
return (
|
||||
<div className="flex flex-col gap-1.5">
|
||||
{label && (
|
||||
<label htmlFor={inputId} className="text-sm font-medium text-gray-700">
|
||||
{label}
|
||||
</label>
|
||||
)}
|
||||
<input
|
||||
ref={ref}
|
||||
id={inputId}
|
||||
className={cn(
|
||||
"block w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 placeholder-gray-400",
|
||||
"focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500",
|
||||
"disabled:bg-gray-50 disabled:cursor-not-allowed",
|
||||
error && "border-red-500 focus:border-red-500 focus:ring-red-500",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
{error && <p className="text-xs text-red-600">{error}</p>}
|
||||
{hint && !error && <p className="text-xs text-gray-500">{hint}</p>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
Input.displayName = "Input";
|
||||
48
src/components/ui/Modal.tsx
Normal file
48
src/components/ui/Modal.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { X } from "lucide-react";
|
||||
|
||||
interface ModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
title: string;
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function Modal({ isOpen, onClose, title, children, className }: ModalProps) {
|
||||
const overlayRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const handleKey = (e: KeyboardEvent) => {
|
||||
if (e.key === "Escape") onClose();
|
||||
};
|
||||
if (isOpen) document.addEventListener("keydown", handleKey);
|
||||
return () => document.removeEventListener("keydown", handleKey);
|
||||
}, [isOpen, onClose]);
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={overlayRef}
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4"
|
||||
onClick={(e) => e.target === overlayRef.current && onClose()}
|
||||
>
|
||||
<div className={cn("w-full max-w-lg rounded-xl bg-white shadow-xl", className)}>
|
||||
<div className="flex items-center justify-between border-b border-gray-100 px-6 py-4">
|
||||
<h3 className="text-base font-semibold text-gray-900">{title}</h3>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="rounded-lg p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600"
|
||||
>
|
||||
<X className="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="px-6 py-4">{children}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
58
src/components/ui/Table.tsx
Normal file
58
src/components/ui/Table.tsx
Normal file
@@ -0,0 +1,58 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface TableProps {
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function Table({ children, className }: TableProps) {
|
||||
return (
|
||||
<div className="overflow-x-auto rounded-xl border border-gray-200 bg-white">
|
||||
<table className={cn("w-full text-sm", className)}>
|
||||
{children}
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function TableHead({ children }: TableProps) {
|
||||
return <thead className="bg-gray-50 text-xs uppercase text-gray-500">{children}</thead>;
|
||||
}
|
||||
|
||||
export function TableBody({ children }: TableProps) {
|
||||
return <tbody className="divide-y divide-gray-100">{children}</tbody>;
|
||||
}
|
||||
|
||||
export function TableRow({ children, className, onClick }: TableProps & { onClick?: () => void }) {
|
||||
return (
|
||||
<tr
|
||||
className={cn("transition-colors", onClick && "cursor-pointer hover:bg-blue-50", className)}
|
||||
onClick={onClick}
|
||||
>
|
||||
{children}
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
export function Th({ children, className }: TableProps) {
|
||||
return <th className={cn("px-4 py-3 text-left font-medium", className)}>{children}</th>;
|
||||
}
|
||||
|
||||
export function Td({ children, className }: TableProps) {
|
||||
return <td className={cn("px-4 py-3 text-gray-700", className)}>{children}</td>;
|
||||
}
|
||||
|
||||
export function EmptyState({ message = "No data yet" }: { message?: string }) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={100} className="py-12 text-center text-gray-400">
|
||||
<div className="flex flex-col items-center gap-2">
|
||||
<svg className="h-12 w-12 text-gray-300" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4" />
|
||||
</svg>
|
||||
<span className="text-sm">{message}</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user