fix: corrige posicionamento do botáo de submit do frete

This commit is contained in:
Andrea Matsunaga 2023-02-10 22:45:05 -03:00
parent ab0645c45d
commit b332dd362a
5 changed files with 20 additions and 60 deletions

View File

@ -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;

View File

@ -1,8 +1,6 @@
import React from "react"; import React, { useEffect } from "react";
import { useProduct } from "vtex.product-context"; import { useProduct } from "vtex.product-context";
import styles from "./styles.css"; import styles from "./styles.css";
// import { useQuery } from "react-apollo";
// import pixPrice from "../../graphql/pixPrice.graphql";
const PixDiscount = () => { const PixDiscount = () => {
const productContextValue = useProduct(); const productContextValue = useProduct();
@ -15,29 +13,30 @@ const PixDiscount = () => {
maximumFractionDigits: 2, 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 ( return (
<> <>
<p className={styles.pixDiscount}>{`R$ ${pixPrice}`}</p> <p className={styles.pixDiscount}>{`R$ ${pixPrice}`}</p>
{/* <p>{testingApi}</p> */}
</> </>
); );
}; };
export default PixDiscount; 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));

View File

@ -318,7 +318,7 @@
"testId": "shipping-simulator", "testId": "shipping-simulator",
"blockClass": "shipping-simulator" "blockClass": "shipping-simulator"
}, },
"children": ["shipping-simulator", "freight"] "children": ["shipping-simulator"]
}, },
"flex-layout.row#product-availability": { "flex-layout.row#product-availability": {

View File

@ -8,8 +8,5 @@
}, },
"pix-discount": { "pix-discount": {
"component": "PixDiscount" "component": "PixDiscount"
},
"freight": {
"component": "Freight"
} }
} }