Skip to content

Commit

Permalink
redeploy test
Browse files Browse the repository at this point in the history
  • Loading branch information
singharaj-usai committed Oct 25, 2024
1 parent 03de22a commit 5cab087
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 2 deletions.
1 change: 0 additions & 1 deletion client/js/avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,5 +562,4 @@ $(document).ready(function () {
loadUserAvatar();
loadRenderedAvatar();
setupItemSelection();
restoreAvatarState();
});
2 changes: 1 addition & 1 deletion client/js/friends/showfriends.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ $(document).ready(function () {
}

const panel = $('<div class="panel panel-primary"></div>');
const panelHeading = $('<div class="panel-heading"><h3 class="panel-title">All Friends</h3></div>');
const panelHeading = $('<div class="panel-heading"><h3 class="panel-title">' + username + '\'s Friends</h3></div>');
const panelBody = $('<div class="panel-body"></div>');
const row = $('<div class="row"></div>');

Expand Down
45 changes: 45 additions & 0 deletions server/functions/api/models/Pant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const mongoose = require('mongoose');

const pantSchema = new mongoose.Schema({
title: {
type: String,
required: true,
trim: true,
},
description: {
type: String,
required: true,
trim: true,
},
thumbnailUrl: {
type: String,
required: true,
},
creator: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
required: true,
},
createdAt: {
type: Date,
default: Date.now,
},
updatedAt: {
type: Date,
default: Date.now,
},
assetId: {
type: Number,
required: true,
unique: true,
},
price: {
type: Number,
required: true,
default: 0,
},
});

const Pant = mongoose.model('Pant', pantSchema);

module.exports = Pant;
8 changes: 8 additions & 0 deletions server/functions/api/models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ const userSchema = new mongoose.Schema({
type: String,
default: null
},
pants: {
type: String,
default: null
},
displayUrl: {
type: String,
default: null
},
lastUpdated: {
type: Date,
default: Date.now
Expand Down
46 changes: 46 additions & 0 deletions server/functions/api/routes/avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,52 @@ router.put('/', authenticateToken, async (req, res) => {
};
}
break;

case 'pants':
if (itemId) {
const pantsAsset = await Asset.findOne({
_id: itemId,
AssetType: 'Pants',
$or: [
{ _id: { $in: user.inventory } },
{ creator: user._id }
]
});

if (!pantsAsset) {
console.error('Pants not accessible:', {
userId: req.user.userId,
pantsId: itemId
});
return res.status(400).json({
error: 'Pants not in inventory or not created by user'
});
}

console.log('Wearing pants:', {
userId: req.user.userId,
pantsId: itemId,
pantsDetails: {
name: pantsAsset.Name,
imageUrl: pantsAsset.imageUrl
}
});

user.avatar.pants = pantsAsset;
user.avatarRender = {
...user.avatarRender,
pants: pantsAsset.imageUrl,
lastUpdated: new Date()
};
} else {
user.avatar.pants = null;
user.avatarRender = {
...user.avatarRender,
pants: null,
lastUpdated: new Date()
};
}
break;
}

await user.save();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5cab087

Please sign in to comment.