-
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.
Refactor API helper into one API helper per entity type
- Loading branch information
1 parent
2a948db
commit 756de2b
Showing
32 changed files
with
680 additions
and
451 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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import styles from "./albumPurchaseDetails.module.css"; | ||
import DatePicker from "react-datepicker"; | ||
import { useState } from "react"; | ||
import CurrencyInput from "react-currency-input-field"; | ||
import config from "../config.json"; | ||
|
||
/** | ||
* Form to set the album purchase details for an album | ||
* @param {*} artist | ||
* @param {*} album | ||
* @param {*} isWishList | ||
* @param {*} navigate | ||
* @param {*} logout | ||
*/ | ||
const AlbumPurchaseDetails = ({ artist, album, navigate, logout }) => { | ||
// Get the retailer name and purchase date from the album | ||
const retailerObject = album["retailer"]; | ||
const retailerName = retailerObject != null ? retailerObject["name"] : null; | ||
const currentPurchaseDate = | ||
album.purchased != null ? new Date(album.purchased) : new Date(); | ||
|
||
// Set up state | ||
const [purchaseDate, setPurchaseDate] = useState(currentPurchaseDate); | ||
const [price, setPrice] = useState(album.price); | ||
const [retailer, setRetailer] = useState(retailerName); | ||
|
||
return ( | ||
<> | ||
<div className="row mb-2 pageTitle"> | ||
<h5 className="themeFontColor text-center"> | ||
{album.title} - {artist.name} - Purchase Details | ||
</h5> | ||
</div> | ||
<div className={styles.purchaseDetailsFormContainer}> | ||
<div className={styles.purchaseDetailsForm}> | ||
<div> | ||
{album.isWishListItem == true ? ( | ||
<></> | ||
) : ( | ||
<div className="form-group mt-3"> | ||
<label className={styles.purchaseDetailsFormLabel}> | ||
Purchase Date | ||
</label> | ||
<div> | ||
<DatePicker | ||
selected={purchaseDate} | ||
onChange={(date) => setPurchaseDate(date)} | ||
/> | ||
</div> | ||
</div> | ||
)} | ||
<div className="form-group mt-3"> | ||
<label className={styles.purchaseDetailsFormLabel}>Price</label> | ||
<div> | ||
<CurrencyInput | ||
placeholder="Price" | ||
name="price" | ||
defaultValue={price} | ||
decimalsLimit={2} | ||
allowNegativeValue={false} | ||
disableAbbreviations={true} | ||
intlConfig={{ | ||
locale: config.region.locale, | ||
currency: config.region.currency, | ||
}} | ||
onValueChange={(value, _) => setPrice(value)} | ||
/> | ||
</div> | ||
</div> | ||
<div className="form-group mt-3"> | ||
<label className={styles.purchaseDetailsFormLabel}> | ||
Retailer | ||
</label> | ||
<input | ||
className="form-control mt-1" | ||
placeholder="Retailer Name" | ||
name="retailer" | ||
value={retailer} | ||
onChange={(e) => setRetailer(e.target.value)} | ||
/> | ||
</div> | ||
<div className="d-grid gap-2 mt-3"></div> | ||
<div className={styles.purchaseDetailsButton}> | ||
<button className="btn btn-primary">Save</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default AlbumPurchaseDetails; |
21 changes: 21 additions & 0 deletions
21
src/music-catalogue-ui/components/albumPurchaseDetails.module.css
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,21 @@ | ||
.purchaseDetailsFormContainer { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.purchaseDetailsForm { | ||
width: 420px; | ||
padding-top: 20px; | ||
padding-bottom: 20px; | ||
} | ||
|
||
.purchaseDetailsFormLabel { | ||
font-size: 14px; | ||
font-weight: 600; | ||
color: rgb(34, 34, 34); | ||
} | ||
|
||
.purchaseDetailsButton { | ||
float: right; | ||
} |
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
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
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
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
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
Oops, something went wrong.