diff --git a/studio/components/CustomCallToActions.tsx b/studio/components/CustomCallToActions.tsx deleted file mode 100644 index 7f9f4eff4..000000000 --- a/studio/components/CustomCallToActions.tsx +++ /dev/null @@ -1,81 +0,0 @@ -"use client"; - -import { Card, Text } from "@sanity/ui"; -import React, { useEffect, useState } from "react"; -import { - ArrayOfObjectsInput, - ArrayOfObjectsInputProps, - ArraySchemaType, - LoadingBlock, - useFormValue, -} from "sanity"; - -import { fetchWithToken } from "studio/lib/fetchWithToken"; -import { LANDING_PAGE_REF_QUERY } from "studio/lib/queries/siteSettings"; -import { buildPublishedId } from "studio/utils/documentUtils"; - -type CustomCallToActionsProps = ArrayOfObjectsInputProps< - { _key: string }, - ArraySchemaType ->; - -const CustomCallToActions: React.FC = (props) => { - const [isLandingPage, setIsLandingPage] = useState(false); - const [landingPageId, setLandingPageId] = useState(null); - const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); - - const documentId = useFormValue(["_id"]) as string; - - useEffect(() => { - const fetchLandingId = async () => { - try { - setLoading(true); - const landingId = await fetchWithToken(LANDING_PAGE_REF_QUERY); - setLandingPageId(landingId); - } catch (error) { - console.error("Failed to fetch navigation manager", error); - setError((error as Error).message); - } finally { - setLoading(false); - } - }; - - fetchLandingId(); - }, []); - - useEffect(() => { - if (!landingPageId) return; - - const currentPageId = buildPublishedId(documentId); - - const isLanding = landingPageId === currentPageId; - - setIsLandingPage(isLanding); - }, [documentId, landingPageId]); - - if (loading) { - return ; - } - - if (error) { - return ( - - Error: {error} - - ); - } - - if (!isLandingPage) { - return ( - - - This feature is only available for landing pages - - - ); - } - return ; -}; - -export default CustomCallToActions; diff --git a/studio/lib/queries/siteSettings.ts b/studio/lib/queries/siteSettings.ts index d4e2e1095..6557111ca 100644 --- a/studio/lib/queries/siteSettings.ts +++ b/studio/lib/queries/siteSettings.ts @@ -38,10 +38,6 @@ export const NAV_QUERY = groq` } `; -export const LANDING_PAGE_REF_QUERY = groq` - *[_type == "navigationManager"][0].setLanding._ref -`; - export const LANDING_PAGE_QUERY = groq` *[_type == "navigationManager"][0].setLanding -> { ${PAGE_FRAGMENT}