21 lines
674 B
TypeScript
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('/');
|
|
}
|