Advertisement
cindex1a

checkout.js

Feb 27th, 2021 (edited)
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from "react";
  2. import Header from "parts/Header";
  3.  
  4. import Fade from "react-reveal/Fade";
  5. import Button from "elements/Button";
  6. import Stepper, {
  7.   Numbering,
  8.   Meta,
  9.   MainContent,
  10.   Controller,
  11. } from "elements/Stepper";
  12. //kenapa belom selesai juga wopiiiii
  13.  
  14. import BookingInformation from "parts/Checkout/BookingInformation";
  15. import Payment from "parts/Checkout/Payment";
  16. import Completed from "parts/Checkout/Completed";
  17.  
  18. import ItemDetails from "json/itemDetails.json";
  19.  
  20. export default class Checkout extends Component {
  21.   state = {
  22.     data: {
  23.       firstName: "",
  24.       lastName: "",
  25.       email: "",
  26.       phone: "",
  27.       proofPayment: "",
  28.       bankName: "",
  29.       bankHolder: "",
  30.     },
  31.   };
  32.  
  33.   onChange = (event) => {
  34.     this.setState({
  35.       data: {
  36.         ...this.state.data,
  37.         [event.target.name]: event.target.value,
  38.       },
  39.     });
  40.   };
  41.  
  42.   componentDidMount() {
  43.     window.scroll(0, 0);
  44.   }
  45.   render() {
  46.     const { data } = this.state;
  47.     const checkout = {
  48.       duration: 3,
  49.     };
  50.  
  51.     const steps = {
  52.       bookingInformation: {
  53.         title: "Booking Information",
  54.         description: "Please fill up the blank fields below ",
  55.         content: (
  56.           <BookingInformation
  57.             data={data}
  58.             checkout={checkout}
  59.             ItemDetails={ItemDetails}
  60.             onChange={this.onChange}
  61.           />
  62.         ),
  63.       },
  64.       payment: {
  65.         title: "payment",
  66.         description: "Kindly follow the instruction below",
  67.         content: (
  68.           <Payment
  69.             data={data}
  70.             ItemDetails={ItemDetails}
  71.             checkout={checkout}
  72.             onChange={this.onChange}
  73.           />
  74.         ),
  75.       },
  76.       completed: {
  77.         title: "Yay!! Completed",
  78.         description: null,
  79.         content: <Completed />,
  80.       },
  81.     };
  82.     return (
  83.       <>
  84.         <Header isCentered />
  85.         <Stepper steps={steps}>
  86.           {(prevStep, nextStep, CurrentStep, steps) => (
  87.             <>
  88.               <Numbering
  89.                 data={steps}
  90.                 current={CurrentStep}
  91.                 style={{ marginBottom: 50 }}
  92.               />
  93.  
  94.               <Meta data={steps} current={CurrentStep} />
  95.               <MainContent data={steps} current={CurrentStep} />
  96.               {CurrentStep === "bookingInformation" && (
  97.                 <Controller>
  98.                   {data.firstName !== "" &&
  99.                     data.lastName !== "" &&
  100.                     data.email !== "" &&
  101.                     data.phone !== "" && (
  102.                       <Fade>
  103.                         <Button
  104.                           className="btn mb-3"
  105.                           type="button"
  106.                           isBlock
  107.                           isPrimary
  108.                           hasShadow
  109.                           onClick={nextStep}
  110.                         >
  111.                           Continue To Book{" "}
  112.                         </Button>
  113.                       </Fade>
  114.                     )}
  115.                   <Button
  116.                     className="btn"
  117.                     type="link"
  118.                     isBlock
  119.                     isLight
  120.                     href={`/properties/${ItemDetails._id}`}
  121.                   >
  122.                     cancel
  123.                   </Button>
  124.                 </Controller>
  125.               )}
  126.               {CurrentStep === "payment" && (
  127.                 <Controller>
  128.                   {data.proofPayment !== "" &&
  129.                     data.bankName !== "" &&
  130.                     data.bankHolder !== "" && (
  131.                       <Fade>
  132.                         <Button
  133.                           className="btn"
  134.                           type="button"
  135.                           isBlock
  136.                           isPrimary
  137.                           hasShadow
  138.                           onClick={nextStep}
  139.                         >
  140.                           Continue To Book
  141.                         </Button>
  142.                       </Fade>
  143.                     )}
  144.                   <Button
  145.                     className="btn"
  146.                     type="button"
  147.                     isBlock
  148.                     isLight
  149.                     onClick={prevStep}
  150.                   >
  151.                     Cancel
  152.                   </Button>
  153.                 </Controller>
  154.               )}
  155.  
  156.               {CurrentStep === "completed" && (
  157.                 <Controller>
  158.                   <Button
  159.                     className="btn"
  160.                     type="link"
  161.                     isBlock
  162.                     isPrimary
  163.                     hasShadow
  164.                     href=""
  165.                   >
  166.                     Back To Home!!!!!!!!!!!!!!!!!
  167.                   </Button>
  168.                 </Controller>
  169.               )}
  170.             </>
  171.           )}
  172.         </Stepper>
  173.       </>
  174.     );
  175.   }
  176. }
  177.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement