From 7e592d3af74cecfa4101b37f373ed5308dbb64e5 Mon Sep 17 00:00:00 2001 From: Vadym Samoilenko Date: Fri, 5 Jun 2026 13:10:59 +0100 Subject: [PATCH] feat(birthday): upload fields for why-section videos Replace text src/poster in whyVideos with media upload pickers so admins can upload video files directly from the CMS instead of entering raw URLs. Co-Authored-By: Claude Sonnet 4.6 --- migrations/0015_birthday_why_videos_upload.sql | 14 ++++++++++++++ src/app/(frontend)/dni-narodzhennia/page.tsx | 12 +++++++----- src/globals/BirthdayPage.ts | 18 +++++++++++++++--- 3 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 migrations/0015_birthday_why_videos_upload.sql diff --git a/migrations/0015_birthday_why_videos_upload.sql b/migrations/0015_birthday_why_videos_upload.sql new file mode 100644 index 0000000..30c85f7 --- /dev/null +++ b/migrations/0015_birthday_why_videos_upload.sql @@ -0,0 +1,14 @@ +-- 0015: replace text src/poster in birthday_page_why_videos with media FK uploads + +ALTER TABLE "birthday_page_why_videos" + ADD COLUMN IF NOT EXISTS "video_id" integer + REFERENCES "media"("id") ON DELETE SET NULL ON UPDATE NO ACTION, + ADD COLUMN IF NOT EXISTS "poster_id" integer + REFERENCES "media"("id") ON DELETE SET NULL ON UPDATE NO ACTION; + +-- versions mirror +ALTER TABLE "_birthday_page_v_version_why_videos" + ADD COLUMN IF NOT EXISTS "video_id" integer + REFERENCES "media"("id") ON DELETE SET NULL ON UPDATE NO ACTION, + ADD COLUMN IF NOT EXISTS "poster_id" integer + REFERENCES "media"("id") ON DELETE SET NULL ON UPDATE NO ACTION; diff --git a/src/app/(frontend)/dni-narodzhennia/page.tsx b/src/app/(frontend)/dni-narodzhennia/page.tsx index 762b9c0..53c72d9 100644 --- a/src/app/(frontend)/dni-narodzhennia/page.tsx +++ b/src/app/(frontend)/dni-narodzhennia/page.tsx @@ -423,11 +423,13 @@ export default async function BirthdayPage() { items={whyItems.map((i) => ({ title: i.title, description: i.description }))} reviewVideos={ whyVideos.length > 0 - ? whyVideos.map((v) => ({ - src: v.src as string, - poster: (v.poster as string) ?? null, - label: (v.label as string) ?? null, - })) + ? whyVideos + .map((v) => ({ + src: mediaUrl(v.video as Media | undefined) ?? (v.src as string) ?? '', + poster: mediaUrl(v.poster as Media | undefined) ?? null, + label: (v.label as string) ?? null, + })) + .filter((v) => v.src) : undefined } /> diff --git a/src/globals/BirthdayPage.ts b/src/globals/BirthdayPage.ts index 43b641d..0c79078 100644 --- a/src/globals/BirthdayPage.ts +++ b/src/globals/BirthdayPage.ts @@ -130,9 +130,21 @@ export const BirthdayPage: GlobalConfig = { type: 'array', label: 'Відео-відгуки у секції "Чому"', fields: [ - { name: 'src', type: 'text', required: true }, - { name: 'poster', type: 'text' }, - { name: 'label', type: 'text' }, + { + name: 'video', + type: 'upload', + relationTo: 'media', + required: true, + label: 'Відео файл', + }, + { + name: 'poster', + type: 'upload', + relationTo: 'media', + required: false, + label: 'Постер (обкладинка, опційно)', + }, + { name: 'label', type: 'text', label: 'Підпис (опційно)' }, ], }, // Working hours