Skip to content

Commit

Permalink
accept incoming changes
Browse files Browse the repository at this point in the history
  • Loading branch information
singharaj-usai committed Oct 16, 2024
1 parent 1ef0a27 commit 6f57bb7
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions server/functions/api/routes/shirt.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,17 @@ router.get('/user', authenticateToken, async (req, res) => {

// Fetch shirts created by user
const createdShirts = await Asset.find({
<<<<<<< HEAD
creator: user.userId,
AssetType: 'Shirt',
});
=======
creator: user._id,
AssetType: 'Shirt',
}).populate('creator', 'username');
>>>>>>> revert-to-avatar-page-paginate

console.log('Created shirts found:', createdShirts.length);

// Fetch shirts owned by user
const ownedShirts = await Asset.find({
_id: { $in: user.inventory },
AssetType: 'Shirt',
<<<<<<< HEAD
});
=======
}).populate('creator', 'username');
>>>>>>> revert-to-avatar-page-paginate

console.log('Owned shirts found:', ownedShirts.length);

Expand Down Expand Up @@ -142,21 +132,6 @@ router.get('/user', authenticateToken, async (req, res) => {
router.get('/:id', async (req, res) => {
try {
const id = req.params.id;
<<<<<<< HEAD
const shirt = await Asset.findOne({ assetId: id, AssetType: 'Shirt' });
if (!shirt) {
return res.status(404).json({ error: 'Shirt not found' });
}
const user = await User.findOne({ userId: shirt.creator });
const shirtWithUsername = {
...shirt.toObject(),
creatorUsername: user ? user.username : 'Unknown',
};
res.json(shirtWithUsername);
} catch (error) {
console.error('Error fetching shirt:', error);
res.status(500).json({ error: 'Error fetching shirt', details: error.message });
=======
const shirt = await Asset.findOne({ _id: id, AssetType: 'Shirt' }).populate(
'creator',
'username'
Expand All @@ -170,7 +145,6 @@ router.get('/:id', async (req, res) => {
res
.status(500)
.json({ error: 'Error fetching shirt', details: error.message });
>>>>>>> revert-to-avatar-page-paginate
}
});

Expand Down Expand Up @@ -293,13 +267,8 @@ router.post(

await thumbnailQueue.addToQueue(shirtassetId, 'Shirt');

<<<<<<< HEAD
await User.findOneAndUpdate({ userId: req.user.userId }, {
$push: { shirts: shirt.assetId },
=======
await User.findByIdAndUpdate(req.user._id, {
$push: { shirts: shirt._id },
>>>>>>> revert-to-avatar-page-paginate
});

res.status(201).json({ shirtId: shirt.assetId, assetId: shirt.assetId });
Expand Down

0 comments on commit 6f57bb7

Please sign in to comment.