-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from davewalker5/MC-256-Purchase-Retailer-Bug
Fixup purchase details retailer selection bug
- Loading branch information
Showing
6 changed files
with
78 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
FROM node:20-alpine | ||
COPY musiccatalogue.ui-1.25.0.0 /opt/musiccatalogue.ui-1.25.0.0 | ||
WORKDIR /opt/musiccatalogue.ui-1.25.0.0 | ||
COPY musiccatalogue.ui-1.26.0.0 /opt/musiccatalogue.ui-1.26.0.0 | ||
WORKDIR /opt/musiccatalogue.ui-1.26.0.0 | ||
RUN npm install | ||
RUN npm run build | ||
ENTRYPOINT [ "npm", "start" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import Select from "react-select"; | ||
import useRetailers from "@/hooks/useRetailers"; | ||
import { useState } from "react"; | ||
|
||
/** | ||
* Component to display the retailer selector | ||
* @param {*} initialRetailer | ||
* @param {*} retailerChangedCallback | ||
* @param {*} logout | ||
* @returns | ||
*/ | ||
const RetailerSelector = ({ | ||
initialRetailer, | ||
retailerChangedCallback, | ||
logout, | ||
}) => { | ||
const { retailers, setRetailers } = useRetailers(logout); | ||
|
||
let options = []; | ||
if (retailers.length > 0) { | ||
// Construct the options for the retailers drop-down | ||
for (let i = 0; i < retailers.length; i++) { | ||
options = [ | ||
...options, | ||
{ value: retailers[i].id, label: retailers[i].name }, | ||
]; | ||
} | ||
} | ||
|
||
// Determine the initial selection | ||
let selectedOption = null; | ||
if (initialRetailer != null) { | ||
selectedOption = options.find((x) => x.value === initialRetailer.id); | ||
} | ||
|
||
// Set up state | ||
const [retailer, setRetailer] = useState(selectedOption); | ||
|
||
// Callback to update the genre state and notify the parent component | ||
// that the genre has changed | ||
const retailerChanged = (e) => { | ||
// Update local state with the selected option | ||
const updatedSelection = options.find((x) => x.value === e.value); | ||
setRetailer(updatedSelection); | ||
|
||
// Notify the parent component with a partial retailer object | ||
retailerChangedCallback({ | ||
id: updatedSelection.value, | ||
name: updatedSelection.label, | ||
}); | ||
}; | ||
|
||
return ( | ||
<Select | ||
value={selectedOption} | ||
onChange={retailerChanged} | ||
options={options} | ||
/> | ||
); | ||
}; | ||
|
||
export default RetailerSelector; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters