Skip to content

Commit

Permalink
handle the case when compensation tier is missing from ashby
Browse files Browse the repository at this point in the history
  • Loading branch information
konstrybakov committed Jul 28, 2024
1 parent c1bf45a commit 5ea5700
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions lib/hiring-platforms/ashby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,39 +120,41 @@ export class Ashby extends HiringPlatform {

result.compensationSummary = job.compensation.compensationTierSummary

const salaryComponent = compensationTier.components.find(
component => component.compensationType === 'Salary',
)

if (salaryComponent) {
result.salaryMin =
typeof salaryComponent.minValue === 'number'
? String(salaryComponent.minValue)
: null

result.salaryMax =
typeof salaryComponent.maxValue === 'number'
? String(salaryComponent.maxValue)
: null

result.compensationCurrencyCode = salaryComponent.currencyCode
result.compensationInterval = salaryComponent.interval
}
if (compensationTier) {
const salaryComponent = compensationTier.components.find(
component => component.compensationType === 'Salary',
)

if (salaryComponent) {
result.salaryMin =
typeof salaryComponent.minValue === 'number'
? String(salaryComponent.minValue)
: null

result.salaryMax =
typeof salaryComponent.maxValue === 'number'
? String(salaryComponent.maxValue)
: null

result.compensationCurrencyCode = salaryComponent.currencyCode
result.compensationInterval = salaryComponent.interval
}

const equityComponent = compensationTier.components.find(
component => component.compensationType === 'EquityPercentage',
)
const equityComponent = compensationTier.components.find(
component => component.compensationType === 'EquityPercentage',
)

if (equityComponent) {
result.equityMin =
typeof equityComponent.minValue === 'number'
? String(equityComponent.minValue)
: null
if (equityComponent) {
result.equityMin =
typeof equityComponent.minValue === 'number'
? String(equityComponent.minValue)
: null

result.equityMax =
typeof equityComponent.maxValue === 'number'
? String(equityComponent.maxValue)
: null
result.equityMax =
typeof equityComponent.maxValue === 'number'
? String(equityComponent.maxValue)
: null
}
}
}

Expand Down

0 comments on commit 5ea5700

Please sign in to comment.