Skip to content

Commit

Permalink
cleanup country selector
Browse files Browse the repository at this point in the history
  • Loading branch information
vraja-pro committed Dec 13, 2024
1 parent 7826a9d commit c710947
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 133 deletions.
28 changes: 19 additions & 9 deletions packages/js/src/components/SEMrushRelatedKeyphrasesModalContent.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/* External dependencies */
import { KeyphrasesTable, UserMessage, PremiumUpsell } from "@yoast/related-keyphrase-suggestions";
import { useCallback, useState } from "@wordpress/element";
import { CountrySelector, KeyphrasesTable, UserMessage, PremiumUpsell } from "@yoast/related-keyphrase-suggestions";
import { Root } from "@yoast/ui-library";
import PropTypes from "prop-types";
import { isEmpty } from "lodash";

/* Internal dependencies */
import SEMrushCountrySelector from "./modals/SEMrushCountrySelector";

/**
* Determines whether the error property is present in the passed response object.
*
Expand Down Expand Up @@ -88,6 +85,18 @@ export default function RelatedKeyphraseModalContent( props ) {
userLocale,
} = props;

const [ activeCountryCode, setActiveCountryCode ] = useState( countryCode );

/**
* Sends a new related keyphrases request to SEMrush and updates the semrush_country_code value in the database.
*
* @returns {void}
*/
const relatedKeyphrasesRequest = useCallback( async() => {
newRequest( countryCode, keyphrase );
setActiveCountryCode( countryCode );
}, [ countryCode, keyphrase, newRequest ] );

return (
<Root context={ { isRtl } }>

Expand All @@ -96,11 +105,12 @@ export default function RelatedKeyphraseModalContent( props ) {
className="yst-mb-4"
/> }

{ ! requestLimitReached && <SEMrushCountrySelector
{ ! requestLimitReached && <CountrySelector
countryCode={ countryCode }
setCountry={ setCountry }
newRequest={ newRequest }
keyphrase={ keyphrase }
activeCountryCode={ activeCountryCode }
onChange={ setCountry }
onClick={ relatedKeyphrasesRequest }
className="yst-mb-4"
userLocale={ userLocale.split( "_" )[ 0 ] }
/> }

Expand Down
64 changes: 0 additions & 64 deletions packages/js/src/components/modals/SEMrushCountrySelector.js

This file was deleted.

60 changes: 0 additions & 60 deletions packages/js/tests/components/SEMrushCountrySelector.test.js

This file was deleted.

0 comments on commit c710947

Please sign in to comment.