style: format code with prettier

This commit is contained in:
openhands committed 2026-07-12 21:07:34 +02:00
1 parent e85e4d74ea
commit 2e4ed76121
378 files changed
+22404 -20686

No files matched your search

+38 -44
View File
@@ -1,49 +1,43 @@
'use client'
"use client";
import { Ban, ShieldOff } from 'lucide-react'
import { useState } from 'react'
import { banUser, unbanUser } 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 { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select'
import { Textarea } from '@/components/ui/textarea'
import { useServerAction } from '@/hooks/use-server-action'
import { Ban, ShieldOff } from "lucide-react";
import { useState } from "react";
import { banUser, unbanUser } 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 { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Textarea } from "@/components/ui/textarea";
import { useServerAction } from "@/hooks/use-server-action";
interface BanInfo {
id: number
reason: string
type: string
staffName: string
timestamp: number
banExpire: number
id: number;
reason: string;
type: string;
staffName: string;
timestamp: number;
banExpire: number;
}
interface UserBanSectionProps {
userId: number
username: string
bans: BanInfo[]
userId: number;
username: string;
bans: BanInfo[];
}
export function UserBanSection({ userId, username, bans }: UserBanSectionProps) {
const { isPending, run } = useServerAction()
const [showBanForm, setShowBanForm] = useState(false)
const [reason, setReason] = useState('')
const [duration, setDuration] = useState('24')
const [banType, setBanType] = useState('account')
const { isPending, run } = useServerAction();
const [showBanForm, setShowBanForm] = useState(false);
const [reason, setReason] = useState("");
const [duration, setDuration] = useState("24");
const [banType, setBanType] = useState("account");
const activeBan = bans.find((b) => {
const now = Math.floor(Date.now() / 1000)
return b.banExpire === 0 || b.banExpire > now
})
const now = Math.floor(Date.now() / 1000);
return b.banExpire === 0 || b.banExpire > now;
});
function handleBan() {
run(
@@ -52,22 +46,22 @@ export function UserBanSection({ userId, username, bans }: UserBanSectionProps)
userId,
reason,
duration: parseInt(duration, 10),
type: banType as 'account' | 'ip' | 'machine',
type: banType as "account" | "ip" | "machine",
}),
{
successMessage: `${username} has been banned.`,
onSuccess: () => {
setShowBanForm(false)
setReason('')
setShowBanForm(false);
setReason("");
},
},
)
);
}
function handleUnban() {
run(() => unbanUser({ userId }), {
successMessage: `${username} has been unbanned.`,
})
});
}
return (
@@ -94,9 +88,9 @@ export function UserBanSection({ userId, username, bans }: UserBanSectionProps)
<p className="text-sm font-medium text-destructive">Active Ban</p>
<p className="text-sm">{activeBan.reason}</p>
<p className="text-xs text-muted-foreground">
By {activeBan.staffName} &middot;{' '}
By {activeBan.staffName} &middot;{" "}
{activeBan.banExpire === 0
? 'Permanent'
? "Permanent"
: `Expires ${new Date(activeBan.banExpire * 1000).toLocaleString()}`}
</p>
</div>
@@ -137,7 +131,7 @@ export function UserBanSection({ userId, username, bans }: UserBanSectionProps)
</div>
</div>
<Button variant="destructive" onClick={handleBan} disabled={isPending || !reason}>
{isPending ? 'Banning...' : 'Confirm Ban'}
{isPending ? "Banning..." : "Confirm Ban"}
</Button>
</div>
)}
@@ -162,5 +156,5 @@ export function UserBanSection({ userId, username, bans }: UserBanSectionProps)
)}
</CardContent>
</Card>
)
);
}