Skip to content

Commit f2f4f42

Browse files
committed
providers
1 parent d6d3560 commit f2f4f42

4 files changed

Lines changed: 76 additions & 15 deletions

File tree

demo/app/src/components/Sidebar/Sidebar.js

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,21 @@ export default function Sidebar(props) {
2121
products,
2222
isLoadingProducts,
2323
isErrorProducts,
24+
userParams,
25+
setUserParams,
26+
providers
2427
} = useAppContext();
25-
console.log('🚀 ~ file: Sidebar.js:24 ~ Sidebar ~ products:', products)
28+
29+
function providerSelectHandler(e) {
30+
setUserParams({
31+
...userParams,
32+
provider: e.target.value
33+
})
34+
}
35+
36+
function isProviderSelected(provider) {
37+
return provider === userParams.provider;
38+
}
2639

2740
const filterButtonClass = openFilters
2841
? styles.filterButtonOpen
@@ -34,35 +47,62 @@ export default function Sidebar(props) {
3447
<>
3548
<div className={styles.topBar}>
3649
<h3 className={styles.heading}>Opportunities</h3>
37-
<Button className={filterButtonClass} onClick={() => setOpenFilters(!openFilters)}>
50+
<Button
51+
className={filterButtonClass}
52+
onClick={() => setOpenFilters(!openFilters)}
53+
>
3854
<HorizontalSlidersLines size={12} />
3955
</Button>
4056
<Button className={styles.sortButton}>
41-
Sort
57+
Sort
4258
<AlignJustifyDown size={12} className={styles.sortIcon} />
4359
</Button>
4460
</div>
4561

46-
{!errorOpps && (
47-
<OpportunityList/>
48-
)}
62+
{!errorOpps && <OpportunityList />}
4963

5064
{!!errorOpps && <div>There was error</div>}
51-
65+
5266
{!!openFilters && (
5367
<div className={styles.filtersFlyout}>
5468
<div className={styles.filtersTopBar}>
5569
<h4>Filters</h4>
56-
<Button className={styles.closeButton} onClick={() => setOpenFilters(false)}>
70+
<Button
71+
className={styles.closeButton}
72+
onClick={() => setOpenFilters(false)}
73+
>
5774
<ArrowRightLine size={12} />
5875
</Button>
5976
</div>
6077
<div className={styles.filtersBody}>
61-
{products.length && (<select>
62-
{products.map(({ title, id }) => {
63-
return (<option key={id} value={id}>{title}</option>)
64-
})}
65-
</select>)}
78+
<div>
79+
<span>Providers: </span>
80+
<select onChange={providerSelectHandler}>
81+
{providers.map((provider) => (
82+
<option
83+
value={provider.id}
84+
key={provider.id}
85+
selected={isProviderSelected(provider.id)}
86+
>
87+
{provider.name}
88+
</option>
89+
))}
90+
</select>
91+
</div>
92+
<div>
93+
<div className={styles.blockLabel}>Products: </div>
94+
{products.length && (
95+
<select>
96+
{products.map(({ title, id }) => {
97+
return (
98+
<option key={id} value={id}>
99+
{title}
100+
</option>
101+
);
102+
})}
103+
</select>
104+
)}
105+
</div>
66106
</div>
67107
</div>
68108
)}

demo/app/src/components/Sidebar/Sidebar.module.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@
9999

100100
.filtersBody {
101101
padding-left: 5px;
102+
text-align: left;
103+
104+
.blockLabel {
105+
display: block;
106+
text-align: left;
107+
padding: 0;
108+
}
102109
}
103110
}
104111

demo/app/src/context/appContext.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ export default function AppProvider({ children }) {
4040

4141
const { isLoading: isLoadingOpps, data: opportunities, error: errorOpps } = usePostRequest(postParams);
4242
const { isLoading: isLoadingProducts, data: products, error: errorProducts } = useGetRequest();
43+
const providers = [{
44+
id: 'historical',
45+
name: 'Historical'
46+
}, {
47+
id: 'blacksky',
48+
name: 'BlackSky'
49+
}, {
50+
id: 'planet',
51+
name: 'Planet'
52+
}, {
53+
id: 'umbra',
54+
name: 'Umbra'
55+
}]
4356

4457
const app = {
4558
userParams,
@@ -56,7 +69,8 @@ export default function AppProvider({ children }) {
5669
setHoveredOpportunity,
5770
openFilters,
5871
setOpenFilters,
59-
setHoveredOpportunity
72+
setHoveredOpportunity,
73+
providers
6074
}
6175

6276
return (

demo/app/src/hooks/usePostRequest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const usePostRequest = (postParams) => {
2626
setIsLoading(false);
2727
});
2828
}
29-
}, [params]);
29+
}, [params, provider]);
3030

3131
return { data, isLoading, error };
3232
};

0 commit comments

Comments
 (0)