Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 

282 Zeilen
11 KiB

  1. import React from 'react';
  2. import { makeStyles } from '@material-ui/core/styles';
  3. import SnackbarContent from "components/Snackbar/SnackbarContent.js";
  4. import Button1 from "components/CustomButtons/Button.js";
  5. import image1 from "../../../assets/img/mail.png"
  6. import GridContainer from "components/Grid/GridContainer.js";
  7. import Card from "components/Card/Card.js";
  8. import classNames from "classnames";
  9. import Icon from "@material-ui/core/Icon";
  10. import Stepper from '@material-ui/core/Stepper';
  11. import Step from '@material-ui/core/Step';
  12. import StepLabel from '@material-ui/core/StepLabel';
  13. import StepContent from '@material-ui/core/StepContent';
  14. import Paper from '@material-ui/core/Paper';
  15. import Grid from '@material-ui/core/Grid';
  16. import TextField from '@material-ui/core/TextField';
  17. import Button from '@material-ui/core/Button';
  18. import Dialog from '@material-ui/core/Dialog';
  19. import ListItemText from '@material-ui/core/ListItemText';
  20. import ListItem from '@material-ui/core/ListItem';
  21. import List from '@material-ui/core/List';
  22. import Divider from '@material-ui/core/Divider';
  23. import AppBar from '@material-ui/core/AppBar';
  24. import Toolbar from '@material-ui/core/Toolbar';
  25. import IconButton from '@material-ui/core/IconButton';
  26. import Typography from '@material-ui/core/Typography';
  27. import CloseIcon from '@material-ui/icons/Close';
  28. import Slide from '@material-ui/core/Slide';
  29. const useStyles = makeStyles((theme) => ({
  30. root: {
  31. width: '100%',
  32. },
  33. button: {
  34. marginTop: theme.spacing(1),
  35. marginRight: theme.spacing(1),
  36. },
  37. actionsContainer: {
  38. marginBottom: theme.spacing(2),
  39. },
  40. resetContainer: {
  41. padding: theme.spacing(3),
  42. },
  43. appBar: {
  44. position: 'relative',
  45. },
  46. title: {
  47. marginLeft: theme.spacing(2),
  48. flex: 1,
  49. },
  50. }));
  51. function getSteps() {
  52. return ['Alamat Pengiriman', 'Pesanan Produk', 'Metode Pembayaran'];
  53. }
  54. const Transition = React.forwardRef(function Transition(props, ref) {
  55. return <Slide direction="up" ref={ref} {...props} />;
  56. });
  57. const DataCheckout = function ({ backend, checkoutproduct, ...props }) {
  58. const classes = useStyles();
  59. const [activeStep, setActiveStep] = React.useState(0);
  60. const steps = getSteps();
  61. const handleNext = () => {
  62. setActiveStep((prevActiveStep) => prevActiveStep + 1);
  63. };
  64. const handleBack = () => {
  65. setActiveStep((prevActiveStep) => prevActiveStep - 1);
  66. };
  67. const handleReset = () => {
  68. setActiveStep(0);
  69. };
  70. const [open, setOpen] = React.useState(false);
  71. const handleClickOpen = () => {
  72. setOpen(true);
  73. };
  74. const handleClose = () => {
  75. setOpen(false);
  76. };
  77. const { ...rest } = props;
  78. const imageClasses = classNames(
  79. classes.imgRaised,
  80. classes.imgRoundedCircle,
  81. classes.imgFluid
  82. );
  83. const navImageClasses = classNames(classes.imgRounded, classes.imgGallery);
  84. const CartAlamat = checkoutproduct.map((data) => {
  85. return (
  86. <div align="center">
  87. <img src={image1} style={{width:"1100px"}}/><br></br>
  88. <h4>Alamat Pengiriman</h4>
  89. <hr></hr>
  90. <h5>Yusmar</h5>
  91. <h5>087797315685</h5>
  92. <h5>Thamrin Indrapura Jl.Aipda Karel Satsuit Tubun,17 Ilir, Kec.Ilir Tim.I, Palembang, KOTA PALEMBANG - ILIR TIMUR II, SUMATERA SELATAN, ID 30114</h5>
  93. <Button1 color="info" href={"/yamaha/cart/checkout?s="+data.id}>
  94. <Icon className={classes.icons}>cached</Icon>
  95. Ubah Alamat
  96. </Button1>
  97. </div>
  98. );
  99. })
  100. const CartProdukPesanan = checkoutproduct.map((data) => {
  101. return (
  102. <div align="center">
  103. <GridContainer>
  104. <Grid item xs>
  105. <div align="center">
  106. <h4>Produk Dipesan</h4>
  107. <img className={navImageClasses} width="200px" alt="First slide" src={`${backend}${data.img[0]["url"]}`} />
  108. </div>
  109. </Grid>
  110. <Grid item xs>
  111. <div align="center">
  112. <h4></h4><br></br><br></br><br></br><br></br>
  113. <h5>{data.name}</h5>
  114. </div>
  115. </Grid>
  116. <Grid item xs>
  117. <div align="center">
  118. <h4>Harga Satuan</h4><br></br><br></br><br></br>
  119. <h5>Rp.{data.price}</h5>
  120. </div>
  121. </Grid>
  122. <Grid item xs>
  123. <div align="center">
  124. <h4>Jumlah Unit</h4><br></br><br></br><br></br>
  125. <h5>1 Unit</h5>
  126. </div>
  127. </Grid>
  128. <Grid item xs>
  129. <div align="center">
  130. <h4>Sub Total Produk</h4><br></br><br></br><br></br>
  131. <h5>Total Rp.{data.price}</h5>
  132. </div>
  133. </Grid>
  134. </GridContainer>
  135. <GridContainer style={{padding:"20px"}}>
  136. <Grid item xs style={{padding:"20px"}}>
  137. <TextField
  138. id="outlined-full-width"
  139. label="Pesan"
  140. style={{ margin: 8 }}
  141. placeholder="( Opsional ) Tinggalkan Pesan Kepada Dealer"
  142. fullWidth
  143. margin="normal"
  144. InputLabelProps={{
  145. shrink: true,
  146. }}
  147. variant="outlined"
  148. />
  149. </Grid>
  150. <Grid item xs style={{padding:"20px"}}><br></br>
  151. <Button variant="outlined" color="primary" onClick={handleClickOpen}>
  152. Pilih Opsi Pengiriman
  153. </Button>
  154. <Dialog fullScreen open={open} onClose={handleClose} TransitionComponent={Transition}>
  155. <AppBar className={classes.appBar}>
  156. <Toolbar>
  157. <IconButton edge="start" color="inherit" onClick={handleClose} aria-label="close">
  158. <CloseIcon />
  159. </IconButton>
  160. <Typography variant="h6" className={classes.title}>
  161. Pilih Opsi Pengiriman
  162. </Typography>
  163. <Button autoFocus color="inherit" onClick={handleClose}>
  164. Pilih
  165. </Button>
  166. </Toolbar>
  167. </AppBar>
  168. <List>
  169. <ListItem button>
  170. <ListItemText primary="Reguler" secondary="Akan diterima pada tanggal 2 Apr - 6 Apr" />
  171. </ListItem>
  172. <Divider />
  173. <ListItem button>
  174. <ListItemText primary="Kargo" secondary="Akan diterima pada tanggal 30 Mar - 2 Apr" />
  175. </ListItem>
  176. <ListItem button>
  177. <ListItemText primary="Hemat" secondary="Akan diterima pada tanggal 1 Apr - 4 Apr, COD (Bayar di Tempat) tidak didukung" />
  178. </ListItem>
  179. </List>
  180. </Dialog>
  181. </Grid>
  182. <Grid item xs align="right" style={{padding:"20px"}}><br></br>
  183. Total Rp. {data.price}
  184. </Grid>
  185. </GridContainer>
  186. </div>
  187. );
  188. })
  189. const CartMetodePembayaran = checkoutproduct.map((data) => {
  190. return (
  191. <div align="center">
  192. <img src={image1} style={{width:"1100px"}}/><br></br>
  193. <h4>Alamat Pengiriman</h4>
  194. <hr></hr>
  195. <h5>Yusmar</h5>
  196. <h5>087797315685</h5>
  197. <h5>Thamrin Indrapura Jl.Aipda Karel Satsuit Tubun,17 Ilir, Kec.Ilir Tim.I, Palembang, KOTA PALEMBANG - ILIR TIMUR II, SUMATERA SELATAN, ID 30114</h5>
  198. <Button1 color="info" href={"/yamaha/cart/checkout?s="+data.id}>
  199. <Icon className={classes.icons}>cached</Icon>
  200. Ubah Alamat
  201. </Button1>
  202. </div>
  203. );
  204. })
  205. return (
  206. <div style={{padding:"50px"}}>
  207. <div align="center" className={classes.section} id="notifications">
  208. <SnackbarContent
  209. message={
  210. <h2><b>Checkout</b></h2>
  211. }
  212. align="center"
  213. color="danger"
  214. />
  215. </div>
  216. <Stepper activeStep={activeStep} orientation="vertical">
  217. {steps.map((label, index) => (
  218. <Step key={label}>
  219. <StepLabel>{label}</StepLabel>
  220. <StepContent>
  221. <Typography>{CartProdukPesanan}</Typography>
  222. <div className={classes.actionsContainer}>
  223. <div>
  224. <Button
  225. disabled={activeStep === 0}
  226. onClick={handleBack}
  227. className={classes.button}
  228. >
  229. Back
  230. </Button>
  231. <Button
  232. variant="contained"
  233. color="primary"
  234. onClick={handleNext}
  235. className={classes.button}
  236. >
  237. {activeStep === steps.length - 1 ? 'Buat Pesanan' : 'Next'}
  238. </Button>
  239. </div>
  240. </div>
  241. </StepContent>
  242. </Step>
  243. ))}
  244. </Stepper>
  245. {activeStep === steps.length && (
  246. <Paper square elevation={0} className={classes.resetContainer}>
  247. <Typography>Semua Langkah Sudah Selesai !!!</Typography>
  248. <Button1 color="info" href={"/yamaha/cart/checkout?s="+data.id}>
  249. <Icon className={classes.icons}>shopping_cart</Icon>
  250. Checkout
  251. </Button1>
  252. <Button1 onClick={handleReset} color="info">
  253. <Icon className={classes.icons}>restore</Icon>
  254. Reset
  255. </Button1>
  256. </Paper>
  257. )}
  258. </div>
  259. );
  260. }
  261. export default DataCheckout;