Skip to content

Commit

Permalink
fix: jobProps can't be parsed when undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
blackbirdem committed May 27, 2024
1 parent 4b85c61 commit fc60608
Showing 1 changed file with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,6 @@ export default {
return jobProps
},
parseProps(jobProps) {
if (!jobProps) {
return undefined
}
let parsedProps = []
for (const j of jobProps) {
let parsedJobProps = {id: j.id}
Expand All @@ -400,19 +397,21 @@ export default {
parsedJobProps[prop] = j[prop]
}
}
let propSkills = []
for (const s of j.skills) {
let skillIds = []
for (const skill of this.skills) {
skillIds.push(skill.id)
}
if (skillIds.includes(s)) {
propSkills.push(this.skills[s-1])
} else {
propSkills.push(new Skill('Skill from added ' + this.$t('optimization.job') + ' ' + j.id, s))
if (j.skills) {
let propSkills = []
for (const s of j.skills) {
let skillIds = []
for (const skill of this.skills) {
skillIds.push(skill.id)
}
if (skillIds.includes(s)) {
propSkills.push(this.skills[s-1])
} else {
propSkills.push(new Skill('Skill from added ' + this.$t('optimization.job') + ' ' + j.id, s))
}
}
parsedJobProps.skills = propSkills
}
parsedJobProps.skills = propSkills

parsedProps.push(parsedJobProps)
}
Expand Down Expand Up @@ -534,11 +533,11 @@ export default {
// places from the appRoute without changing the
// object reference because it is a prop
const defaultJobs = this.jobs
const jobProps = this.parseProps(this.$store.getters.appRouteData.options.jobProps)
const places = this.$store.getters.appRouteData.places
let storedJobs = localStorage.getItem('jobs')
const jobs = []
if (places.length > 0) {
const jobProps = this.parseProps(this.$store.getters.appRouteData.options.jobProps)
for (const [i, place] of places.entries()) {
jobs.push(new Job(place.lng, place.lat, place.placeName, jobProps[i]))
}
Expand Down

0 comments on commit fc60608

Please sign in to comment.