Display bid history for media outlet auctions and fetch bid data
Add a new API endpoint and integrate bid history display into the media outlet auction page. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 069d4324-6c40-4355-955e-c714a50de1ea Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/3df548ff-50ae-432f-9be4-25d34eccc983/069d4324-6c40-4355-955e-c714a50de1ea/6XTzcDL
This commit is contained in:
@ -168,6 +168,16 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/api/auctions/:id/bids', async (req, res) => {
|
||||
try {
|
||||
const bids = await storage.getBidsByAuctionId(req.params.id);
|
||||
res.json(bids);
|
||||
} catch (error) {
|
||||
console.error("Error fetching bids:", error);
|
||||
res.status(500).json({ message: "Failed to fetch bids" });
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/auctions/:id/bid', isAuthenticated, async (req: any, res) => {
|
||||
try {
|
||||
const userId = req.user.claims.sub;
|
||||
|
||||
@ -59,6 +59,7 @@ export interface IStorage {
|
||||
getAuctionByMediaOutlet(mediaOutletId: string): Promise<Auction | undefined>;
|
||||
createAuction(auction: InsertAuction): Promise<Auction>;
|
||||
placeBid(bid: InsertBid): Promise<Bid>;
|
||||
getBidsByAuctionId(auctionId: string): Promise<Bid[]>;
|
||||
|
||||
// Media outlet request operations
|
||||
getMediaOutletRequests(status?: string): Promise<MediaOutletRequest[]>;
|
||||
@ -251,6 +252,14 @@ export class DatabaseStorage implements IStorage {
|
||||
|
||||
return newBid;
|
||||
}
|
||||
|
||||
async getBidsByAuctionId(auctionId: string): Promise<Bid[]> {
|
||||
return await db
|
||||
.select()
|
||||
.from(bids)
|
||||
.where(eq(bids.auctionId, auctionId))
|
||||
.orderBy(desc(bids.createdAt));
|
||||
}
|
||||
|
||||
// Media outlet request operations
|
||||
async getMediaOutletRequests(status?: string): Promise<MediaOutletRequest[]> {
|
||||
|
||||
Reference in New Issue
Block a user