You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

1 rivi
17 KiB

  1. {"ast":null,"code":"import _regeneratorRuntime from \"@babel/runtime/regenerator\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nvar _excluded = [\"checkoutprofile\", \"province\", \"cities\", \"backend\", \"checkoutproduct\"];\nvar __jsx = React.createElement;\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nimport React, { Component, Fragment } from 'react';\nimport { withStyles, makeStyles } from '@material-ui/core/styles';\nimport clsx from 'clsx';\nimport Selects from 'react-select';\nimport SnackbarContent from \"components/Snackbar/SnackbarContent.js\";\nimport Button1 from \"components/CustomButtons/Button.js\";\nimport image1 from \"../../../assets/img/mail.png\";\nimport GridContainer from \"components/Grid/GridContainer.js\";\nimport Carousel from \"react-slick\";\nimport GridItem from \"components/Grid/GridItem.js\";\nimport classNames from \"classnames\";\nimport swal from 'sweetalert';\nimport Icon from \"@material-ui/core/Icon\";\nimport Grid from '@material-ui/core/Grid';\nimport TextField from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\nimport Slide from '@material-ui/core/Slide';\nimport Select from '@material-ui/core/Select';\nimport Card from \"components/Card/Card.js\";\nimport CardBody from \"components/Card/CardBody.js\";\nimport FormControl from '@material-ui/core/FormControl';\nimport { Form, FormGroup, ControlLabel, SelectPicker } from \"rsuite\";\nimport InputLabel from '@material-ui/core/InputLabel';\nimport OutlinedInput from '@material-ui/core/OutlinedInput';\nimport NumberFormat from 'react-number-format';\nimport Table from '@material-ui/core/Table';\nimport TableBody from '@material-ui/core/TableBody';\nimport TableCell from '@material-ui/core/TableCell';\nimport TableContainer from '@material-ui/core/TableContainer';\nimport TableHead from '@material-ui/core/TableHead';\nimport TableRow from '@material-ui/core/TableRow';\nimport Paper from '@material-ui/core/Paper';\nvar useStyles = makeStyles(function (theme) {\n var _ref;\n\n return _ref = {\n root: {\n width: '100%'\n },\n button: {\n marginTop: theme.spacing(1),\n marginRight: theme.spacing(1)\n },\n actionsContainer: {\n marginBottom: theme.spacing(2)\n },\n resetContainer: {\n padding: theme.spacing(3)\n },\n appBar: {\n position: 'relative'\n },\n title: {\n marginLeft: theme.spacing(2),\n flex: 1\n }\n }, _defineProperty(_ref, \"root\", {\n '&:hover': {\n backgroundColor: 'transparent'\n }\n }), _defineProperty(_ref, \"icon\", {\n borderRadius: '50%',\n width: 16,\n height: 16,\n boxShadow: 'inset 0 0 0 1px rgba(16,22,26,.2), inset 0 -1px 0 rgba(16,22,26,.1)',\n backgroundColor: '#f5f8fa',\n backgroundImage: 'linear-gradient(180deg,hsla(0,0%,100%,.8),hsla(0,0%,100%,0))',\n '$root.Mui-focusVisible &': {\n outline: '2px auto rgba(19,124,189,.6)',\n outlineOffset: 2\n },\n 'input:hover ~ &': {\n backgroundColor: '#ebf1f5'\n },\n 'input:disabled ~ &': {\n boxShadow: 'none',\n background: 'rgba(206,217,224,.5)'\n }\n }), _defineProperty(_ref, \"checkedIcon\", {\n backgroundColor: '#137cbd',\n backgroundImage: 'linear-gradient(180deg,hsla(0,0%,100%,.1),hsla(0,0%,100%,0))',\n '&:before': {\n display: 'block',\n width: 16,\n height: 16,\n backgroundImage: 'radial-gradient(#fff,#fff 28%,transparent 32%)',\n content: '\"\"'\n },\n 'input:hover ~ &': {\n backgroundColor: '#106ba3'\n }\n }), _ref;\n});\nvar Transition = React.forwardRef(function Transition(props, ref) {\n return __jsx(Slide, _extends({\n direction: \"up\",\n ref: ref\n }, props));\n});\n\nvar DataCheckout = function DataCheckout(_ref2) {\n var checkoutprofile = _ref2.checkoutprofile,\n province = _ref2.province,\n cities = _ref2.cities,\n backend = _ref2.backend,\n checkoutproduct = _ref2.checkoutproduct,\n props = _objectWithoutProperties(_ref2, _excluded);\n\n var StyledTableCell = withStyles(function (theme) {\n return {\n head: {\n backgroundColor: theme.palette.common.black,\n color: theme.palette.common.white\n },\n body: {\n fontSize: 14\n }\n };\n })(TableCell);\n var StyledTableRow = withStyles(function (theme) {\n return {\n root: {\n '&:nth-of-type(odd)': {\n backgroundColor: theme.palette.action.hover\n }\n }\n };\n })(TableRow);\n var settings = {\n dots: true,\n infinite: true,\n speed: 500,\n slidesToShow: 1,\n slidesToScroll: 1,\n autoplay: false,\n time: 5\n };\n var classes = useStyles();\n\n var rest = _extends({}, props);\n\n var imageClasses = classNames(classes.imgRaised, classes.imgRoundedCircle, classes.imgFluid);\n var navImageClasses = classNames(classes.imgRounded, classes.imgGallery);\n\n var _React$useState = React.useState({\n order_id: GenerateID(),\n cust_name: \"\",\n cust_telp: \"\",\n cust_address: \"\",\n product_img: \"\",\n product_name: \"\",\n product_color: \"\",\n product_quantity: \"\",\n product_price: \"\",\n product_courier: \"\",\n note: \"\",\n status: 1\n }),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n formValue = _React$useState2[0],\n setFormValue = _React$useState2[1]; // const [formValue, setFormValue] = React.useState({\n // order_id: \"Trx-Ord-9ab8ab88\",\n // cust_name: \"Yusmar\",\n // cust_telp: \"087797315685\",\n // 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\",\n // product_img: null,\n // product_name: \"NMAX 155\",\n // product_color: \"Red\",\n // product_quantity: \"1\",\n // product_price: \"28545000\",\n // product_courier: \"JNE\",\n // note: \"Tes\",\n // });\n\n\n function GenerateID() {\n var dt = new Date().getTime();\n var uuid = 'Trx-Ord-yyyyyyyy'.replace(/[y]/g, function (c) {\n var r = (dt + Math.random() * 16) % 16 | 0;\n dt = Math.floor(dt / 16);\n return (c == 'x' ? r : r & 0x3 | 0x8).toString(16);\n });\n return uuid;\n }\n\n var CheckoutAlamat = checkoutprofile.map(function (data) {\n return __jsx(Card, {\n className: classes.textCenter,\n align: \"center\"\n }, __jsx(TableContainer, null, __jsx(Table, {\n className: classes.table,\n \"aria-label\": \"customized table\"\n }, __jsx(TableHead, null, __jsx(TableRow, null, __jsx(StyledTableCell, {\n align: \"center\"\n }, \"Nama Customer\"), __jsx(StyledTableCell, {\n align: \"center\"\n }, \"Email Customer\"), __jsx(StyledTableCell, {\n align: \"center\"\n }, \"No.Telp Customer\"), __jsx(StyledTableCell, {\n align: \"center\"\n }, \"Alamat Customer\"))), __jsx(TableBody, null, __jsx(StyledTableRow, null, __jsx(StyledTableCell, {\n align: \"center\"\n }, __jsx(\"b\", null, data.username)), __jsx(StyledTableCell, {\n align: \"center\"\n }, __jsx(\"b\", null, data.email)), __jsx(StyledTableCell, {\n align: \"center\"\n }, __jsx(\"b\", null, data.telp)), __jsx(StyledTableCell, {\n align: \"center\"\n }, __jsx(\"b\", null, data.address)))))));\n });\n var CheckoutProdukPesanan = checkoutproduct.map(function (data) {\n var _React$useState3 = React.useState({\n warna: '',\n name: 'hai'\n }),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n state = _React$useState4[0],\n setState = _React$useState4[1];\n\n var handleChange = function handleChange(event) {\n var name = event.target.name;\n setState(_objectSpread({}, state, _defineProperty({}, name, event.target.value)));\n };\n\n return __jsx(\"div\", {\n align: \"center\"\n }, __jsx(Card, {\n className: classes.textCenter,\n align: \"center\"\n }, __jsx(TableContainer, null, __jsx(Table, {\n className: classes.table,\n \"aria-label\": \"customized table\"\n }, __jsx(TableHead, null, __jsx(TableRow, null, __jsx(StyledTableCell, {\n align: \"center\"\n }, \"Produk Dipesan\"), __jsx(StyledTableCell, {\n align: \"center\"\n }, \"Nama Produk\"), __jsx(StyledTableCell, {\n align: \"center\"\n }, \"Warna\"), __jsx(StyledTableCell, {\n align: \"center\"\n }, \"Harga Per Unit\"), __jsx(StyledTableCell, {\n align: \"center\"\n }, \"Jumlah Unit\"), __jsx(StyledTableCell, {\n align: \"center\"\n }, \"Subtotal Harga\"))), __jsx(TableBody, null, __jsx(StyledTableRow, null, __jsx(StyledTableCell, null, __jsx(\"img\", {\n className: navImageClasses,\n width: \"200px\",\n alt: \"First slide\",\n src: \"\".concat(backend).concat(data.img[0][\"url\"])\n })), __jsx(StyledTableCell, {\n align: \"center\"\n }, __jsx(\"b\", null, data.name)), __jsx(StyledTableCell, {\n align: \"center\"\n }, __jsx(FormControl, {\n variant: \"outlined\",\n className: classes.formControl\n }, __jsx(InputLabel, {\n htmlFor: \"outlined-age-native-simple\"\n }, \"Warna\"), __jsx(Select, {\n \"native\": true,\n value: state.warna,\n onChange: handleChange,\n label: \"Warna\",\n name: \"product_color\",\n inputProps: {\n name: 'warna',\n id: 'outlined-age-native-simple'\n },\n onInput: function onInput(e) {\n setFormValue(_objectSpread({}, formValue, {\n product_color: e.target.value.toString()\n }));\n }\n }, __jsx(\"option\", {\n \"aria-label\": \"None\",\n value: \"\"\n }), __jsx(\"option\", {\n value: \"Hitam\"\n }, \"Hitam\"), __jsx(\"option\", {\n value: \"Putih\"\n }, \"Putih\"), __jsx(\"option\", {\n value: \"Merah\"\n }, \"Merah\")))), __jsx(StyledTableCell, {\n align: \"center\"\n }, __jsx(\"h5\", null, __jsx(\"b\", null, __jsx(NumberFormat, {\n value: data.price,\n displayType: 'text',\n thousandSeparator: true,\n prefix: 'Rp.'\n })))), __jsx(StyledTableCell, {\n align: \"center\"\n }, __jsx(TextField, {\n id: \"outlined-number\",\n label: \"Number\",\n type: \"number\",\n name: \"quantity\",\n InputLabelProps: {\n shrink: true\n },\n onInput: function onInput(e) {\n setFormValue(_objectSpread({}, formValue, {\n product_quantity: e.target.value\n }));\n },\n variant: \"outlined\"\n })), __jsx(StyledTableCell, {\n align: \"center\"\n }, __jsx(\"h5\", null, __jsx(\"b\", null, __jsx(NumberFormat, {\n value: data.price,\n displayType: 'text',\n thousandSeparator: true,\n prefix: 'Rp.'\n })))))))), __jsx(TableContainer, null, __jsx(Table, null, __jsx(TableBody, null, __jsx(TableRow, null, __jsx(StyledTableCell, {\n align: \"center\"\n }, __jsx(TextField, {\n id: \"outlined-full-width\",\n label: \"Pesan\",\n style: {\n width: \"550px\"\n },\n placeholder: \"( Opsional ) Tinggalkan Pesan Kepada Dealer\",\n margin: \"normal\",\n variant: \"outlined\",\n onInput: function onInput(e) {\n setFormValue(_objectSpread({}, formValue, {\n note: e.target.value\n }));\n }\n })), __jsx(StyledTableCell, {\n align: \"center\"\n }, __jsx(FormControl, {\n variant: \"outlined\",\n className: classes.formControl\n }, __jsx(InputLabel, {\n htmlFor: \"outlined-age-native-simple\"\n }, \"Pilih Ekspedisi Pengiriman\"), __jsx(Select, {\n \"native\": true,\n style: {\n width: \"550px\"\n },\n value: state.age,\n onChange: handleChange,\n label: \"Pilih Ekspedisi Pengiriman\",\n inputProps: {\n name: 'age',\n id: 'outlined-age-native-simple'\n },\n onInput: function onInput(e) {\n setFormValue(_objectSpread({}, formValue, {\n product_courier: e.target.value\n }));\n }\n }, __jsx(\"option\", {\n \"aria-label\": \"None\",\n value: \"\"\n }), __jsx(\"option\", {\n value: \"JNE\"\n }, \"JNE\"), __jsx(\"option\", {\n value: \"Antar Aja\"\n }, \"Antar Aja\"), __jsx(\"option\", {\n value: \"TIKI\"\n }, \"TIKI\"))))))))));\n });\n return __jsx(\"div\", {\n style: {\n padding: \"50px\"\n }\n }, __jsx(\"div\", {\n align: \"center\",\n className: classes.section,\n id: \"notifications\"\n }, __jsx(SnackbarContent, {\n message: __jsx(\"h2\", null, __jsx(\"b\", null, \"Checkout\")),\n align: \"center\",\n color: \"info\"\n })), __jsx(Form, {\n onSubmit: function _callee(value) {\n var newformValue, response, res;\n return _regeneratorRuntime.async(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n newformValue = _objectSpread({}, formValue, {\n cust_name: checkoutprofile[0].username,\n cust_telp: checkoutprofile[0].telp.toString(),\n cust_address: checkoutprofile[0].address,\n product_img: checkoutproduct.img,\n product_name: checkoutproduct[0].name,\n product_price: checkoutproduct[0].price\n });\n setFormValue(newformValue);\n _context.next = 4;\n return _regeneratorRuntime.awrap(fetch(\"/api/transaction/create\", {\n method: \"POST\",\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify(newformValue)\n }));\n\n case 4:\n response = _context.sent;\n\n if (!response.ok) {\n _context.next = 12;\n break;\n }\n\n _context.next = 8;\n return _regeneratorRuntime.awrap(response.json());\n\n case 8:\n res = _context.sent;\n\n if (res[\"STATUS\"] === 1) {\n res[\"DATA\"][\"transaction\"];\n swal(\"Produk Berhasil Ditambah ke Keranjang\", \"Silahkan Cek Keranjang Belanja Anda\", \"success\");\n } else {\n swal(\"Produk Gagal Ditambah ke Keranjang\", \"Silahkan Coba Lagi\", \"error\");\n }\n\n _context.next = 13;\n break;\n\n case 12:\n swal(\"Transaksi Gagal\", \"Silahkan Coba Lagi\", \"error\");\n\n case 13:\n case \"end\":\n return _context.stop();\n }\n }\n }, null, null, null, Promise);\n }\n }, __jsx(\"div\", null, CheckoutAlamat), __jsx(\"div\", null, CheckoutProdukPesanan), __jsx(\"div\", null, __jsx(GridContainer, null, __jsx(Grid, {\n item: true,\n xs: 6,\n style: {\n padding: \"20px\"\n }\n }, __jsx(Button1, {\n color: \"info\",\n style: {\n width: \"100%\"\n },\n type: \"submit\" // onClick={async function (e) {\n // // setFormValue({\n // // cust_name : data.username,\n // // ... formValue\n // // });\n //\n // }}\n\n }, __jsx(Icon, {\n className: classes.icons\n }, \"attach_money\"), \"Buat Pesanan\")), __jsx(Grid, {\n item: true,\n xs: 6,\n style: {\n padding: \"20px\"\n }\n }, __jsx(Button1, {\n color: \"danger\",\n style: {\n width: \"100%\"\n } // swal({\n // title: \"Anda Ingin Menghapus Pesanan ?\",\n // icon: \"warning\",\n // buttons: true,\n // dangerMode: true,\n // })\n // .then((willDelete) => {\n // if (willDelete) {\n // swal(\"Pesanan Anda Berhasil Dihapus\", {\n // icon: \"success\",\n // });\n // } else {\n // swal(\"Selamat Belanja Kembali\");\n // }\n // });\n\n }, __jsx(Icon, {\n className: classes.icons\n }, \"attach_money\"), \"Batalkan Pesanan\"))))));\n};\n\nexport default DataCheckout;","map":null,"metadata":{},"sourceType":"module"}