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.

334 lines
20 KiB

  1. import React from 'react'
  2. //component
  3. import PageBanner from '@/components/Common/PageBanner';
  4. import * as Icon from 'react-feather'
  5. import { useSelector, useDispatch } from 'react-redux'
  6. import { useRouter } from 'next/router'
  7. import { useToasts } from 'react-toast-notifications'
  8. //addon library
  9. import { resetIdCounter, Tab, Tabs, TabList, TabPanel } from 'react-tabs';
  10. resetIdCounter();
  11. import dynamic from 'next/dynamic'
  12. const OwlCarousel = dynamic(import('react-owl-carousel3'))
  13. //library yarn
  14. import NumberFormat from 'react-number-format';
  15. import ReactHtmlParser from "react-html-parser";
  16. //sweet alert
  17. import swal from 'sweetalert';
  18. const options = {
  19. loop: true,
  20. nav: true,
  21. dots: false,
  22. autoplay: true,
  23. items: 1,
  24. smartSpeed: 1000,
  25. autoplayTimeout: 5000,
  26. navText: [
  27. "<i class='bx bx-chevron-left'></i>",
  28. "<i class='bx bx-chevron-right'></i>"
  29. ],
  30. };
  31. const ProductDetails = function ({ detailygp, backend, user, ...props }) {
  32. console.log(detailygp);
  33. const [formValue, setFormValue] = React.useState({
  34. product_img: "",
  35. product_name: "",
  36. product_color: "",
  37. product_price: "",
  38. });
  39. const router = useRouter();
  40. const MotorDetail = detailygp.map((data) => {
  41. return (
  42. <div>
  43. <PageBanner pageTitle={data.name} />
  44. <div className="shop-details-area ptb-80">
  45. <div className="container">
  46. <div className="row align-items-center">
  47. <div className="col-lg-5">
  48. <OwlCarousel
  49. className="products-details-image products-details-image-slides owl-carousel owl-theme"
  50. {...options}
  51. >
  52. <img src={`${backend}${data.img["url"]}`} />
  53. </OwlCarousel>
  54. </div>
  55. <div className="col-lg-7">
  56. <div className="products-details">
  57. <h3>{data.name}</h3>
  58. <h3>
  59. <NumberFormat value={data.price1} displayType={'text'} thousandSeparator={true} prefix={'Rp.'} />
  60. </h3>
  61. <ul className="rating">
  62. <li><i className="flaticon-star-1"></i></li>
  63. <li><i className="flaticon-star-1"></i></li>
  64. <li><i className="flaticon-star-1"></i></li>
  65. <li><i className="flaticon-star-1"></i></li>
  66. <li><i className="flaticon-star-1"></i></li>
  67. </ul>
  68. <div className="availability">
  69. Availability: <span>{data.stock}</span>
  70. </div>
  71. <form
  72. onSubmit={async (e) => {
  73. e.preventDefault();
  74. var newformValue = {
  75. ...formValue,
  76. product_name: detailproduct[0].name,
  77. }
  78. setFormValue(newformValue)
  79. console.log(JSON.stringify(newformValue));
  80. const response = await fetch(
  81. "/api/transaction/AddToCart",
  82. {
  83. method: "POST",
  84. headers: {
  85. 'Content-Type': 'application/json'
  86. },
  87. body: JSON.stringify(newformValue),
  88. }
  89. );
  90. if (response.ok) {
  91. var res = await response.json();
  92. console.log("cek response :", res);
  93. if (res["STATUS"] === 1) {
  94. res["DATA"]["cart"];
  95. swal("Produk Berhasil Ditambah ke Keranjang", "Silahkan Cek Keranjang Belanja Anda", "success");
  96. router.push("/yamaha/Shop/Cart");
  97. }
  98. else {
  99. swal("Produk Gagal Ditambah ke Keranjang", "Silahkan Coba Lagi", "error");
  100. }
  101. } else {
  102. swal("Transaksi Gagal", "Silahkan Coba Lagi", "error");
  103. }
  104. return false;
  105. }}
  106. >
  107. {/* <label>Product OTR <span className="required">*</span></label>
  108. <div className="select-box" placeholder="Pilih Harga OTR">
  109. <select className="form-select"
  110. name="product_otr"
  111. onInput={(e) => {
  112. setFormValue({
  113. ...formValue,
  114. product_price: e.target.value.toString(),
  115. })
  116. }}
  117. >
  118. <option value="0">- Pilih Product OTR -</option>
  119. {detailproduct.map((option) => (
  120. <option value={option.product_otrs[0].price}>{option.product_otrs[0].name}</option>
  121. ))}
  122. {detailproduct.map((option) => (
  123. <option value={option.product_otrs[1].price}>{option.product_otrs[1].name}</option>
  124. ))}
  125. {detailproduct.map((option) => (
  126. <option value={option.product_otrs[2].price}>{option.product_otrs[2].name}</option>
  127. ))}
  128. </select>
  129. </div>
  130. <br />
  131. <label>Product Color <span className="required">*</span></label>
  132. <div className="select-box" placeholder="Pilih Harga OTR">
  133. <select className="form-select"
  134. name="product_color"
  135. onInput={(e) => {
  136. setFormValue({
  137. ...formValue,
  138. product_color: e.target.value.toString()
  139. })
  140. }}
  141. >
  142. <option value="0">- Pilih Product Color -</option>
  143. {detailproduct.map((option) => (
  144. <option value={option.product_image_colors[0].name}>{option.product_image_colors[0].name}</option>
  145. ))}
  146. {detailproduct.map((option) => (
  147. <option value={option.product_image_colors[1].name}>{option.product_image_colors[1].name}</option>
  148. ))}
  149. {detailproduct.map((option) => (
  150. <option value={option.product_image_colors[2].name}>{option.product_image_colors[2].name}</option>
  151. ))}
  152. </select>
  153. </div>
  154. <br /> */}
  155. <button type="submit">Add to Cart</button>
  156. <a href="#" className="add-to-wishlist-btn" title="Add to Wishlist">
  157. <Icon.Heart />
  158. </a>
  159. </form>
  160. <div className="custom-payment-options">
  161. <span>Metode Pembayaran : </span>
  162. <div className="payment-methods">
  163. <img src="/images/payment-image/Mastercard.svg" width="50px" alt="image" />
  164. <img src="/images/payment-image/Visa.svg" width="50px" alt="image" />
  165. <img src="/images/payment-image/BNI.svg" width="50px" alt="image" />
  166. <img src="/images/payment-image/BCA.svg" width="50px" alt="image" />
  167. <img src="/images/payment-image/Mandiri.svg" width="50px" alt="image" />
  168. <img src="/images/payment-image/BSI.svg" width="50px" alt="image" />
  169. <img src="/images/payment-image/Indomaret.svg" width="50px" alt="image" />
  170. </div>
  171. </div>
  172. <div className="products-share-social">
  173. <span>Share:</span>
  174. <ul>
  175. <li>
  176. <a href="#" className="facebook" target="_blank">
  177. <Icon.Facebook />
  178. </a>
  179. </li>
  180. <li>
  181. <a href="#" className="twitter" target="_blank">
  182. <Icon.Twitter />
  183. </a>
  184. </li>
  185. <li>
  186. <a href="#" className="linkedin" target="_blank">
  187. <Icon.Linkedin />
  188. </a>
  189. </li>
  190. <li>
  191. <a href="#" className="instagram" target="_blank">
  192. <Icon.Instagram />
  193. </a>
  194. </li>
  195. </ul>
  196. </div>
  197. </div>
  198. </div>
  199. <div className="col-lg-12 col-md-12">
  200. <div className="products-details-tabs">
  201. <Tabs>
  202. <TabList>
  203. <Tab>Deskripsi</Tab>
  204. <Tab>Info Penting</Tab>
  205. {/* <Tab>Review</Tab> */}
  206. </TabList>
  207. <TabPanel>
  208. <div className="products-description" align="left">
  209. <p>{ReactHtmlParser(data.description)}</p>
  210. </div>
  211. </TabPanel>
  212. <TabPanel>
  213. <div className="products-description" align="left">
  214. <p>
  215. <p><b>Informasi mengenai prosedur pengiriman, pembelian dan dokumen</b></p>
  216. <ul>
  217. <li>Kota Palembang, Kayu Agung, Prabumulih, Pangkalan Balai, Betung : 2-3 hari kerja*</li>
  218. <li>Untuk daerah Sungsang/daerah lain yang menggunakan kapal motor, maka motor diantar sampai di dermaga sesuai dengan jadwal yang diinformasikan</li>
  219. <li>Sekayu, Babat Toman, Pendopo, Baturaja, Martapura, Muara Dua, Lahat, Tanjung Enim, Tugu Mulyo, Belitang : 4-5 hari kerja*</li>
  220. <li>Lubuk Linggau, Curup, Pagar Alam : 6-7 hari kerja*</li>
  221. </ul>
  222. <p><b>Harga</b></p>
  223. <ul>
  224. <li>Harga OTR sudah termasuk biaya pengiriman dan BBN, kecuali tambahan pengenaan pajak progresif kepemilikan kendaraan bermotor (sesuai dengan peraturan yang telah ditetapkan oleh pemerintah)</li>
  225. <li>Harga OTR diatas berlaku untuk KTP domisili PALEMBANG, OGAN ILIR, dan BANYUASIN, diluar wilayah tersebut harap menghubungi kami untuk konfirmasi harga.</li>
  226. <li>Harga OTR sewaktu-waktu dapat berubah.</li>
  227. <li>Proses pemesanan sepeda motor tidak dapat dibatalkan dan warna yang sudah dipesan tidak dapat diubah.</li>
  228. <li>Proses pemesanan yang terkait waktu pengiriman produk dan kelengkapan dokumen yang dibutuhkan untuk pembuatan STNK dan BPKB akan diinformasikan oleh pihak Dealer.</li>
  229. <li>Proses pengiriman sepeda motor akan dilakukan setelah pelunasan transaksi dan dokumen yang dibutuhkan telah lengkap.</li>
  230. </ul>
  231. <p><b>Dokumen</b></p>
  232. <ul>
  233. <li>Proses pembuatan STNK setelah KTP diterima oleh pihak dealer adalah 19-25 hari kerja*.</li>
  234. <li>Proses pembuatan BPKB adalah 3-4 bulan.</li>
  235. <li>STNK dan BPKB wajib diambil sendiri oleh pihak yang bersangkutan sesuai dengan identitas yang tertera STNK di dealer yang ditunjuk.</li>
  236. <li>Untuk proses pembuatan STNK dan BPKB sepenuhnya menjadi tanggung jawab dealer terkait.</li>
  237. <li>Buku servis diterima bersamaan dengan pengiriman sepeda motor.</li>
  238. </ul>
  239. <p><b>*tidak termasuk Sabtu dan Minggu.</b></p>
  240. </p>
  241. </div>
  242. </TabPanel>
  243. {/* <TabPanel>
  244. <div className="products-reviews">
  245. <h3>Customer Reviews</h3>
  246. <p>There are no reviews yet.</p>
  247. <form className="review-form">
  248. <p>Rate this item:</p>
  249. <div className="star-rating">
  250. <i className='bx bxs-star'></i>
  251. <i className='bx bxs-star'></i>
  252. <i className='bx bxs-star'></i>
  253. <i className='bx bxs-star'></i>
  254. <i className='bx bxs-star'></i>
  255. <p>Very good product!</p>
  256. </div>
  257. <div className="row">
  258. <div className="col-lg-12">
  259. <div className="form-group">
  260. <textarea name="review-message" id="message" cols="30" rows="4" placeholder="Write your review*" className="form-control"></textarea>
  261. </div>
  262. </div>
  263. <div className="col-lg-6 col-md-6">
  264. <div className="form-group">
  265. <input type="text" placeholder="Name*" className="form-control" />
  266. </div>
  267. </div>
  268. <div className="col-lg-6 col-md-6">
  269. <div className="form-group">
  270. <input type="email" placeholder="Email*" className="form-control" />
  271. </div>
  272. </div>
  273. <div className="col-lg-12 col-md-12">
  274. <button type="submit" className="btn btn-primary">Submit</button>
  275. </div>
  276. </div>
  277. </form>
  278. </div>
  279. </TabPanel> */}
  280. </Tabs>
  281. </div>
  282. </div>
  283. </div>
  284. </div>
  285. </div>
  286. </div>
  287. );
  288. })
  289. return (
  290. <>
  291. {MotorDetail}
  292. </>
  293. )
  294. }
  295. export default ProductDetails;