Skip to content

Commit

Permalink
feat: Shows total keywords count in domains page
Browse files Browse the repository at this point in the history
  • Loading branch information
towfiqi committed Nov 11, 2023
1 parent 60c68bd commit fbd23ed
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pages/domains/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import type { NextPage } from 'next';
import Head from 'next/head';
import { useRouter } from 'next/router';
Expand All @@ -23,6 +23,16 @@ const SingleDomain: NextPage = () => {
const { data: appSettings } = useFetchSettings();
const { data: domainsData, isLoading } = useFetchDomains(router, true);

const totalKeywords = useMemo(() => {
let keywords = 0;
if (domainsData?.domains) {
domainsData.domains.forEach(async (domain:DomainType) => {
keywords += domain?.keywordCount || 0;
});
}
return keywords;
}, [domainsData]);

useEffect(() => {
if (domainsData?.domains && domainsData.domains.length > 0 && appSettings?.settings?.screenshot_key) {
domainsData.domains.forEach(async (domain:DomainType) => {
Expand Down Expand Up @@ -69,7 +79,9 @@ const SingleDomain: NextPage = () => {

<div className="flex flex-col w-full max-w-5xl mx-auto p-6 lg:mt-24 lg:p-0">
<div className='flex justify-between mb-2 items-center'>
<div className=' text-sm'>{domainsData?.domains?.length || 0} Domains</div>
<div className=' text-sm text-gray-600'>
{domainsData?.domains?.length || 0} Domains <span className=' text-gray-300 ml-1 mr-1'>|</span> {totalKeywords} keywords
</div>
<div>
<button
className={'ml-2 inline-block py-2 text-blue-700 font-bold text-sm'}
Expand Down

0 comments on commit fbd23ed

Please sign in to comment.