Skip to content

Commit

Permalink
fix: hides Search Console Stats if its not connected
Browse files Browse the repository at this point in the history
  • Loading branch information
towfiqi committed Dec 20, 2022
1 parent e3bd5b9 commit b740ef3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pages/domain/console/[slug]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const DiscoverPage: NextPage = () => {
const [scDateFilter, setSCDateFilter] = useState('thirtyDays');
const { data: appSettings } = useFetchSettings();
const { data: domainsData } = useFetchDomains(router);
const { data: keywordsData, isLoading: keywordsLoading, isFetching } = useFetchSCKeywords(router, !!(domainsData?.domains?.length));
const scConnected = !!(appSettings && appSettings?.settings?.search_console_integrated);
const { data: keywordsData, isLoading: keywordsLoading, isFetching } = useFetchSCKeywords(router, !!(domainsData?.domains?.length) && scConnected);

const theDomains: DomainType[] = (domainsData && domainsData.domains) || [];
const theKeywords: SearchAnalyticsItem[] = keywordsData?.data && keywordsData.data[scDateFilter] ? keywordsData.data[scDateFilter] : [];
Expand Down Expand Up @@ -64,7 +65,7 @@ const DiscoverPage: NextPage = () => {
isLoading={keywordsLoading || isFetching}
domain={activDomain}
keywords={theKeywords}
isConsoleIntegrated={!!(appSettings && appSettings?.settings?.search_console_integrated) }
isConsoleIntegrated={scConnected}
/>
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions pages/domain/insight/[slug]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const InsightPage: NextPage = () => {
const [scDateFilter, setSCDateFilter] = useState('thirtyDays');
const { data: appSettings } = useFetchSettings();
const { data: domainsData } = useFetchDomains(router);
const { data: insightData } = useFetchSCInsight(router, !!(domainsData?.domains?.length));
const scConnected = !!(appSettings && appSettings?.settings?.search_console_integrated);
const { data: insightData } = useFetchSCInsight(router, !!(domainsData?.domains?.length) && scConnected);

const theDomains: DomainType[] = (domainsData && domainsData.domains) || [];
const theInsight: InsightDataType = insightData && insightData.data ? insightData.data : {};
Expand Down Expand Up @@ -64,7 +65,7 @@ const InsightPage: NextPage = () => {
isLoading={false}
domain={activDomain}
insight={theInsight}
isConsoleIntegrated={!!(appSettings && appSettings?.settings?.search_console_integrated) }
isConsoleIntegrated={scConnected}
/>
</div>
</div>
Expand Down

0 comments on commit b740ef3

Please sign in to comment.