Added ascent record to Dashboard
This commit is contained in:
@ -9,30 +9,37 @@ export const formatRecord = (
|
||||
tz: string,
|
||||
useImperialUnits: boolean
|
||||
): Record<string, string | number> => {
|
||||
const unitFrom: TUnit = 'km'
|
||||
const unitTo: TUnit = useImperialUnits
|
||||
? units[unitFrom].defaultTarget
|
||||
: unitFrom
|
||||
const distanceUnitFrom: TUnit = 'km'
|
||||
const distanceUnitTo: TUnit = useImperialUnits
|
||||
? units[distanceUnitFrom].defaultTarget
|
||||
: distanceUnitFrom
|
||||
const ascentUnitFrom: TUnit = 'm'
|
||||
const ascentUnitTo: TUnit = useImperialUnits
|
||||
? units[ascentUnitFrom].defaultTarget
|
||||
: ascentUnitFrom
|
||||
let value
|
||||
switch (record.record_type) {
|
||||
case 'AS':
|
||||
case 'MS':
|
||||
value = `${convertDistance(
|
||||
+record.value,
|
||||
unitFrom,
|
||||
unitTo,
|
||||
distanceUnitFrom,
|
||||
distanceUnitTo,
|
||||
2
|
||||
)} ${unitTo}/h`
|
||||
)} ${distanceUnitTo}/h`
|
||||
break
|
||||
case 'FD':
|
||||
value = `${convertDistance(+record.value, unitFrom, unitTo, 3)} ${unitTo}`
|
||||
value = `${convertDistance(+record.value, distanceUnitFrom, distanceUnitTo, 3)} ${distanceUnitTo}`
|
||||
break
|
||||
case 'HA':
|
||||
value = `${convertDistance(+record.value, ascentUnitFrom, ascentUnitTo, 2)} ${ascentUnitTo}`
|
||||
break
|
||||
case 'LD':
|
||||
value = record.value
|
||||
break
|
||||
default:
|
||||
throw new Error(
|
||||
`Invalid record type, expected: "AS", "FD", "LD", "MD", got: "${record.record_type}"`
|
||||
`Invalid record type, expected: "AS", "FD", "HA", "LD", "MD", got: "${record.record_type}"`
|
||||
)
|
||||
}
|
||||
return {
|
||||
|
Reference in New Issue
Block a user