-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
948 additions
and
369 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
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,84 @@ | ||
import React, { useState } from "react"; | ||
import { makeStyles } from "@material-ui/core/styles"; | ||
import Typography from "@material-ui/core/Typography"; | ||
import { Chip } from "@material-ui/core"; | ||
import Accordion from "@material-ui/core/Accordion"; | ||
import AccordionSummary from "@material-ui/core/AccordionSummary"; | ||
import Button from "@material-ui/core/Button"; | ||
import Alert from "@material-ui/lab/Alert"; | ||
|
||
import { getPurchaseParams } from "../services/udRegistry"; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
grow: { | ||
flexGrow: 1, | ||
paddingLeft: 30, | ||
}, | ||
buy: { | ||
marginLeft: 16, | ||
fontWeight: "bold", | ||
}, | ||
acc: { | ||
marginBottom: 16, | ||
}, | ||
accSum: { | ||
"& > .Mui-expanded": { | ||
margin: "initial", | ||
}, | ||
}, | ||
})); | ||
|
||
const BuyDomain = ({ name, status, price }) => { | ||
const classes = useStyles(); | ||
|
||
const [fetched, setFetched] = useState(true); | ||
const [error, setError] = useState(undefined); | ||
|
||
const handleBuy = async () => { | ||
try { | ||
setError(undefined); | ||
setFetched(false); | ||
const res = await getPurchaseParams(name); | ||
console.log("RES", res); | ||
} catch (error) { | ||
console.error(error.message); | ||
// setError(error.message); | ||
setError("Comming soon..."); | ||
} finally { | ||
setFetched(true); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<Accordion className={classes.acc}> | ||
<AccordionSummary className={classes.accSum}> | ||
<Typography style={{ fontWeight: "bold", fontSize: 20 }} noWrap> | ||
{name} | ||
</Typography> | ||
<Chip | ||
color="primary" | ||
style={{ backgroundColor: "green", marginLeft: 16 }} | ||
label={status} | ||
/> | ||
<div className={classes.grow}></div> | ||
<Typography style={{ fontWeight: "bold", fontSize: 20 }} noWrap> | ||
USD {(price / 100).toFixed(2)} | ||
</Typography> | ||
<Button | ||
onClick={handleBuy} | ||
className={classes.buy} | ||
variant="contained" | ||
color="primary" | ||
disabled={!fetched} | ||
> | ||
Buy | ||
</Button> | ||
</AccordionSummary> | ||
</Accordion> | ||
{error && <Alert severity="error">{error}</Alert>} | ||
</> | ||
); | ||
}; | ||
|
||
export default BuyDomain; |
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.