revert fb8e77bb68
Local Build and Deploy / deploy (push) Successful in 1m11s

revert style: clean up code with prettier and eslint
This commit is contained in:
remco committed 2026-07-12 21:02:03 +02:00
1 parent 27de078f54
commit e85e4d74ea
378 files changed
+20710 -22428

No files matched your search

+62 -49
View File
@@ -1,89 +1,102 @@
"use client";
'use client'
import { Check, Coins, Copy, KeyRound, MessageCircle, Unplug, Volume2, VolumeX } from "lucide-react";
import { useState } from "react";
import { alertUser, disconnectUser, muteUser, resetPassword, sendCredits, unmuteUser } from "@/actions/users";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { useServerAction } from "@/hooks/use-server-action";
import { Check, Coins, Copy, KeyRound, MessageCircle, Unplug, Volume2, VolumeX } from 'lucide-react'
import { useState } from 'react'
import {
alertUser,
disconnectUser,
muteUser,
resetPassword,
sendCredits,
unmuteUser,
} from '@/actions/users'
import { Badge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import { useServerAction } from '@/hooks/use-server-action'
interface UserQuickActionsProps {
userId: number;
username: string;
isOnline: boolean;
userId: number
username: string
isOnline: boolean
}
export function UserQuickActions({ userId, username, isOnline }: UserQuickActionsProps) {
const { run, isPending } = useServerAction();
const { run, isPending } = useServerAction()
// Reset password state
const [newPassword, setNewPassword] = useState<string | null>(null);
const [copied, setCopied] = useState(false);
const [newPassword, setNewPassword] = useState<string | null>(null)
const [copied, setCopied] = useState(false)
// Alert state
const [alertMessage, setAlertMessage] = useState("");
const [alertMessage, setAlertMessage] = useState('')
// Mute state
const [muteDuration, setMuteDuration] = useState("10");
const [muteDuration, setMuteDuration] = useState('10')
// Credits state
const [creditAmount, setCreditAmount] = useState("1000");
const [creditAmount, setCreditAmount] = useState('1000')
function handleResetPassword() {
if (!confirm(`Reset password for ${username}? A new random password will be generated.`)) return;
if (!confirm(`Reset password for ${username}? A new random password will be generated.`)) return
run(() => resetPassword({ userId }), {
successMessage: "Password reset successfully.",
successMessage: 'Password reset successfully.',
onSuccess: (data) => {
setNewPassword(data.newPassword as string);
setNewPassword(data.newPassword as string)
},
});
})
}
function handleDisconnect() {
run(() => disconnectUser({ userId }), {
successMessage: `${username} disconnected.`,
});
})
}
function handleAlert() {
if (!alertMessage.trim()) return;
if (!alertMessage.trim()) return
run(() => alertUser({ userId, message: alertMessage.trim() }), {
successMessage: "Alert sent.",
onSuccess: () => setAlertMessage(""),
});
successMessage: 'Alert sent.',
onSuccess: () => setAlertMessage(''),
})
}
function handleMute() {
const duration = Number(muteDuration);
if (Number.isNaN(duration) || duration < 0) return;
const duration = Number(muteDuration)
if (Number.isNaN(duration) || duration < 0) return
run(() => muteUser({ userId, duration }), {
successMessage: `${username} muted.`,
});
})
}
function handleUnmute() {
run(() => unmuteUser({ userId }), {
successMessage: `${username} unmuted.`,
});
})
}
function handleSendCredits() {
const amount = parseInt(creditAmount, 10);
if (!amount || amount <= 0) return;
const amount = parseInt(creditAmount, 10)
if (!amount || amount <= 0) return
run(() => sendCredits({ userId, amount }), {
successMessage: `${amount.toLocaleString()} credits sent to ${username}.`,
});
})
}
function copyPassword() {
if (newPassword) {
navigator.clipboard.writeText(newPassword);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
navigator.clipboard.writeText(newPassword)
setCopied(true)
setTimeout(() => setCopied(false), 2000)
}
}
@@ -129,10 +142,14 @@ export function UserQuickActions({ userId, username, isOnline }: UserQuickAction
placeholder="Message to send..."
value={alertMessage}
onChange={(e) => setAlertMessage(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && handleAlert()}
onKeyDown={(e) => e.key === 'Enter' && handleAlert()}
className="flex-1"
/>
<Button onClick={handleAlert} disabled={isPending || !alertMessage.trim()} size="icon">
<Button
onClick={handleAlert}
disabled={isPending || !alertMessage.trim()}
size="icon"
>
<MessageCircle className="h-4 w-4" />
</Button>
</div>
@@ -183,8 +200,8 @@ export function UserQuickActions({ userId, username, isOnline }: UserQuickAction
<DialogHeader>
<DialogTitle>Password Reset</DialogTitle>
<DialogDescription>
New password generated for <strong>{username}</strong>. Copy it now — it won&apos;t be shown
again.
New password generated for <strong>{username}</strong>. Copy it now — it won&apos;t be
shown again.
</DialogDescription>
</DialogHeader>
<div className="flex items-center gap-2 rounded-lg border bg-muted p-3">
@@ -192,15 +209,11 @@ export function UserQuickActions({ userId, username, isOnline }: UserQuickAction
{newPassword}
</code>
<Button variant="ghost" size="icon" onClick={copyPassword}>
{copied ? (
<Check className="h-4 w-4 text-[var(--admin-success)]" />
) : (
<Copy className="h-4 w-4" />
)}
{copied ? <Check className="h-4 w-4 text-[var(--admin-success)]" /> : <Copy className="h-4 w-4" />}
</Button>
</div>
</DialogContent>
</Dialog>
</>
);
)
}