From 92dda23952287a1f07a499b4497e35af10dc105d Mon Sep 17 00:00:00 2001 From: Conor Sinclair Date: Tue, 2 Aug 2022 23:26:46 +0100 Subject: [PATCH] able to change the thumbnail and gif times --- app/src/pages/admin/short/[id].tsx | 36 +++++++++++++++++++++++++++--- app/src/server/routers/short.ts | 13 +++++++++-- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/app/src/pages/admin/short/[id].tsx b/app/src/pages/admin/short/[id].tsx index df7acfb..04bde6a 100644 --- a/app/src/pages/admin/short/[id].tsx +++ b/app/src/pages/admin/short/[id].tsx @@ -20,6 +20,8 @@ export const editShortSchema = z.object({ description: z.string().min(1).max(256).optional(), path: z.string().min(3), playbackId: z.string(), + thumbnailTime: z.string().optional(), + previewGifStartTime: z.string().optional(), }); function EditShortForm() { @@ -70,8 +72,8 @@ function EditShortForm() { ); return ( - <> -

Edit short

+
+

Edit short

+
+ + +

{zo.errors.thumbnailTime()?.message}

+
+
+ + +

+ {zo.errors.previewGifStartTime()?.message} +

+
); } diff --git a/app/src/server/routers/short.ts b/app/src/server/routers/short.ts index 44dc7bc..4de16a3 100644 --- a/app/src/server/routers/short.ts +++ b/app/src/server/routers/short.ts @@ -135,10 +135,19 @@ export const shortRouter = createRouter() data: editShortSchema, }), async resolve({ input, ctx }) { - const { id, data } = input; + const { + id, + data: { previewGifStartTime, thumbnailTime, ...data }, + } = input; const short = await ctx.prisma.short.update({ where: { id }, - data, + data: { + ...data, + previewGifStartTime: previewGifStartTime + ? parseInt(previewGifStartTime) + : null, + thumbnailTime: thumbnailTime ? parseInt(thumbnailTime) : null, + }, select: defaultShortSelect, }); return short;