import React, { useEffect, useState } from 'react'; import {Elements} from '@stripe/react-stripe-js'; import {loadStripe} from '@stripe/stripe-js'; import { Form, Col, Row, Toast } from 'react-bootstrap'; import './Book.css' import axios from 'axios'; import ifoIcon from '../../../../Assets/info.svg'; import Checkout from './Checkout'; import { SET_SELECTED_SERVICE, useAppContext } from '../../../../context'; const Book = () => { const { state: { selectedService }, dispatch} = useAppContext() const [services, setServices] = useState([]); const [show, setShow] = useState(true); useEffect(() => { axios.get(`https://immense-river-40491.herokuapp.com/services`) .then(res => { setServices(res.data) if(!selectedService.name){ dispatch({type: SET_SELECTED_SERVICE, payload: res.data[0]}) } }) }, [selectedService.name, dispatch]) const handleSelection = e => { const getService = services.find(({name}) => e.target.value === name) dispatch({type: SET_SELECTED_SERVICE, payload: getService}) } const stripePromise = loadStripe('pk_test_51Ii2KaCKKXM4eFaOJWCOr8pS4GVkoCerGCRHefo7hDpLYMcjpGqPNpoeydvFApWXDSSMnfXNzdtwRcF1o8XmTk3H00xDH8wKZc'); setTimeout(() => { setShow(false); }, 7000) return (
setShow(!show)} className="bookToast"> Info 02 seconds ago 4242 4242 4242 4242 you can use this card number for testing Service Price
{selectedService.price}
); }; export default Book;