Files
videoreg.ru/src/features/register-video/model/actions.ts
T
huncode df60a7b74c
Master Production Deploy / production (push) Failing after 7m51s
Init repo
2026-05-16 23:51:49 +03:00

21 lines
674 B
TypeScript

'use server';
import { revalidatePath, updateTag } from 'next/cache';
import { VIDEO_COLLECTION_TAG } from '@/entities/video/api/videoCache';
import { addVideo } from '@/entities/video/api/videoRepository';
import { normalizeVideoDraft } from '@/entities/video/model/video';
export async function registerVideoAction(formData: FormData) {
const draft = normalizeVideoDraft({
title: String(formData.get('title') ?? ''),
owner: String(formData.get('owner') ?? ''),
sourceUrl: String(formData.get('sourceUrl') ?? ''),
status: String(formData.get('status') ?? ''),
});
await addVideo(draft);
updateTag(VIDEO_COLLECTION_TAG);
revalidatePath('/');
}