Moved conditions and defined second queries/mutations

This commit is contained in:
2024-10-12 19:16:35 -03:00
parent fc590d959c
commit 48030a035e
4 changed files with 79 additions and 28 deletions

View File

@@ -11,6 +11,7 @@ export type Entry = {
type: "artist" | "album";
name: string;
image: string;
number?: number;
};
export const entryRouter = createTRPCRouter({
@@ -20,6 +21,7 @@ export const entryRouter = createTRPCRouter({
type: z.enum(["artist", "album"]),
name: z.string().min(1),
image: z.string().min(1),
number: z.number().optional(),
}),
)
.query(async ({ ctx, input }) => {

View File

@@ -2,7 +2,7 @@ import * as cloudinary from "cloudinary";
import { Entry } from "../api/routers/entry";
export const generateEntryUniqueKey = (entry: Entry): string => {
return `${entry.type}:${entry.name.trim().toLowerCase().replace(/\s/g, "-")}`;
return `${entry.type}:${entry.name.trim().toLowerCase().replace(/\s/g, "-")}:${entry.number || 1}`;
};
export const uploadImage = async (