Inputting and Displaying Ratings

I’ve created a page intended to allow site visitors to rate the people they worked with on projects. I’ve modified the code from the Velo “Product Reviews” and the “Search a Database” examples to pull information from my data collection (ACFreelancers). Lacking a coding background, I’m receiving the following errors:

  1. Loading the code for the HOME page. To debug this code, open visv2.js in Developer Tools.
  2. Loading the code for the Expert Reviews page. To debug this code, open lkftf.js in Developer Tools.
  3. TypeError: Cannot read property ‘title’ of undefined

If someone could look at my code and let me know what I need to correct, I would appreciate it. Following is the code:

import wixData from "wix-data";
 
$w.onReady(() => {
 loadACFreelancers();
});
let lastFilterExpertise;
let lastFilterCategory;
let debounceTimer;
export function iExpertise_keyPress(event) {
 if (debounceTimer) {
 clearTimeout(debounceTimer);
 debounceTimer = undefined;
 }
 debounceTimer = setTimeout(() => {
 filter($w('#iExpertise').value, lastFilterCategory); 
 }, 500);
}
 
export function iCategory_click_1(event) {
 filter(lastFilterExpertise, $w('#iCategory').value);
}
 
function filter(expertise, category) {
 if (lastFilterExpertise !== expertise || lastFilterCategory !== category) {
 let newFilter = wixData.filter();
 if (expertise)
 newFilter = newFilter.contains('expertise', expertise);
 if (category)
 newFilter = newFilter.contains('category', category);
 const filterValue = $w("#iCategory").value
const byAssignment = wixData.filter().contains("assignment", filterValue)
const byHumanities = wixData.filter().contains("humanities", filterValue)
const bySocialSciences = wixData.filter().contains("socialSciences", filterValue)
const byTopics = wixData.filter().contains("topics", filterValue)
const byOther = wixData.filter().contains("other", filterValue)
 
$w("#dataset1").setFilter(byAssignment.or(byHumanities).or(bySocialSciences).or(byTopics).or(byOther))
 $w('#dataset1').setFilter(newFilter); 
 lastFilterExpertise = expertise; 
 lastFilterCategory = category;
 }
}
 
function loadACFreelancers() {
 wixData.query('ACFreelancers')
 .limit(1000)
 .ascending("category")
 .distinct("category")
 .then(results => {
 let distinctList = buildOptions(results.items);
 // unshift() is like push(), but it prepends an item at the beginning of an array
 distinctList.unshift({ "value": '', "label": 'Select Category' });
 // Call the function that builds the options list from the unique titles 
 $w("#iCategory").options = distinctList;
 });
}
 function buildOptions(items) {
 return items.map(curr => {
 // Use the map method to build the options list in the format {label:uniqueTitle, value:uniqueTitle}
 return { label: curr, value: curr };
 });
 }
 
 
export function repeater1_itemReady($item, itemData, index) {
 
 let currentPrice = itemData.hourlyRate3;
 let newPrice = "$" + formatNumber_AsDollar(currentPrice);
 $item("#priceText").text = newPrice
 
 function formatNumber_AsDollar (x) {
return x.toString().replace(/\D(?=(\d{3})+(?!\d))/g, ","); 
 }
 
}

This item can be closed. I found an example that might achieve what I’m looking for.

The Ratings by User example might also be helpful.

Thank you Yisrael. I closed this question because I found the “Ratings by User” example you had mentioned in a previous post. I am having difficulty with the example’s code, however, and this morning I posted the issues I am having. My request for assistance is at https://www.wix.com/velo/forum/community-discussion/ratings-by-user. Hopefully, someone can show me what I am doing wrong.