added toast to unlock handle

This commit is contained in:
Polaris 2024-09-15 14:15:21 -04:00
parent d13e1561ae
commit f4a6ef6150

View File

@ -4,17 +4,30 @@ import { aime_user_game_locks } from "@/prisma/schemas/artemis/generated/artemis
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { Trash2, UnlockIcon } from "lucide-react"; import { Trash2, UnlockIcon } from "lucide-react";
import { deleteUserGameLocks } from "./action"; import { deleteUserGameLocks } from "./action";
import { toast } from "@/components/ui/use-toast";
type chunithm = aime_user_game_locks & { userName: string | null }; type chunithm = aime_user_game_locks & { userName: string | null };
const handleDelete = async (userId: number) => { const handleDelete = async (userId: number) => {
try { try {
const result = await deleteUserGameLocks(userId); const result = await deleteUserGameLocks(userId);
if (result.success) { if (result.success) {
console.log( toast({
`Successfully deleted ${result.count} rows for user ${userId}.`, title: "User Unlocked",
); description: (
<pre className="mt-2 w-[340px] rounded-md p-4">
<div className="text-white">Successfully unlocked the user</div>
</pre>
),
});
} else { } else {
console.error(result.message); toast({
title: "Failed to unlock user",
description: (
<pre className="mt-2 w-[340px] rounded-md p-4">
<div className="text-white">User has already been unlocked</div>
</pre>
),
});
} }
} catch (error) { } catch (error) {
console.error("Error deleting user game locks:", error); console.error("Error deleting user game locks:", error);