Skip to content

Commit 62ee0c8

Browse files
committed
a bit hacky still but working
1 parent fe70979 commit 62ee0c8

File tree

2 files changed

+12
-52
lines changed

2 files changed

+12
-52
lines changed

src/components/Filter/Filter.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ const Filter = () => {
7878

7979
const filterContainer = []
8080

81-
if (_selectedProductData?.queryables?.properties == null) return null
81+
if (_selectedProductData?.constraints?.properties == null) return null
8282
for (const constraintName of Object.keys(
83-
_selectedProductData.queryables.properties
83+
_selectedProductData.constraints.properties
8484
)) {
8585
const constraint =
86-
_selectedProductData.queryables.properties[constraintName]
86+
_selectedProductData.constraints.properties[constraintName]
8787
if (constraint.type === 'integer') {
8888
filterContainer.push(
8989
<FormControl key={constraintName} sx={{ marginTop: 4 }}>
@@ -108,7 +108,7 @@ const Filter = () => {
108108
})
109109
)
110110
}}
111-
required={_selectedProductData.queryables.required.includes(
111+
required={_selectedProductData.constraints.required.includes(
112112
constraintName
113113
)}
114114
/>
@@ -165,7 +165,7 @@ const Filter = () => {
165165
id={constraintName}
166166
name={constraintName}
167167
aria-describedby={constraintName}
168-
required={_selectedProductData.queryables.required.includes(constraintName)}
168+
required={_selectedProductData.constraints.required.includes(constraintName)}
169169
onChange={(event, newValue) => {
170170
store.dispatch(
171171
setSelectedProductFilters({

src/services/get-products-service.js

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,12 @@ import { setProductsData } from '../redux/slices/mainSlice'
22
import { store } from '../redux/store'
33

44
export async function GetProductsService(provider, apikey) {
5-
// const allProductRequests = ALL_PROVIDERS.map(async provider => {
6-
// return fetch('/api/products', {
7-
// headers: new Headers({
8-
// 'Backend': provider.id,
9-
// 'Authorization': `Bearer ${userToken}`
10-
// })
11-
// })
12-
// .then(async res => await res.json())
13-
// .then(data => { return { 'provider': provider.id, 'data': data } })
14-
// });
15-
16-
// Promise.all(allProductRequests).then((results) => {
17-
// store.dispatch(setProductsData(Object.fromEntries(Object.values(results).map(value => {
18-
// return value.data.products
19-
// }))))
20-
// }).catch(e => setError(e));
215

226
const PROVIDERS = [
237
{ id: 'eusi', url: 'https://apps.euspaceimaging.com/test/internal/stapi' }
248
]
259

26-
const allProductRequests = PROVIDERS_URLS.map(async (providerData) => {
10+
const allProductRequests = PROVIDERS.map(async (providerData) => {
2711
// Get all products meta data
2812
const productMetaResponse = await fetch(providerData.url + '/products', {
2913
method: 'GET'
@@ -55,33 +39,10 @@ export async function GetProductsService(provider, apikey) {
5539
})
5640

5741
const results = await Promise.all(allProductRequests)
42+
console.log('products', results[0].productList)
43+
store.dispatch(setProductsData(results[0].productList))
5844

59-
// for (const url of baseurls) {
60-
// // Get all products meta data
61-
// const productMetaResponse = await fetch(url, { method: 'GET' }).then(
62-
// (res) => res.json()
63-
// )
64-
65-
// // Get all constraints
66-
// for (const product of productMetaResponse) {
67-
// const constraints = await fetch(url + `/${product.id}/constraints`).then(
68-
// (res) => res.json()
69-
// )
70-
71-
// const productParameters = await fetch(
72-
// url + `/${product.id}/product-parameters`
73-
// ).then((res) => res.json())
74-
75-
// productList.push({
76-
// ...product,
77-
// constraints,
78-
// productParameters
79-
// })
80-
// }
81-
// }
82-
console.log('products', results)
83-
84-
const mockProducts = [
45+
/* const mockProducts = [
8546
{
8647
type: 'Product',
8748
conformsTo: ['https://geojson.org/schema/Polygon.json'],
@@ -261,8 +222,8 @@ export async function GetProductsService(provider, apikey) {
261222
// }
262223
// // }
263224
// // const EUSI_PRODUCTS = [EUSI_MAXAR_OPTICAL_PRODUCT]
264-
265-
switch (provider) {
225+
*/
226+
/* switch (provider) {
266227
case 'eusi':
267228
store.dispatch(setProductsData(eusiProducts))
268229
return
@@ -274,7 +235,6 @@ export async function GetProductsService(provider, apikey) {
274235
return
275236
default:
276237
console.error('Unsupported provider', provider)
277-
}
238+
} */
278239

279-
// store.dispatch(setProductsData(mockProducts))
280240
}

0 commit comments

Comments
 (0)