diff --git a/react/components/Freight/Freight.tsx b/react/components/Freight/Freight.tsx deleted file mode 100644 index 2ed5cdc..0000000 --- a/react/components/Freight/Freight.tsx +++ /dev/null @@ -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; diff --git a/react/components/Freight/styles.css b/react/components/Freight/styles.css deleted file mode 100644 index e69de29..0000000 diff --git a/react/components/PixDiscount/PixDiscount.tsx b/react/components/PixDiscount/PixDiscount.tsx index 7170ad9..c811cad 100644 --- a/react/components/PixDiscount/PixDiscount.tsx +++ b/react/components/PixDiscount/PixDiscount.tsx @@ -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 ( <>

{`R$ ${pixPrice}`}

- {/*

{testingApi}

*/} ); }; 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)); diff --git a/store/blocks/pdp/product.jsonc b/store/blocks/pdp/product.jsonc index 4dcf756..1eb3331 100644 --- a/store/blocks/pdp/product.jsonc +++ b/store/blocks/pdp/product.jsonc @@ -318,7 +318,7 @@ "testId": "shipping-simulator", "blockClass": "shipping-simulator" }, - "children": ["shipping-simulator", "freight"] + "children": ["shipping-simulator"] }, "flex-layout.row#product-availability": { diff --git a/store/interfaces.json b/store/interfaces.json index e18f54a..085dfaf 100644 --- a/store/interfaces.json +++ b/store/interfaces.json @@ -8,8 +8,5 @@ }, "pix-discount": { "component": "PixDiscount" - }, - "freight": { - "component": "Freight" } }