I have a platform's embedded html and script. This button triggers the script from what I understand. They actually designed it to be embedded on a website. I am looking for a way to implement same on a react application if it is possible. Here is the code provided by the platform to be embedled on a website:
<button class="wtrvl-checkout_button" id="wetravel_button_widget" data-
env="https://awebsite.com" data-version="v0.3" data-uid="62302" data-uuid="54806750"
href="https://website.com/checkout_embed?uuid=54806750" style="background-
color:#33ae3f;color:#ffffff;border: 0px;border-radius: 5px;font-family: 'Poppins', sans-
serif;font-weight: 400;font-size: 14px;-webkit-font-smoothing: antialiased;text-transform:
capitalize;padding: 13px 24px;text-decoration: none;text-align: center;line-height:
14px;display: inline-block; cursor: pointer;">Book Now</button> <link
href="https://fonts.googleapis.com/css?family=Poppins" rel="stylesheet"> <script
src="https://cdn.wetravel.com/widgets/embed_checkout.js"></script>
This was what I could come up with but not working:
const [action, setAction] = useState(false);
useEffect(() => {
const script = document.createElement('script');
script.src = "https://cdn.wetravel.com/widgets/embed_checkout.js";
script.async = true;
document.body.appendChild(script);
return () => {
document.body.removeChild(script);
}
}, [action]);
const triggerScript = ()=>{
etAction(true)
}
return(
<button class="wtrvl-checkout_button" id="wetravel_button_widget" data-env="https://maximumimpacttravel.wetravel.com" data-version="v0.3" data-uid="62302" data-uuid="54806750" href="https://maximumimpacttravel.wetravel.com/checkout_embed?uuid=54806750" style={{backgroundColor:'black', color:'#ffffff', border: '0px', borderRadius: '5px', fontFamily: 'Poppins', cursor: 'pointer'}}
onClick={triggerScript}
>Book Now</button>
)
Also, will it be possible to listen to button clicks events on this script? The idea behind the embedled button is to create a pop up iframe that overlays on a web page. I don't know if this can be implemented on a React component