Skip to content

Commit

Permalink
fix: 🐛 fix: detail pages when refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
waynewyang committed Jan 10, 2024
1 parent 0b9a542 commit 9d0aec0
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 90 deletions.
110 changes: 57 additions & 53 deletions src/pages/dataset/detail/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,61 +31,65 @@ export default () => {
useState<ValueFields<DatasetMetadata>>()
const [datasetProofMeta, setDatasetProofMeta] =
useState<ValueFields<DatasetProofMetadata>>()

const tabItems = convertDataToItems({
messasge: (
<MessageTable
queryParam={{
network: "calibration",
queryFilter: {
...defaultTableQueryParams,
conditions: [{ datasetId: id }],
},
}}
/>
),
car: (
<CarTable
queryParam={{
network: "calibration",
queryFilter: {
...defaultTableQueryParams,
conditions: [{ datasetId: id }],
},
}}
/>
),
// requirement: (
// <DatasetRequirementBasicTable
// queryParam={{
// network: "calibration",
// queryFilter: {
// ...defaultTableQueryParams,
// conditions: [{ datasetId: id }],
// },
// }}
// />
// ),
})
const [tabItems, setTabItems] = useState<any>()

useEffect(() => {
getDatasetMetadata({
network: "calibration",
queryFilter: { conditions: [{ datasetId: id }] },
}).then((res) => {
const datasetMetadata = res.data
//TODO
setDatasetMetadata(datasetMetadata![0])
})
getDatasetProofMetadata({
network: "calibration",
queryFilter: { conditions: [{ datasetId: id }] },
}).then((res) => {
const datasetMetadata = res.data
//TODO
setDatasetProofMeta(datasetMetadata![0])
})
}, [])
if (id) {
getDatasetMetadata({
network: "calibration",
queryFilter: { conditions: [{ datasetId: id }] },
}).then((res) => {
const datasetMetadata = res.data
//TODO
setDatasetMetadata(datasetMetadata![0])
})
getDatasetProofMetadata({
network: "calibration",
queryFilter: { conditions: [{ datasetId: id }] },
}).then((res) => {
const datasetMetadata = res.data
//TODO
setDatasetProofMeta(datasetMetadata![0])
})
setTabItems(
convertDataToItems({
messasge: (
<MessageTable
queryParam={{
network: "calibration",
queryFilter: {
...defaultTableQueryParams,
conditions: [{ datasetId: id }],
},
}}
/>
),
car: (
<CarTable
queryParam={{
network: "calibration",
queryFilter: {
...defaultTableQueryParams,
conditions: [{ datasetId: id }],
},
}}
/>
),
// requirement: (
// <DatasetRequirementBasicTable
// queryParam={{
// network: "calibration",
// queryFilter: {
// ...defaultTableQueryParams,
// conditions: [{ datasetId: id }],
// },
// }}
// />
// ),
})
)
}
}, [id])

return (
<>
Expand Down
65 changes: 37 additions & 28 deletions src/pages/matching/detail/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,45 @@ export default () => {
const router = useRouter()
const { id } = router.query
const [overview, setOverview] = useState<ValueFields<MatchingMetadata>>()

const tabItems = convertDataToItems({
messasge: (
<MessageBasicPage
queryParam={{
network: "calibration",
queryFilter: { conditions: [{ matchingId: id }] },
}}
/>
),
carReplica: (
<CarReplicaPage
queryParam={{
network: "calibration",
queryFilter: { conditions: [{ matchingId: id }] },
}}
/>
),
})
const [tabItems, setTabItems] = useState<any>()

useEffect(() => {
getMatchingMetadata({
network: "calibration",
queryFilter: { conditions: [{ matchingId: id }] },
}).then((res) => {
const datasetMetadata = res.data
//TODO
setOverview(datasetMetadata![0])
})
}, [])
if (id) {
setTabItems(
convertDataToItems({
messasge: (
<MessageBasicPage
queryParam={{
network: "calibration",
queryFilter: {
conditions: [{ matchingId: id }],
},
}}
/>
),
carReplica: (
<CarReplicaPage
queryParam={{
network: "calibration",
queryFilter: {
conditions: [{ matchingId: id }],
},
}}
/>
),
})
)

getMatchingMetadata({
network: "calibration",
queryFilter: { conditions: [{ matchingId: id }] },
}).then((res) => {
const datasetMetadata = res.data
//TODO
setOverview(datasetMetadata![0])
})
}
}, [id])

return (
<>
Expand Down
20 changes: 11 additions & 9 deletions src/pages/message/detail/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ export default () => {
useState<ValueFields<DataswapMessage>>()

useEffect(() => {
getDataswapMessage({
network: "calibration",
queryFilter: { conditions: [{ cid: { "/": id } }] },
}).then((res) => {
const datasetMetadata = res.data
//TODO
setDatasetMetadata(datasetMetadata![0])
})
}, [])
if (id) {
getDataswapMessage({
network: "calibration",
queryFilter: { conditions: [{ cid: { "/": id } }] },
}).then((res) => {
const datasetMetadata = res.data
//TODO
setDatasetMetadata(datasetMetadata![0])
})
}
}, [id])

return (
<>{datasetMetadata && <MessageDescription data={datasetMetadata} />}</>
Expand Down

0 comments on commit 9d0aec0

Please sign in to comment.