From 42a54125826e59afffe79160ce4ce06780dd1613 Mon Sep 17 00:00:00 2001 From: jackiettran <41605212+jackiettran@users.noreply.github.com> Date: Mon, 24 Nov 2025 17:36:18 -0500 Subject: [PATCH] changed field from availability to isAvailable --- backend/models/Item.js | 2 +- backend/routes/items.js | 2 +- backend/routes/rentals.js | 2 +- backend/tests/unit/routes/items.test.js | 6 +++--- backend/tests/unit/routes/rentals.test.js | 6 +++--- frontend/src/pages/ItemDetail.tsx | 4 ++-- frontend/src/pages/ItemList.tsx | 2 +- frontend/src/pages/Owning.tsx | 10 +++++----- frontend/src/pages/RentItem.tsx | 2 +- frontend/src/types/index.ts | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/backend/models/Item.js b/backend/models/Item.js index 647a9c3..1a1b737 100644 --- a/backend/models/Item.js +++ b/backend/models/Item.js @@ -86,7 +86,7 @@ const Item = sequelize.define("Item", { type: DataTypes.ARRAY(DataTypes.STRING), defaultValue: [], }, - availability: { + isAvailable: { type: DataTypes.BOOLEAN, defaultValue: true, }, diff --git a/backend/routes/items.js b/backend/routes/items.js index 8157d0b..8e49247 100644 --- a/backend/routes/items.js +++ b/backend/routes/items.js @@ -98,7 +98,7 @@ router.get("/recommendations", authenticateToken, async (req, res) => { // For now, just return random available items as recommendations const recommendations = await Item.findAll({ where: { - availability: true, + isAvailable: true, isDeleted: false, }, limit: 10, diff --git a/backend/routes/rentals.js b/backend/routes/rentals.js index e9988bb..eac230b 100644 --- a/backend/routes/rentals.js +++ b/backend/routes/rentals.js @@ -192,7 +192,7 @@ router.post("/", authenticateToken, requireVerifiedEmail, async (req, res) => { return res.status(404).json({ error: "Item not found" }); } - if (!item.availability) { + if (!item.isAvailable) { return res.status(400).json({ error: "Item is not available" }); } diff --git a/backend/tests/unit/routes/items.test.js b/backend/tests/unit/routes/items.test.js index 6e51d8f..b712606 100644 --- a/backend/tests/unit/routes/items.test.js +++ b/backend/tests/unit/routes/items.test.js @@ -422,8 +422,8 @@ describe('Items Routes', () => { describe('GET /recommendations', () => { const mockRecommendations = [ - { id: 1, name: 'Item 1', availability: true }, - { id: 2, name: 'Item 2', availability: true } + { id: 1, name: 'Item 1', isAvailable: true }, + { id: 2, name: 'Item 2', isAvailable: true } ]; it('should get recommendations for authenticated user', async () => { @@ -443,7 +443,7 @@ describe('Items Routes', () => { }); expect(mockItemFindAll).toHaveBeenCalledWith({ - where: { availability: true }, + where: { isAvailable: true, isDeleted: false }, limit: 10, order: [['createdAt', 'DESC']] }); diff --git a/backend/tests/unit/routes/rentals.test.js b/backend/tests/unit/routes/rentals.test.js index 8b2c936..0524234 100644 --- a/backend/tests/unit/routes/rentals.test.js +++ b/backend/tests/unit/routes/rentals.test.js @@ -260,7 +260,7 @@ describe('Rentals Routes', () => { id: 1, name: 'Test Item', ownerId: 2, - availability: true, + isAvailable: true, pricePerHour: 10, pricePerDay: 50, }; @@ -340,7 +340,7 @@ describe('Rentals Routes', () => { }); it('should return 400 for unavailable item', async () => { - Item.findByPk.mockResolvedValue({ ...mockItem, availability: false }); + Item.findByPk.mockResolvedValue({ ...mockItem, isAvailable: false }); const response = await request(app) .post('/rentals') @@ -382,7 +382,7 @@ describe('Rentals Routes', () => { Item.findByPk.mockResolvedValue({ id: 1, ownerId: 2, - availability: true, + isAvailable: true, pricePerHour: 0, pricePerDay: 0 }); diff --git a/frontend/src/pages/ItemDetail.tsx b/frontend/src/pages/ItemDetail.tsx index f71edd5..563b2ee 100644 --- a/frontend/src/pages/ItemDetail.tsx +++ b/frontend/src/pages/ItemDetail.tsx @@ -633,7 +633,7 @@ const ItemDetail: React.FC = () => { })()} {/* Rental Period Selection - Only show for non-owners */} - {!isOwner && item.availability && !isAlreadyRenting && ( + {!isOwner && item.isAvailable && !isAlreadyRenting && ( <>