mirror of
https://github.com/traberph/short.git
synced 2026-11-22 22:55:12 +00:00
add charts and reset stats function
This commit is contained in:
@@ -207,4 +207,33 @@ export async function pinPageToRoot(prevState: any, fromData: FormData) {
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export async function deletePageStats(prevState: any, formData: FormData) {
|
||||
const schema = z.object({
|
||||
uuid: z.string().uuid()
|
||||
});
|
||||
|
||||
const data = schema.safeParse({
|
||||
uuid: formData.get("uuid")
|
||||
});
|
||||
|
||||
if (!data.success) {
|
||||
return {
|
||||
message: "Invalid data",
|
||||
error: data.error.flatten().fieldErrors,
|
||||
};
|
||||
}
|
||||
|
||||
await prisma.stat.deleteMany({
|
||||
where: {
|
||||
pageUuid: data.data.uuid
|
||||
}
|
||||
});
|
||||
|
||||
revalidatePath(`/~/dash/${data.data.uuid}`);
|
||||
|
||||
return {
|
||||
message: "Stats deleted",
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user