Skip to content

Commit

Permalink
Merge pull request #721 from OneCommunityGlobal/development
Browse files Browse the repository at this point in the history
Backend Release to Main [1.37]
  • Loading branch information
one-community authored Jan 26, 2024
2 parents a499bda + 5b3bb76 commit 9825974
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/controllers/profileInitialSetupController.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,12 @@ const profileInitialSetupController = function (
const token = jwt.sign(jwtPayload, JWT_SECRET);

const locationData = {
title: '',
firstName: req.body.firstName,
lastName: req.body.lastName,
jobTitle: req.body.jobTitle,
location: req.body.homeCountry,
isActive: true,
};

res.send({ token }).status(200);
Expand Down
25 changes: 25 additions & 0 deletions src/models/mapLocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@ const mongoose = require('mongoose');

const { Schema } = mongoose;

const capitalizeString = (s) => {

if (typeof s !== 'string') {
return s;
}
const words = s.split(' ');
const capitalizedWords = words.map(word => {
if (word.length > 0) {
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
} else {
return '';
}
});
const capitalizedString = capitalizedWords.join(' ');
return capitalizedString;
}

const mapLocation = new Schema({
title: {
type: String,
Expand Down Expand Up @@ -40,4 +57,12 @@ const mapLocation = new Schema({
},
});

mapLocation.pre('save', function (next) {
this.firstName = capitalizeString(this.firstName);
this.lastName = capitalizeString(this.lastName);
this.jobTitle = capitalizeString(this.jobTitle);
this.location.userProvided = capitalizeString(this.location.userProvided);
next();
});

module.exports = mongoose.model('MapLocation', mapLocation, 'maplocations');

0 comments on commit 9825974

Please sign in to comment.