Spaces:
Runtime error
Runtime error
Download src/actions/submit-proposal.ts from dvijaykrishnan/vault-video-processor: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/spaces/dvijaykrishnan/vault-video-processor/resolve/main/src/actions/submit-proposal.ts
- Command line
-
hf download hf://spaces/dvijaykrishnan/vault-video-processor/src/actions/submit-proposal.ts
-
curl -L -o submit-proposal.ts https://huggingface.co/spaces/dvijaykrishnan/vault-video-processor/resolve/main/src/actions/submit-proposal.ts
1.33 kB
| 'use server'; | |
| import { db } from '@/lib/db'; | |
| import { affiliateProposals } from '@/lib/db/schema'; | |
| import { revalidatePath } from 'next/cache'; | |
| export async function submitAffiliateProposal(data: { | |
| videoId: string; | |
| creatorId: string; | |
| objectId?: string; | |
| submitterName?: string; | |
| submitterEmail?: string; | |
| productUrl: string; | |
| affiliateUrl: string; | |
| productName: string; | |
| price?: number; | |
| imageUrl?: string; | |
| note?: string; | |
| }) { | |
| try { | |
| const [proposal] = await db.insert(affiliateProposals).values({ | |
| videoId: data.videoId, | |
| creatorId: data.creatorId, | |
| objectId: data.objectId, | |
| submitterName: data.submitterName, | |
| submitterEmail: data.submitterEmail, | |
| productUrl: data.productUrl, | |
| affiliateUrl: data.affiliateUrl, | |
| productName: data.productName, | |
| price: data.price, | |
| imageUrl: data.imageUrl, | |
| note: data.note, | |
| status: 'PENDING', | |
| }).returning(); | |
| revalidatePath('/dashboard/requests'); | |
| return { success: true, id: proposal.id }; | |
| } catch (error: any) { | |
| console.error('Failed to submit affiliate proposal:', error); | |
| return { success: false, error: error.message || 'Failed to submit proposal' }; | |
| } | |
| } | |