fleet/website/api/controllers/view-testimonials.js
Eric 70d01d9a48
Website: Update testimonial sort order on /customer-stories, render testimonials server-side (#23996)
Changes:
- Updated the sort order of cards on the /customer-stories page
- Updated the cards on the /customer-stories page to be rendered
server-side.
- Updated styles for testimonial cards.
2024-11-21 08:55:47 +09:00

121 lines
3.8 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'View testimonials',
description: 'Display "Testimonials" page.',
exits: {
success: {
viewTemplatePath: 'pages/testimonials'
}
},
fn: async function () {
if (!_.isObject(sails.config.builtStaticContent) || !_.isArray(sails.config.builtStaticContent.testimonials) || !sails.config.builtStaticContent.compiledPagePartialsAppPath) {
throw {badConfig: 'builtStaticContent.testimonials'};
}
// Get testimonials for the <scrolalble-tweets> component.
let testimonials = _.clone(sails.config.builtStaticContent.testimonials);
// Filter the testimonials by product category
let testimonialsForMdm = _.filter(testimonials, (testimonial)=>{
return _.contains(testimonial.productCategories, 'Device management');
});
let testimonialOrderForMdm = [
'Scott MacVicar',
'Wes Whetstone',
'Nick Fohs',
'Erik Gomez',
'Matt Carr',
'Nico Waisman',
'Kenny Botelho',
'Dan Grzelak',
'Eric Tan',
];
testimonialsForMdm.sort((a, b)=>{
if(testimonialOrderForMdm.indexOf(a.quoteAuthorName) === -1){
return 1;
} else if(testimonialOrderForMdm.indexOf(b.quoteAuthorName) === -1) {
return -1;
}
return testimonialOrderForMdm.indexOf(a.quoteAuthorName) - testimonialOrderForMdm.indexOf(b.quoteAuthorName);
});
let testimonialsForSecurityEngineering = _.filter(testimonials, (testimonial)=>{
return _.contains(testimonial.productCategories, 'Vulnerability management');
});
let testimonialOrderForSecurityEngineering = [
'Nico Waisman',
'Austin Anderson',
'Chandra Majumdar',
'Andre Shields',
'Dan Grzelak',
'Charles Zaffery',
'Erik Gomez',
'Nick Fohs',
'Dhruv Majumdar',
'Arsenio Figueroa',
];
testimonialsForSecurityEngineering.sort((a, b)=>{
if(testimonialOrderForSecurityEngineering.indexOf(a.quoteAuthorName) === -1){
return 1;
} else if(testimonialOrderForSecurityEngineering.indexOf(b.quoteAuthorName) === -1) {
return -1;
}
return testimonialOrderForSecurityEngineering.indexOf(a.quoteAuthorName) - testimonialOrderForSecurityEngineering.indexOf(b.quoteAuthorName);
});
let testimonialsForItEngineering = _.filter(testimonials, (testimonial)=>{
return _.contains(testimonial.productCategories, 'Endpoint operations');
});
let testimonialOrderForItEngineering = [
'Charles Zaffery',
'Nico Waisman',
'Erik Gomez',
'Mike Arpaia',
'Ahmed Elshaer',
'Kenny Botelho',
'Alvaro Gutierrez',
'Tom Larkin',
'Nick Fohs',
'charles zaffery',// Note: This testimonial's quoteAuthorName value is lowercased so it can be sorted to a different position than the other Charles Zaffery quote.
'Andre Shields',
'Abubakar Yousafzai',
'Chandra Majumdar',
'Joe Pistone',
'Dan Grzelak',
'Austin Anderson',
'Brendan Shaklovitz',
'Dhruv Majumdar',
'Wes Whetstone',
'Eric Tan',
'Arsenio Figueroa',
];
testimonialsForItEngineering.sort((a, b)=>{
if(testimonialOrderForItEngineering.indexOf(a.quoteAuthorName) === -1){
return 1;
} else if(testimonialOrderForItEngineering.indexOf(b.quoteAuthorName) === -1) {
return -1;
}
return testimonialOrderForItEngineering.indexOf(a.quoteAuthorName) - testimonialOrderForItEngineering.indexOf(b.quoteAuthorName);
});
let testimonialsWithVideoLinks = _.filter(testimonials, (testimonial)=>{
return testimonial.youtubeVideoUrl;
});
return {
testimonialsForMdm,
testimonialsForSecurityEngineering,
testimonialsForItEngineering,
testimonialsWithVideoLinks,
};
}
};