Skip to content

Commit 91b2d35

Browse files
YaroslavTrefilovBraveDevelopersAndreyUstyumenko
authored andcommitted
fix(FOROME-573): fix locus for variant without gene
1 parent d8b9371 commit 91b2d35

File tree

3 files changed

+60
-15
lines changed

3 files changed

+60
-15
lines changed

src/components/variant/ui/igv-button.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ import variantStore from '@store/variant'
99
import { Routes } from '@router/routes.enum'
1010
import { Button } from '@ui/button'
1111

12+
//TODO: Delete interface when merge service providers
13+
interface IAttributeDescriptors {
14+
name: string
15+
title: string
16+
cells: [content: string, cellClassName: string][]
17+
tooltip: string | undefined
18+
render: string | undefined
19+
}
20+
1221
export const IgvButton = observer((): ReactElement => {
1322
const variant = toJS(variantStore.variant)
1423

@@ -24,7 +33,9 @@ export const IgvButton = observer((): ReactElement => {
2433
return sampleName
2534
})
2635

27-
const locus: string = get(variant, '[0].rows[2].cells[0][0]', '')
36+
const rows: IAttributeDescriptors[] = get(variant, '[0].rows', [])
37+
const hg38Row = rows.find(element => element.name === 'hg38')
38+
const locus = hg38Row?.cells[0][0] ?? ''
2839

2940
const fixedLocus = locus.split(' ')[0]
3041

src/store/dataset.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ import { getFilteredAttrsList } from '@utils/getFilteredAttrsList'
2020
import dirinfoStore from './dirinfo'
2121
import operations from './operations'
2222

23+
//TODO: Delete interfaces when merge service providers
24+
enum TableColorCodes {
25+
GREY = 'grey',
26+
GREEN = 'green',
27+
YELLOW = 'yellow',
28+
YELLOW_CROSS = 'yellow-cross',
29+
RED = 'red',
30+
RED_CROSS = 'red-cross',
31+
}
32+
interface IRecordDescriptor {
33+
cl: TableColorCodes
34+
lb: string
35+
no: number
36+
dt?: string
37+
}
38+
2339
const INCREASE_INDEX = 50
2440

2541
export type Condition = [string, string, unknown, string[]?, unknown?]
@@ -34,7 +50,7 @@ export class DatasetStore {
3450
samples: string[] = []
3551
selectedVariantNumber?: number
3652

37-
wsRecords: { no: number; cl: string; dt: string; lb: string }[] = []
53+
wsRecords: IRecordDescriptor[] = []
3854
offset = 0
3955
filteredNo: number[] = []
4056

src/store/variant.ts

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { get } from 'lodash'
2-
import { makeAutoObservable, runInAction } from 'mobx'
2+
import { makeAutoObservable, runInAction, toJS } from 'mobx'
33

44
import { IGridLayout, ReccntCommon, ReccntDisplayItem } from '@declarations'
55
import { getApiUrl } from '@core/get-api-url'
6+
import { IReccntArguments } from '@service-providers/dataset-level/dataset-level.interface'
67
import datasetStore from './dataset'
78

89
const DRAWER_DEFAULT_WIDTH = 6
@@ -126,21 +127,38 @@ export class VariantStore {
126127
async fetchVarinatInfoAsync() {
127128
if (datasetStore.isXL) return
128129

129-
const details = datasetStore.wsRecords.find(
130-
record => record.no === this.index,
130+
const details = toJS(
131+
datasetStore.wsRecords.find(record => record.no === this.index),
131132
)
132133

134+
const label = details?.lb
135+
const geneNameInBrackets = label?.split(' ')[0] ?? ''
136+
const geneName = geneNameInBrackets.slice(1, geneNameInBrackets.length - 1)
137+
138+
const isVariantWithoutGene = geneName === 'None'
139+
140+
// create reccntBody with URLSearchParams
141+
const reccntArguments: IReccntArguments = {
142+
ds: this.dsName,
143+
rec: String(this.index),
144+
}
145+
146+
if (!isVariantWithoutGene) {
147+
reccntArguments.details = details?.dt
148+
}
149+
150+
const reccntArgumentsList = Object.entries(reccntArguments)
151+
const reccntBody = new URLSearchParams()
152+
153+
reccntArgumentsList.forEach(element => {
154+
reccntBody.append(element[0], element[1])
155+
})
156+
133157
const [variantResponse, tagsResponse] = await Promise.all([
134-
fetch(
135-
getApiUrl(
136-
`reccnt?ds=${this.dsName}&rec=${this.index}&details=${
137-
details ? details.dt : ''
138-
}`,
139-
),
140-
{
141-
method: 'POST',
142-
},
143-
),
158+
fetch(getApiUrl('reccnt'), {
159+
method: 'POST',
160+
body: reccntBody,
161+
}),
144162
fetch(getApiUrl(`ws_tags?ds=${this.dsName}&rec=${this.index}`)),
145163
])
146164

0 commit comments

Comments
 (0)