import React, { Component, Fragment } from 'react'; import { withStyles, makeStyles } from '@material-ui/core/styles'; import clsx from 'clsx'; import Selects from 'react-select'; import SnackbarContent from "components/Snackbar/SnackbarContent.js"; import Button1 from "components/CustomButtons/Button.js"; import image1 from "../../../assets/img/mail.png" import GridContainer from "components/Grid/GridContainer.js"; import Carousel from "react-slick"; import GridItem from "components/Grid/GridItem.js"; import classNames from "classnames"; import swal from 'sweetalert'; import Icon from "@material-ui/core/Icon"; import Grid from '@material-ui/core/Grid'; import TextField from '@material-ui/core/TextField'; import Typography from '@material-ui/core/Typography'; import Slide from '@material-ui/core/Slide'; import Select from '@material-ui/core/Select'; import Card from "components/Card/Card.js"; import CardBody from "components/Card/CardBody.js"; import FormControl from '@material-ui/core/FormControl'; import { Form, FormGroup, ControlLabel, SelectPicker } from "rsuite"; import InputLabel from '@material-ui/core/InputLabel'; import OutlinedInput from '@material-ui/core/OutlinedInput'; import NumberFormat from 'react-number-format'; import Table from '@material-ui/core/Table'; import TableBody from '@material-ui/core/TableBody'; import TableCell from '@material-ui/core/TableCell'; import TableContainer from '@material-ui/core/TableContainer'; import TableHead from '@material-ui/core/TableHead'; import TableRow from '@material-ui/core/TableRow'; import Paper from '@material-ui/core/Paper'; const useStyles = makeStyles((theme) => ({ root: { width: '100%', }, button: { marginTop: theme.spacing(1), marginRight: theme.spacing(1), }, actionsContainer: { marginBottom: theme.spacing(2), }, resetContainer: { padding: theme.spacing(3), }, appBar: { position: 'relative', }, title: { marginLeft: theme.spacing(2), flex: 1, }, root: { '&:hover': { backgroundColor: 'transparent', }, }, icon: { borderRadius: '50%', width: 16, height: 16, boxShadow: 'inset 0 0 0 1px rgba(16,22,26,.2), inset 0 -1px 0 rgba(16,22,26,.1)', backgroundColor: '#f5f8fa', backgroundImage: 'linear-gradient(180deg,hsla(0,0%,100%,.8),hsla(0,0%,100%,0))', '$root.Mui-focusVisible &': { outline: '2px auto rgba(19,124,189,.6)', outlineOffset: 2, }, 'input:hover ~ &': { backgroundColor: '#ebf1f5', }, 'input:disabled ~ &': { boxShadow: 'none', background: 'rgba(206,217,224,.5)', }, }, checkedIcon: { backgroundColor: '#137cbd', backgroundImage: 'linear-gradient(180deg,hsla(0,0%,100%,.1),hsla(0,0%,100%,0))', '&:before': { display: 'block', width: 16, height: 16, backgroundImage: 'radial-gradient(#fff,#fff 28%,transparent 32%)', content: '""', }, 'input:hover ~ &': { backgroundColor: '#106ba3', }, }, })); const Transition = React.forwardRef(function Transition(props, ref) { return ; }); const DataCheckout = function ({ checkoutprofile, province, cities, backend, checkoutproduct, ...props }) { const StyledTableCell = withStyles((theme) => ({ head: { backgroundColor: theme.palette.common.black, color: theme.palette.common.white, }, body: { fontSize: 14, }, }))(TableCell); const StyledTableRow = withStyles((theme) => ({ root: { '&:nth-of-type(odd)': { backgroundColor: theme.palette.action.hover, }, }, }))(TableRow); const settings = { dots: true, infinite: true, speed: 500, slidesToShow: 1, slidesToScroll: 1, autoplay: false, time: 5 }; const classes = useStyles(); const { ...rest } = props; const imageClasses = classNames( classes.imgRaised, classes.imgRoundedCircle, classes.imgFluid ); const navImageClasses = classNames(classes.imgRounded, classes.imgGallery); const [formValue, setFormValue] = React.useState({ order_id: GenerateID(), cust_name: "", cust_telp: "", cust_address: "", product_img: "", product_name: "", product_color: "", product_quantity: "", product_price: "", product_courier: "", note: "", status: 1, }); // const [formValue, setFormValue] = React.useState({ // order_id: "Trx-Ord-9ab8ab88", // cust_name: "Yusmar", // cust_telp: "087797315685", // cust_address: "Thamrin Indrapura Jl.Aipda Karel Satsuit Tubun,17 Ilir, Kec.Ilir Tim.I, Palembang, KOTA PALEMBANG - ILIR TIMUR II, SUMATERA SELATAN, ID 30114", // product_img: null, // product_name: "NMAX 155", // product_color: "Red", // product_quantity: "1", // product_price: "28545000", // product_courier: "JNE", // note: "Tes", // }); function GenerateID() { var dt = new Date().getTime(); var uuid = 'Trx-Ord-yyyyyyyy'.replace(/[y]/g, function (c) { var r = (dt + Math.random() * 16) % 16 | 0; dt = Math.floor(dt / 16); return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); return uuid; } const CheckoutAlamat = checkoutprofile.map((data) => { return ( Nama Customer Email Customer No.Telp Customer Alamat Customer {data.username} {data.email} {data.telp} {data.address}
); }) const CheckoutProdukPesanan = checkoutproduct.map((data) => { const [state, setState] = React.useState({ warna: '', name: 'hai', }); const handleChange = (event) => { const name = event.target.name; setState({ ...state, [name]: event.target.value, }); }; return (
Produk Dipesan Nama Produk Warna Harga Per Unit Jumlah Unit Subtotal Harga First slide {data.name} Warna
{ setFormValue({ ...formValue, product_quantity: e.target.value }) }} variant="outlined" />
{ setFormValue({ ...formValue, note: e.target.value }) }} /> Pilih Ekspedisi Pengiriman
); }) return (
Checkout } align="center" color="info" />
{ var newformValue = { ...formValue, cust_name: checkoutprofile[0].username, cust_telp: checkoutprofile[0].telp.toString(), cust_address: checkoutprofile[0].address, product_img: checkoutproduct.img, product_name: checkoutproduct[0].name, product_price: checkoutproduct[0].price, } setFormValue(newformValue) const response = await fetch( "/api/transaction/create", { method: "POST", headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(newformValue), } ); if (response.ok) { var res = await response.json(); if (res["STATUS"] === 1) { res["DATA"]["transaction"]; swal("Produk Berhasil Ditambah ke Keranjang", "Silahkan Cek Keranjang Belanja Anda", "success"); } else { swal("Produk Gagal Ditambah ke Keranjang", "Silahkan Coba Lagi", "error"); } } else { swal("Transaksi Gagal", "Silahkan Coba Lagi", "error"); } }} >
{CheckoutAlamat}
{CheckoutProdukPesanan}
attach_money Buat Pesanan { // if (willDelete) { // swal("Pesanan Anda Berhasil Dihapus", { // icon: "success", // }); // } else { // swal("Selamat Belanja Kembali"); // } // }); > attach_money Batalkan Pesanan {/* {snap.pay(transactionToken);}} style={{width:"100%"}}> attach_money Bayar Pesanan */}
); } export default DataCheckout;