Skip to content

Commit

Permalink
TODO: autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
WinWisely268 committed Mar 16, 2021
1 parent 0f805e0 commit 1b12231
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 16 deletions.
3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"@aws-amplify/ui-react": "^1.0.3",
"@material-ui/core": "^4.11.3",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.57",
"@material-ui/pickers": "^3.2.10",
"@material-ui/styles": "^4.11.3",
"aws-amplify": "^3.3.22",
Expand All @@ -18,13 +19,13 @@
"graphql-tag": "^2.11.0",
"ky": "^0.27.0",
"match-sorter": "^6.3.0",
"react-table": "^7.6.3",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-dropzone": "^11.3.1",
"react-json-view": "^1.21.3",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"react-table": "^7.6.3",
"subscriptions-transport-ws": "^0.9.18",
"uuid": "^8.3.2",
"web-vitals": "^0.2.4",
Expand Down
35 changes: 20 additions & 15 deletions frontend/src/components/products/NewProduct.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,26 @@ export const NewProduct: React.FC<NewProductProps> = ({

const submitNewProduct = (e: any) => {
e.preventDefault()
insertProduct({
variables: {
sku: values.sku,
name: values.name!,
sellable: values.sellable,
buyPrice: values.buy_price,
bestPrice: values.best_price,
downlinePrice: values.downline_price,
retailPrice: values.retail_price
}
}).then((data) => {
refetchAction()
}).catch((e) => {
setErrMsg(e.message)
})
if (!update) {
insertProduct({
variables: {
sku: values.sku,
name: values.name!,
sellable: values.sellable,
buyPrice: values.buy_price,
bestPrice: values.best_price,
downlinePrice: values.downline_price,
retailPrice: values.retail_price
}
}).then((data) => {
refetchAction()
}).catch((e) => {
setErrMsg(e.message)
})
} else {

}

}

return (
Expand Down
38 changes: 38 additions & 0 deletions frontend/src/components/shared/AutoCompleteField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';

export interface AutoCompleteFieldProps {

}

export const AutoCompleteField : React.FC<AutoCompleteFieldProps> = () => {

return (
<div style={{ width: 300 }}>
<Autocomplete
id="free-solo-demo"
freeSolo
options={top100Films.map((option) => option.title)}
renderInput={(params) => (
<TextField {...params} label="freeSolo" margin="normal" variant="outlined" />
)}
/>
<Autocomplete
freeSolo
id="free-solo-2-demo"
disableClearable
options={top100Films.map((option) => option.title)}
renderInput={(params) => (
<TextField
{...params}
label="Search input"
margin="normal"
variant="outlined"
InputProps={{ ...params.InputProps, type: 'search' }}
/>
)}
/>
</div>
);
}
11 changes: 11 additions & 0 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3615,6 +3615,17 @@
dependencies:
"@babel/runtime" "^7.4.4"

"@material-ui/lab@^4.0.0-alpha.57":
version "4.0.0-alpha.57"
resolved "https://registry.yarnpkg.com/@material-ui/lab/-/lab-4.0.0-alpha.57.tgz#e8961bcf6449e8a8dabe84f2700daacfcafbf83a"
integrity sha512-qo/IuIQOmEKtzmRD2E4Aa6DB4A87kmY6h0uYhjUmrrgmEAgbbw9etXpWPVXuRK6AGIQCjFzV6WO2i21m1R4FCw==
dependencies:
"@babel/runtime" "^7.4.4"
"@material-ui/utils" "^4.11.2"
clsx "^1.0.4"
prop-types "^15.7.2"
react-is "^16.8.0 || ^17.0.0"

"@material-ui/pickers@^3.2.10":
version "3.2.10"
resolved "https://registry.yarnpkg.com/@material-ui/pickers/-/pickers-3.2.10.tgz#19df024895876eb0ec7cd239bbaea595f703f0ae"
Expand Down

0 comments on commit 1b12231

Please sign in to comment.