Commit 8151263 1 parent 67e3ada commit 8151263 Copy full SHA for 8151263
File tree 1 file changed +7
-4
lines changed
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export type Substance = {
16
16
id : string ,
17
17
name : string ,
18
18
type : string ,
19
+ categories : string [ ] ,
19
20
} ;
20
21
21
22
// Build a list of "proper" names from `config.tableOrder`
@@ -63,22 +64,24 @@ export const substances = keyById(
63
64
64
65
export const allSubstances = keyById (
65
66
map ( ( drug : { name : string , pretty_name ? : string , categories : string [ ] } ) => {
66
- const { name, categories } = drug ;
67
+ const { name } = drug ;
67
68
68
69
const pretty_name =
69
70
typeof drug . pretty_name === "string"
70
71
? drug . pretty_name
71
72
: upperFirst ( name ) ;
72
73
74
+ const categories =
75
+ drug . categories && drug . categories . length > 0 ? drug . categories : [ ] ;
76
+
73
77
const type =
74
- ( categories && categories . length && categories [ 0 ] ) ||
75
- nameToType [ name ] ||
76
- "unknown" ;
78
+ ( categories . length > 0 && categories [ 0 ] ) || nameToType [ name ] || "unknown" ;
77
79
78
80
return {
79
81
id : name ,
80
82
name : pretty_name ,
81
83
type,
84
+ categories,
82
85
} ;
83
86
} ) ( allDrugs )
84
87
) ;
You can’t perform that action at this time.
0 commit comments