diff --git a/dashboard/src/components/copy-button/index.tsx b/dashboard/src/components/copy-button/index.tsx index a26fb2a..460a5b9 100644 --- a/dashboard/src/components/copy-button/index.tsx +++ b/dashboard/src/components/copy-button/index.tsx @@ -1,8 +1,8 @@ import { - Button, - Tooltip, - TooltipContent, - TooltipTrigger, + Button, + Tooltip, + TooltipContent, + TooltipTrigger, } from "@marzneshin/components"; import CopyToClipboard from "react-copy-to-clipboard"; import { useEffect, useState } from "react"; @@ -12,78 +12,70 @@ import { toast } from "sonner"; import { cn } from "@marzneshin/utils"; interface CopyToClipboardButtonProps { - text: string; - disabled?: boolean; - successMessage: string; - copyIcon?: LucideIcon; - copyLabel?: string; - errorLabel?: string; - className?: string; - tooltipMsg?: string; + text: string; + disabled?: boolean; + successMessage: string; + copyIcon?: LucideIcon; + copyLabel?: string; + errorLabel?: string; + className?: string; + tooltipMsg?: string; } export const CopyToClipboardButton: React.FC = ({ - text, - disabled = false, - successMessage, - copyIcon, - copyLabel, - errorLabel, - className, - tooltipMsg, + text, + disabled = false, + successMessage, + copyIcon, + copyLabel, + errorLabel, + className, + tooltipMsg, }) => { - const { t } = useTranslation(); - const [copied, setCopied] = useState(false); - const [healthy, setHealthy] = useState(false); + const { t } = useTranslation(); + const [copied, setCopied] = useState(false); + const [healthy, setHealthy] = useState(false); - useEffect(() => { - if (copied) { - toast.success(t(successMessage)); - setTimeout(() => { - setCopied(false); - }, 1000); - } - }, [copied, successMessage, t]); + useEffect(() => { + if (copied) { + toast.success(t(successMessage)); + setTimeout(() => { + setCopied(false); + }, 1000); + } + }, [copied, successMessage, t]); - useEffect(() => { - setHealthy(text !== ""); - }, [text]); + useEffect(() => { + setHealthy(text !== ""); + }, [text]); - const handleClick = () => { - if (!disabled) { - setCopied(true); - } - }; + const handleClick = () => { + if (!disabled) { + setCopied(true); + } + }; - const tooltip = tooltipMsg ? tooltipMsg : copyLabel ? copyLabel : undefined; + const tooltip = tooltipMsg ? tooltipMsg : copyLabel ? copyLabel : undefined; - const Icon = copied - ? CopyCheck - : healthy - ? copyIcon - ? copyIcon - : ClipboardCopy - : CopyX; - const isWithLabel = successMessage && copyLabel && errorLabel; + const Icon = copied ? CopyCheck : healthy ? copyIcon || ClipboardCopy : CopyX; + const isWithLabel = successMessage && copyLabel && errorLabel; - return ( - - - - - - - {tooltip && {tooltip}} - - ); + return ( + + + + + + + {tooltip && {tooltip}} + + ); }; diff --git a/dashboard/src/features/users/tables/users/columns.tsx b/dashboard/src/features/users/tables/users/columns.tsx index f359a82..8ef6009 100644 --- a/dashboard/src/features/users/tables/users/columns.tsx +++ b/dashboard/src/features/users/tables/users/columns.tsx @@ -1,22 +1,21 @@ - -import { ColumnDef } from "@tanstack/react-table" +import type { ColumnDef } from "@tanstack/react-table"; +import type { UserType } from "@marzneshin/features/users"; import { UsersStatusBadge, - UserType, UsersStatus, OnlineStatus, - UserUsedTraffic -} from "@marzneshin/features/users" -import { DataTableColumnHeader } from "@marzneshin/components/data-table/column-header" -import i18n from "@marzneshin/features/i18n" + UserUsedTraffic, +} from "@marzneshin/features/users"; +import { DataTableColumnHeader } from "@marzneshin/components/data-table/column-header"; +import i18n from "@marzneshin/features/i18n"; import { CopyToClipboardButton, DataTableActionsCell, - buttonVariants -} from "@marzneshin/components" -import { LinkIcon } from "lucide-react" -import { getSubscriptionLink } from "@marzneshin/utils" -import { format } from "date-fns" + buttonVariants, +} from "@marzneshin/components"; +import { LinkIcon } from "lucide-react"; +import { getSubscriptionLink } from "@marzneshin/utils"; +import { format } from "date-fns"; interface ColumnAction { onDelete: (user: UserType) => void; @@ -24,45 +23,74 @@ interface ColumnAction { onEdit: (user: UserType) => void; } -export const columns = (actions: ColumnAction): ColumnDef[] => ([ +export const columns = (actions: ColumnAction): ColumnDef[] => [ { accessorKey: "username", - header: ({ column }) => , - cell: ({ row }) => (
- {row.original.username} -
) + header: ({ column }) => ( + + ), + cell: ({ row }) => ( +
+ {row.original.username} +
+ ), }, { accessorKey: "status", - header: ({ column }) => , - cell: ({ row }) => , + header: ({ column }) => ( + + ), + cell: ({ row }) => ( + + ), enableSorting: false, }, { accessorKey: "used_traffic", - header: ({ column }) => , - cell: ({ row }) => + header: ({ column }) => ( + + ), + cell: ({ row }) => , }, { accessorKey: "expire", - header: ({ column }) => , - cell: ({ row }) => row.original.expire ? format(row.original.expire.toLocaleString(), "PPP") : "Unlimited" + header: ({ column }) => ( + + ), + cell: ({ row }) => + row.original.expire + ? format(row.original.expire.toLocaleString(), "PPP") + : "Unlimited", }, { id: "actions", cell: ({ row }) => { return ( -
e.stopPropagation()}> +
e.stopPropagation()} + >
- ) - } + ); + }, }, -]); +];