-
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.
Add the ability to add new retailers with full details
- Loading branch information
1 parent
1c6e7bf
commit debb5b5
Showing
11 changed files
with
294 additions
and
53 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.23.0.0 /opt/musiccatalogue.ui-1.23.0.0 | ||
WORKDIR /opt/musiccatalogue.ui-1.23.0.0 | ||
COPY musiccatalogue.ui-1.24.0.0 /opt/musiccatalogue.ui-1.24.0.0 | ||
WORKDIR /opt/musiccatalogue.ui-1.24.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
59 changes: 59 additions & 0 deletions
59
src/music-catalogue-ui/components/deleteRetailerActionIcon.js
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,59 @@ | ||
import { useCallback } from "react"; | ||
import { apiDeleteRetailer, apiFetchRetailers } from "@/helpers/apiRetailers"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { faTrashAlt } from "@fortawesome/free-solid-svg-icons"; | ||
|
||
/** | ||
* Icon and associated action to delete a retailer | ||
* @param {*} retailer | ||
* @param {*} logout | ||
* @param {*} clearError | ||
* @param {*} setError | ||
* @param {*} setRetailers | ||
* @returns | ||
*/ | ||
const DeleteRetailerActionIcon = ({ | ||
retailer, | ||
logout, | ||
clearError, | ||
setError, | ||
setRetailers, | ||
}) => { | ||
/* Callback to prompt for confirmation and delete a retailer */ | ||
const confirmDeleteRetailer = useCallback( | ||
async (e, album) => { | ||
// Prevent the default action associated with the click event | ||
e.preventDefault(); | ||
|
||
// Clear any pre-existing error messages | ||
clearError(); | ||
|
||
// Show a confirmation message and get the user response | ||
const message = `This will delete the retailer "${retailer.name}" - click OK to confirm`; | ||
const result = confirm(message); | ||
|
||
// If they've confirmed the deletion ... | ||
if (result) { | ||
// ... delete the retailer and confirm the API call was successful | ||
const result = await apiDeleteRetailer(retailer.id, logout); | ||
if (result) { | ||
// Successful, so refresh the retailer list | ||
const fetchedRetailers = await apiFetchRetailers(logout); | ||
setRetailers(fetchedRetailers); | ||
} else { | ||
setError(`An error occurred deleting retailer "${retailer.name}"`); | ||
} | ||
} | ||
}, | ||
[retailer, logout, clearError, setError, setRetailers] | ||
); | ||
|
||
return ( | ||
<FontAwesomeIcon | ||
icon={faTrashAlt} | ||
onClick={(e) => confirmDeleteRetailer(e, retailer)} | ||
/> | ||
); | ||
}; | ||
|
||
export default DeleteRetailerActionIcon; |
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,12 @@ | ||
.retailerListErrorContainer { | ||
text-align: center; | ||
margin-top: 10px; | ||
margin-bottom: 10px; | ||
font-weight: bold; | ||
color: red; | ||
} | ||
|
||
.retailerListButton { | ||
margin-left: 10px; | ||
float: right; | ||
} |
Oops, something went wrong.