dvijaykrishnan's picture
feat: Implement admin management for product requests and affiliate proposals, including new database migrations and expanded dashboard statistics.
7bb5991
Raw
History Blame Contribute Delete
945 Bytes
"use server";
import { db } from "@/lib/db";
import {
productRequests,
affiliateProposals,
youtubeVideos,
youtubeChannels,
users,
} from "@/lib/db/schema";
import { eq, desc, and } from "drizzle-orm";
export async function getAdminRequests() {
const requests = await db.query.productRequests.findMany({
with: {
video: {
with: {
channel: true
}
},
creator: true,
},
orderBy: [desc(productRequests.createdAt)],
});
return requests;
}
export async function getAdminProposals() {
const proposals = await db.query.affiliateProposals.findMany({
with: {
video: {
with: {
channel: true
}
},
creator: true,
},
orderBy: [desc(affiliateProposals.createdAt)],
});
return proposals;
}