Skip to content

Commit

Permalink
fix: add Eubank system to context (#920)
Browse files Browse the repository at this point in the history
  • Loading branch information
vnugent authored Jul 17, 2023
1 parent 7bca17c commit d7ca843
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@heroicons/react": "2.0.13",
"@lexical/react": "^0.7.5",
"@math.gl/web-mercator": "3.6.2",
"@openbeta/sandbag": "^0.0.33",
"@openbeta/sandbag": "^0.0.45",
"@radix-ui/react-alert-dialog": "^1.0.0",
"@radix-ui/react-dialog": "^1.0.0",
"@radix-ui/react-dropdown-menu": "^2.0.1",
Expand Down
18 changes: 15 additions & 3 deletions src/js/grades/Grade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ const gradeContextToGradeScales = {
aid: GradeScales.FRENCH,
snow: GradeScales.FRENCH, // is this the same as alpine?
ice: GradeScales.FRENCH // is this the same as alpine?
},
AU: {
trad: GradeScales.EWBANK,
sport: GradeScales.EWBANK,
bouldering: GradeScales.VSCALE,
tr: GradeScales.EWBANK,
deepwatersolo: GradeScales.EWBANK,
alpine: GradeScales.YDS,
mixed: GradeScales.YDS,
aid: GradeScales.AID,
snow: GradeScales.YDS, // is this the same as alpine?
ice: GradeScales.WI
}
}

Expand Down Expand Up @@ -79,7 +91,7 @@ export default class Grade {
const isValidGrade = (userInput: string): string | undefined => {
if (userInput == null || userInput === '') return undefined
const score = getScale(this.gradescales.bouldering)?.getScore(userInput) ?? -1
return score >= 0 || Array.isArray(score) ? undefined : 'Invalid grade'
return Array.isArray(score) || score >= 0 ? undefined : 'Invalid grade'
}
return {
validate: {
Expand All @@ -92,7 +104,7 @@ export default class Grade {
const isValidGrade = (userInput: string): string | undefined => {
if (userInput == null || userInput === '') return undefined // possible to have unknown grade (Ex: route under development)
const score = getScale(this.gradescales[discipline])?.getScore(userInput) ?? -1
return score >= 0 || Array.isArray(score) ? undefined : 'Invalid grade'
return Array.isArray(score) || score >= 0 ? undefined : 'Invalid grade'
}
return {
validate: {
Expand Down Expand Up @@ -125,7 +137,7 @@ export class GradeHelper {
if (userInput == null || userInput === '') return 'Missing grade'
const _d = discipline == null && this.isBoulder ? 'bouldering' : 'trad'
const score = getScale(this.gradeScales[_d])?.getScore(userInput) ?? -1
return score >= 0 || Array.isArray(score) ? undefined : 'Invalid grade'
return Array.isArray(score) || score >= 0 ? undefined : 'Invalid grade'
}
return {
validate: {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1882,10 +1882,10 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@openbeta/sandbag@^0.0.33":
version "0.0.33"
resolved "https://registry.yarnpkg.com/@openbeta/sandbag/-/sandbag-0.0.33.tgz#bb771d94c5a3fc2c9d9e7fcad7e85e6809b89d0e"
integrity sha512-YACAVdBU2bn0A7XIilw22yieS/QrAHqmIpiDWHJr/lAw4M3hEDq956SEfw/H0pwukTLy8A6z9K/o4uD84t4OiA==
"@openbeta/sandbag@^0.0.45":
version "0.0.45"
resolved "https://registry.yarnpkg.com/@openbeta/sandbag/-/sandbag-0.0.45.tgz#b6230ddf63f265b91d0a0359a2f87c5359dded74"
integrity sha512-8s2YFeUBU3lK2EzQIZSsf/apEIaxhtHJNfWWDmtjIE7/wlgqm84BSX72wur1FGrqcI9o3P1dkZmevHnu0ItGZQ==

"@panva/hkdf@^1.0.2":
version "1.1.1"
Expand Down

1 comment on commit d7ca843

@vercel
Copy link

@vercel vercel bot commented on d7ca843 Jul 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.