index.tsx 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import Link from "next/link";
  2. import { Suspense } from "react";
  3. import { serverGraphqlFetch } from "@/utils/bagisto";
  4. import type {
  5. GetFooterResponse,
  6. ThemeCustomizationResult
  7. } from "@/types/theme/theme-customization";
  8. import {
  9. GET_FOOTER
  10. } from "@/graphql";
  11. import { env } from "@/env";
  12. import LogoIcon from "@components/common/icons/LogoIcon";
  13. import FaceBookIcon from "@components/common/icons/social-icon/FaceBookIcon";
  14. import InstaGramIcon from "@components/common/icons/social-icon/InstaGramIcon";
  15. import TwitterIcon from "@components/common/icons/social-icon/TwitterIcon";
  16. import Subscribe from "./Subscribe";
  17. import FooterMenu from "./FooterMenu";
  18. async function getFooterData(): Promise<ThemeCustomizationResult> {
  19. const [{data: footerRes}, {data:servicesRes}] = await Promise.all([
  20. serverGraphqlFetch<GetFooterResponse,{type: string;}>({
  21. query: GET_FOOTER,
  22. variables:{
  23. type: "footer_links",
  24. },
  25. takeAuthorization: false
  26. }),
  27. serverGraphqlFetch<GetFooterResponse,{type: string;}>({
  28. query: GET_FOOTER,
  29. variables:{
  30. type: "services_content",
  31. },
  32. takeAuthorization: false
  33. }),
  34. ]);
  35. return {
  36. footer_links: footerRes,
  37. services_content: servicesRes,
  38. };
  39. }
  40. export default async function Footer() {
  41. const currentYear = new Date().getFullYear();
  42. const copyrightDate = 2010 + (currentYear > 2010 ? `-${currentYear}` : "");
  43. const skeleton =
  44. "w-full h-6 animate-pulse rounded bg-neutral-200 dark:bg-neutral-700";
  45. const menu = await getFooterData();
  46. const copyrightName = env.STORE_NAME;
  47. return (
  48. <>
  49. <footer className="border-t border-neutral-200 text-sm text-neutral-500">
  50. <div className="mx-auto flex w-full flex-col justify-between gap-6 gap-y-6 px-6 py-12 text-sm">
  51. <div className="flex flex-col gap-[14px]">
  52. <Link
  53. className="flex items-center gap-2 cursor-pointer"
  54. href="/"
  55. aria-label="Go to homepage"
  56. title="Go to homepage"
  57. >
  58. <LogoIcon />
  59. <span className="sr-only">Go to homepage</span>
  60. </Link>
  61. <div className="flex gap-[14px]">
  62. <Link
  63. href={"#"}
  64. aria-label="Visit Bagisto Store on Facebook"
  65. title="Facebook"
  66. target="_blank"
  67. className="cursor-pointer"
  68. >
  69. <FaceBookIcon />
  70. <span className="sr-only">Facebook</span>
  71. </Link>
  72. <Link
  73. href={"#"}
  74. aria-label="Visit Bagisto Store on Instagram"
  75. title="Instagram"
  76. target="_blank"
  77. className="cursor-pointer"
  78. >
  79. <InstaGramIcon />
  80. <span className="sr-only">Instagram</span>
  81. </Link>
  82. <Link
  83. href={"#"}
  84. aria-label="Visit Bagisto Store on Twitter"
  85. title="Twitter"
  86. target="_blank"
  87. className="cursor-pointer"
  88. >
  89. <TwitterIcon />
  90. <span className="sr-only">Twitter</span>
  91. </Link>
  92. </div>
  93. </div>
  94. <div className="flex flex-col gap-x-8">
  95. <Suspense
  96. fallback={
  97. <div className="flex h-[188px] w-[200px] flex-col gap-2">
  98. {Array(6)
  99. .fill(0)
  100. .map((_, index) => (
  101. <div key={index} className={skeleton} />
  102. ))}
  103. </div>
  104. }
  105. >
  106. <FooterMenu
  107. menu={menu?.footer_links?.themeCustomizations?.edges}
  108. />
  109. </Suspense>
  110. <Subscribe />
  111. </div>
  112. </div>
  113. <div className="border-t border-neutral-200 py-6 text-sm dark:border-neutral-700">
  114. <div className="mx-auto flex w-full max-w-screen-2xl flex-col justify-center gap-1 px-4 md:flex-row">
  115. <p className="text-center">
  116. &copy; {copyrightDate} {copyrightName}
  117. {copyrightName.length && !copyrightName.endsWith(".")
  118. ? "."
  119. : ""}{" "}
  120. All rights reserved.
  121. </p>
  122. <hr className="mx-4 hidden h-4 w-[1px] border-l border-neutral-400 md:inline-block" />
  123. <p className="text-center">Designed in Bagisto</p>
  124. </div>
  125. </div>
  126. </footer>
  127. </>
  128. );
  129. }