import { Form, Formik } from "formik"; import * as Yup from "yup"; import { useMutation } from "@tanstack/react-query"; import { setExternalURL } from "../../../services/services"; import { useState } from "react"; import { Link } from "react-router-dom"; const validationSchema = Yup.object().shape({ url: Yup.string() .required("URL is required") .matches( /^https?:\/\/[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-]+\.[a-zA-Z]+/, "Must be like: https://example.mysite.com", ), }); // const initialValues = { // url: '', // }; const URLConfiguration = ({ productData }) => { const [externalURLChanged, setExternalURLChanged] = useState(true); const initialValues = { url: productData?.external_url || "", }; let defaultUrl = "https://" + productData?.internal_url; let externalUrl = productData?.external_url; const handleExternalURLChanged = (e) => { if (e.target.value == externalUrl) { setExternalURLChanged(true); } else { setExternalURLChanged(false); } }; // API to set url const setURL = useMutation({ mutationFn: (fields) => { return setExternalURL(fields); }, onSuccess: (res) => { if (res.data.resultCode != "0") { // throw({message: res?.data?.resultDescription}) throw { message: "Something went wrong!" }; } }, onSettled: () => { setTimeout(() => { setURL.reset(); }, 3000); }, // onError: (err) => { // console.log('err', err) // } }); const handleSubmit = (values) => { let reqData = { token: localStorage.getItem("token"), // USER TOKEN uid: localStorage.getItem("uid"), // USER UID subscription_uid: productData?.subscription_uid, external_url: values.url, }; setURL.mutate(reqData); }; return ( <>

{defaultUrl}

{/*
*/} {/*
*/} {/* /!**!/*/} {/* */} {/*
*/} {/*
*/}
{(props) => { return (

Set your own URL

{ props.handleChange(e); handleExternalURLChanged(e); }} type="text" className="form-control" id="url" aria-describedby="url" placeholder="https://example.mysite.com" />
{setURL.error && (

{setURL.error.message}

)} {setURL.isSuccess && (

{"Completed successfully"}

)}
To link your domain to your website, update your DNS record to point to our hosting provider.

Enter the following DNS servers in your domain settings
{process.env.REACT_APP_DNS1}
{process.env.REACT_APP_DNS2}
Click here for detailed instructions.
After updating your DNS settings, click “Start Verification.” You will receive a status notification within 24 hours.
); }}
); }; export default URLConfiguration;