Skip to content

Commit

Permalink
New Dropdown file edit
Browse files Browse the repository at this point in the history
  • Loading branch information
manifau committed May 13, 2021
1 parent 94464c0 commit 2ddfc3e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
45 changes: 45 additions & 0 deletions frontend/src/components/productGrid/DropdownButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React, { useContext, useState } from "react";
import { getModels } from "interface/simaProInterface";
import Select from "react-select";
import { PrivateSectionContext } from "resources/PrivateSectionContext";

const SelectModelVariable = (props) => {
const productID = props.productID;
const productName = props.productName;
const [selectedProducts, setSelectedProducts] = useContext(
PrivateSectionContext
);
const variables = getModels(productID);
const [selected, setSelected] = useState("Select a model");

return (
<Select
options={variables}
onChange={(props) => {
console.log(props);
variables.map((item) => (
<a
onClick={(props) => {
const newSelectedProducts = [
{
productID: productID,
productName: productName,
modelID: item.modelID,
modelName: item.modelName
}
];
setSelected(item.modelName);
setSelectedProducts(newSelectedProducts);
}}
className="w3-bar-item w3-button"
key={item.modelID}
>
{item.modelName}
</a>
));
}}
/>
);
};

export default SelectModelVariable;
2 changes: 2 additions & 0 deletions frontend/src/components/productGrid/ProductGridComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {Link} from 'react-router-dom';
import {PrivateSectionContext} from 'hooks/PrivateSectionContext';




function ProductGridComponent() {
const [ selectedProducts, setSelectedProducts ] = useContext(PrivateSectionContext);
const NewSelectedProducts =
Expand Down

0 comments on commit 2ddfc3e

Please sign in to comment.