25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

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