@veracity/vui
Version:
Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.
39 lines (37 loc) • 1.14 kB
JavaScript
import { cdnUrls } from "../core/consts.js";
import { isObject } from "../utils/assertion.js";
import { useLinks } from "../core/links.js";
import { useEffect, useState } from "react";
//#region src/footer/helpers.ts
/** Loads templates for Footer links and enriches them with urls from LinksContext. */
function useFooterLinks(env) {
const [templates, setTemplates] = useState({});
const [links] = useLinks();
useEffect(() => {
loadFooterLinks();
async function loadFooterLinks() {
try {
const response = await fetch(`${cdnUrls[env]}/common/data/links/footer.json`);
if (!response.ok) return;
const data = await response.json();
if (isObject(data)) setTemplates(data);
} catch {
console.error("Failed to retrieve footer data.");
}
}
}, [env]);
return {
columns: templates.columns?.map((column) => column.map((section) => ({
...section,
links: section.links?.map((link) => ({
...link,
url: links?.[link?.id ?? ""]
}))
}))),
linkedIn: templates.linkedIn
};
}
//#endregion
export { useFooterLinks };
globalThis.__vuiVersion__ = "5.3.1"
//# sourceMappingURL=helpers.js.map