HEX
Server: LiteSpeed
System: Linux server902.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: deshuvsd (2181)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/deshuvsd/www/wp-content/plugins/surerank/src/apps/admin-dashboard/site-selector.js
import { Select } from '@bsf/force-ui';
import { __ } from '@wordpress/i18n';
import { useMemo } from '@wordpress/element';
import { InfoTooltip } from '@AdminComponents/tooltip';

const SiteSelector = ( {
	sites = [],
	selectedSite,
	onSiteSelect,
	placeholder = __( 'Select a site', 'surerank' ),
} ) => {
	// Create options with JSX components
	const options = useMemo( () => {
		const siteOptions = [];

		// Add verified sites first
		sites.forEach( ( site ) => {
			const tooltipText = site.isVerified
				? ''
				: __( 'Not Verified', 'surerank' );

			siteOptions.push( {
				label: site.siteUrl,
				value: site.siteUrl,
				tooltipText,
				isVerified: site.isVerified,
			} );
		} );

		return siteOptions;
	}, [ sites ] );

	return (
		<Select
			value={ selectedSite }
			onChange={ onSiteSelect }
			size="md"
			combobox
			className="w-full"
		>
			<Select.Button
				placeholder={ placeholder }
				render={ ( selectedValue ) => selectedValue || placeholder }
			/>
			<Select.Options>
				{ options.map( ( option ) => (
					<Select.Option
						key={ option.value }
						value={ option.value }
						title={ option.tooltipText }
					>
						{ /* Enhanced JSX */ }
						<div className="flex items-center justify-between w-full">
							<span className="truncate">{ option.label }</span>
							{ ! option.isVerified && (
								<div className="flex items-center gap-1 mr-1">
									<InfoTooltip
										content={
											option.tooltipText ||
											( option.isCurrentSite
												? __(
														'Not Connected',
														'surerank'
												  )
												: __(
														'Not Verified',
														'surerank'
												  ) )
										}
										className="z-[9999]"
									/>
								</div>
							) }
						</div>
					</Select.Option>
				) ) }
			</Select.Options>
		</Select>
	);
};

export default SiteSelector;