Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit c2fb04c

Browse files
committed
fix: impact area of url params reader
Signed-off-by: Neha Gupta <[email protected]>
1 parent 5900351 commit c2fb04c

File tree

6 files changed

+17
-15
lines changed

6 files changed

+17
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ npm i
4646
```
4747
For development, we'll add the API URL as local keploy server url running at http://localhost:6789
4848
```shell
49-
export GATSBY_API_URL=http://localhost:6879/api
49+
export GATSBY_API_URL=http://localhost:6789/api
5050
```
5151

5252
Now let's start the Gatsby Server

src/components/testlist/tcs-detail.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ export default function TcsDetail(props: TcsDetailProps) {
4545
}
4646

4747
const data = tc.testCase[0]
48-
4948
const handleChange = (_: React.SyntheticEvent, newValue: number) => {
5049
setValue(newValue)
5150
}

src/components/testlist/test-list.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import ErrorView from "../global/error"
1414
import { a11yProps, CustomTab, TabPanelBox } from "../global/tab-panel"
1515
import { Link,navigate } from "gatsby";
1616

17-
import { useQueryParamString } from 'react-use-query-param-string';
17+
import { getQueryParams } from "react-use-query-param-string";
1818
// import {NumberParam, StringParam, useQueryParam} from "use-query-params"
1919
import { POLLING_INTERVAL } from "../../constants";
2020

@@ -36,8 +36,9 @@ const useStyles = makeStyles(() => ({
3636

3737
export default function TestList() {
3838
const classes = useStyles()
39-
const [index=0]= useQueryParamString("index", '')
40-
const [tcId=""]=useQueryParamString("tcId",'')
39+
const params = getQueryParams()
40+
const index= params["index"]?params["index"].toString(): '0'
41+
const tcId=params["tcId"]?params["tcId"].toString(): ''
4142
const [value, setValue] = React.useState<number>(Number(index)? Number(index) : 0)
4243
const [tc, setTc] = React.useState(tcId)
4344

src/components/testrun/test-tab.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface TestTabProps {
2626
editMode: boolean
2727
tdId:string | null | undefined
2828
testRunID:string
29-
index:string | null
29+
index: number | null
3030
data: TestRunData
3131
}
3232

@@ -162,6 +162,7 @@ export default function TestTab(props: TestTabProps) {
162162
event.defaultMuiPrevented = true
163163
let t = props.tests.filter((item) => item.id == params.id)
164164
setTcData(t[0])
165+
console.log("?id="+testRunID+"&index="+index+"&tdId="+t[0].id)
165166
navigate("?id="+testRunID+"&index="+index+"&tdId="+t[0].id)
166167
}}
167168
components={{ Toolbar: CustomToolbar }} />
@@ -177,6 +178,7 @@ export default function TestTab(props: TestTabProps) {
177178
checkboxSelection={true}
178179
isRowSelectable={(params: GridRowParams) => params.row["status"] == TestStatus.FAILED}
179180
onRowClick={(params: GridRowParams, event: MuiEvent<React.MouseEvent>) => {
181+
console.log(tdId)
180182
event.defaultMuiPrevented = true
181183
let t = props.tests.filter((item) => item.id == params.id)
182184
setTcData(t[0])

src/pages/testlist/tc.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { CLIENT } from "../../constants"
2-
// import { StringParam, useQueryParam } from "use-query-params"
3-
import { useQueryParamString } from 'react-use-query-param-string';
2+
import { getQueryParams } from 'react-use-query-param-string';
43
import { navigate } from "gatsby"
54
import { ApolloProvider } from "@apollo/client"
65
import { ThemeProvider } from "@mui/material/styles"
@@ -15,7 +14,8 @@ export default function TestCase() {
1514
return null
1615
}
1716

18-
const [id] = useQueryParamString("id", '')
17+
const params = getQueryParams()
18+
const id = params["id"]? params["id"].toString(): ""
1919
if (id == null) {
2020
typeof window !== `undefined` && navigate("/testlist")
2121
}

src/pages/testruns/detail.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import Layout from "../../components/global/layout"
44
import SEO from "../../components/global/seo"
55
import { navigate } from "gatsby"
66
import React from "react"
7-
import { useQueryParamString } from 'react-use-query-param-string';
8-
// import { StringParam,NumberParam, useQueryParam } from "use-query-params"
7+
import { getQueryParams } from "react-use-query-param-string";
98
import TestRunDetail from "../../components/testrun/testrun-detail"
109
import { ThemeProvider } from "@mui/material/styles"
1110
import { theme } from "../../services/services"
@@ -15,9 +14,10 @@ export default function Detail() {
1514
return null
1615
}
1716

18-
const [id] = useQueryParamString("id", '')
19-
const [index='0'] = useQueryParamString("index",'0' )
20-
const [tdId=""]=useQueryParamString("tdId",'')
17+
const params = getQueryParams();
18+
const id = params['id']? params['id'].toString(): ""
19+
const index = params['index']? params['index']: '0'
20+
const tdId= params['tdId']? params['tdId'].toString(): ""
2121

2222
if (id == null) {
2323
typeof window !== `undefined` && navigate("/testruns")
@@ -27,7 +27,7 @@ export default function Detail() {
2727
<ThemeProvider theme={theme}>
2828
<Layout>
2929
<SEO title="Testrun Details" />
30-
<TestRunDetail testRunID={id!} index={index.toString()} tdId={tdId} />
30+
<TestRunDetail testRunID={id!} index={Number(index)} tdId={tdId} />
3131
</Layout>
3232
</ThemeProvider>
3333
</ApolloProvider>

0 commit comments

Comments
 (0)