This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
'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('/');
|
||||
}
|
||||
Reference in New Issue
Block a user