fix: corrige posicionamento do botáo de submit do frete
This commit is contained in:
parent
ab0645c45d
commit
b332dd362a
@ -1,36 +0,0 @@
|
||||
import React, { useEffect } from "react";
|
||||
|
||||
const Freight = () => {
|
||||
const setPlaceholder = (input: Element | null, placeholder: string) => {
|
||||
if (input) {
|
||||
input!.setAttribute("placeholder", placeholder);
|
||||
}
|
||||
};
|
||||
|
||||
const appendElement = (
|
||||
parentElement: ChildNode | null | undefined,
|
||||
childElement: ChildNode | null | undefined
|
||||
) => {
|
||||
if (parentElement && childElement) {
|
||||
parentElement!.appendChild(childElement);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const cepInput = document.querySelector(".vtex-address-form-4-x-input");
|
||||
const inputSpan = cepInput?.nextSibling;
|
||||
const cepButton = document.querySelector(".vtex-address-form__postalCode")
|
||||
?.nextSibling;
|
||||
|
||||
console.log("cepInput: " + cepInput, typeof cepInput);
|
||||
console.log("inputSpan: " + inputSpan, typeof inputSpan);
|
||||
console.log("cepButton: " + cepButton, typeof cepButton);
|
||||
|
||||
setPlaceholder(cepInput, "Digite seu CEP");
|
||||
appendElement(inputSpan, cepButton);
|
||||
});
|
||||
|
||||
return <></>;
|
||||
};
|
||||
|
||||
export default Freight;
|
@ -1,8 +1,6 @@
|
||||
import React from "react";
|
||||
import React, { useEffect } from "react";
|
||||
import { useProduct } from "vtex.product-context";
|
||||
import styles from "./styles.css";
|
||||
// import { useQuery } from "react-apollo";
|
||||
// import pixPrice from "../../graphql/pixPrice.graphql";
|
||||
|
||||
const PixDiscount = () => {
|
||||
const productContextValue = useProduct();
|
||||
@ -15,29 +13,30 @@ const PixDiscount = () => {
|
||||
maximumFractionDigits: 2,
|
||||
});
|
||||
|
||||
// console.log(productContextValue);
|
||||
useEffect(() => {
|
||||
const cepInput = document.querySelector(".vtex-address-form-4-x-input");
|
||||
const inputSpan = cepInput?.nextSibling;
|
||||
const cepButton = document.querySelector(".vtex-address-form__postalCode")
|
||||
?.nextSibling;
|
||||
|
||||
console.log("cepInput: " + cepInput, typeof cepInput);
|
||||
console.log("inputSpan: " + inputSpan, typeof inputSpan);
|
||||
console.log("cepButton: " + cepButton, typeof cepButton);
|
||||
|
||||
if (cepInput) {
|
||||
cepInput!.setAttribute("placeholder", "Digite seu CEP");
|
||||
}
|
||||
|
||||
if (inputSpan && cepButton) {
|
||||
inputSpan!.appendChild(cepButton);
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<p className={styles.pixDiscount}>{`R$ ${pixPrice}`}</p>
|
||||
{/* <p>{testingApi}</p> */}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default PixDiscount;
|
||||
|
||||
// "vtex.search-graphql": "0.x"
|
||||
|
||||
// const { data } = useQuery(pixPrice, {
|
||||
// variables: {
|
||||
// slug: productContextValue?.product?.productName,
|
||||
// },
|
||||
// ssr: false,
|
||||
// });
|
||||
|
||||
// const testingApi = fetch(
|
||||
// "https://agenciamagma.dev.com.br/api/checkout/pub/orderForms/simulation"
|
||||
// )
|
||||
// .then((response) => response.json())
|
||||
// .then((data) => console.log(data));
|
||||
|
@ -318,7 +318,7 @@
|
||||
"testId": "shipping-simulator",
|
||||
"blockClass": "shipping-simulator"
|
||||
},
|
||||
"children": ["shipping-simulator", "freight"]
|
||||
"children": ["shipping-simulator"]
|
||||
},
|
||||
|
||||
"flex-layout.row#product-availability": {
|
||||
|
@ -8,8 +8,5 @@
|
||||
},
|
||||
"pix-discount": {
|
||||
"component": "PixDiscount"
|
||||
},
|
||||
"freight": {
|
||||
"component": "Freight"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user