diff --git a/pwa/src/templates/landing/LandingTemplate.tsx b/pwa/src/templates/landing/LandingTemplate.tsx index e5a60302..fd8e27be 100644 --- a/pwa/src/templates/landing/LandingTemplate.tsx +++ b/pwa/src/templates/landing/LandingTemplate.tsx @@ -15,53 +15,11 @@ import { useTranslation } from "react-i18next"; export const LandingTemplate: React.FC = () => { const { currentPage, setCurrentPage } = usePaginationContext(); const { filters } = useFiltersContext(); - const { t, i18n } = useTranslation(); + const { t } = useTranslation(); const queryClient = new QueryClient(); const getItems = useOpenWoo(queryClient).getAll(filters, currentPage); - React.useEffect(() => { - if (!getItems.data?.results.length) return; - - //Updates aria-label of previous and next pagination buttons to translatable aria-labels - document - .querySelectorAll('[class*="Pagination-module--previous"]')[0] - ?.children[0].setAttribute("aria-label", `${t("Previous page")}`); - document - .querySelectorAll('[class*="Pagination-module--next"]')[0] - ?.children[0].setAttribute("aria-label", `${t("Next page")}`); - - //Adds tabindex of -1 to all disabled and unused pagination buttons - document.querySelectorAll('[class*="Pagination-module--disabled"]')[0]?.children[0].setAttribute("tabindex", "-1"); - document.querySelectorAll('[class*="Pagination-module--disabled"]')[0]?.setAttribute("tabindex", "-1"); - document - .querySelectorAll('[class*="Pagination-module--previous"]')[0] - ?.children[0].children[0].setAttribute("tabindex", "-1"); - document - .querySelectorAll('[class*="Pagination-module--next"]')[0] - ?.children[0].children[0].setAttribute("tabindex", "-1"); - - //Updates aria-label of all page pagination buttons to translatable aria-labels - let pageNumbers = Array.from(document.querySelectorAll('[class*="Pagination-module--container"]')[0].children); - var removeStr = ["Pagination-module--previous", "Pagination-module--next"]; - pageNumbers = pageNumbers.filter(function (val) { - var found = false; - for (var i = 0; i < removeStr.length; i++) { - var str = removeStr[i]; - if (val.className.indexOf(str) > -1) { - return false; - } - } - return true; - }); - pageNumbers.map((value: any) => { - const label = value.children[0].ariaLabel; - const lastSpaceIndex = label.lastIndexOf(" "); - const pageNumber = label.substring(lastSpaceIndex + 1); - value.children[0].setAttribute("aria-label", `${t("Page")} ${pageNumber}`); - }); - }, [getItems.isSuccess, i18n.language]); - return ( <>

@@ -76,7 +34,11 @@ export const LandingTemplate: React.FC = () => {
- +
)} {getItems.isLoading && }