Sh3ll
OdayForums


Server : LiteSpeed
System : Linux premium84.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : claqxcrl ( 523)
PHP Version : 8.1.32
Disable Function : NONE
Directory :  /home/claqxcrl/www/wp-content/plugins/extendify/src/Assist/components/dashboard/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/claqxcrl/www/wp-content/plugins/extendify/src/Assist/components/dashboard/Recommendations.jsx
import { __ } from '@wordpress/i18n';
import { safeParseJson } from '@shared/lib/parsing';
import { RecommendationCard } from '@assist/components/dashboard/RecommendationCard';
import { isAtLeastNDaysAgo } from '@assist/lib/recommendations';

const siteCreatedAt = window.extSharedData?.siteCreatedAt ?? '';
const recommendations =
	safeParseJson(window.extSharedData.resourceData)?.recommendations || [];
const goals =
	safeParseJson(window.extSharedData?.userData?.userSelectionData)?.state
		?.goals || [];
const plugins =
	window.extSharedData?.activePlugins?.map((plugin) => plugin.split('/')[0]) ||
	[];

const getRecommendations = () =>
	// Filter out recs that have goal deps that don't appear in the user's goals list
	// If no goal deps, show the rec
	recommendations
		.filter((rec) =>
			rec?.goalDepSlugs?.length
				? rec?.goalDepSlugs?.every((dep) =>
						goals.find(({ slug }) => slug === dep),
					)
				: true,
		)
		// Filter out recs that have pluginExclusions, and the plugin is already installed
		.filter((rec) =>
			rec?.pluginExclusions?.length
				? rec?.pluginExclusions?.every(
						(dep) => !plugins.find((plugin) => plugin === dep)?.length,
					)
				: true,
		)
		// Filter out recs where there is a plugin dep, and the plugin is not installed
		.filter((rec) =>
			rec?.pluginDepSlugs?.length
				? rec?.pluginDepSlugs?.every(
						(dep) => plugins.find((plugin) => plugin === dep)?.length,
					)
				: true,
		)
		.sort((a, b) => b.priority - a.priority)
		// filter out recs based on the showAfterDay field
		.filter((rec) =>
			// Only show recommendations after the number of days set in rec.showAfterDay
			isAtLeastNDaysAgo(siteCreatedAt, rec?.showAfterDay ?? 0) ? rec : false,
		);

export const Recommendations = () => {
	const filteredRecommendations = getRecommendations();

	if (!filteredRecommendations?.length) return;

	return (
		<div
			data-test="assist-recommendations-module"
			id="assist-recommendations-module"
			className="h-full w-full rounded border border-gray-300 bg-white p-5 text-base lg:p-8">
			<h2 className="mb-4 mt-0 text-lg font-semibold">
				{__('Website Tools & Plugins', 'extendify-local')}
			</h2>
			<div
				className="grid gap-y-3 md:grid-cols-3 md:gap-3"
				data-test="assist-recommendations-module-list">
				{filteredRecommendations.map((recommendation) => (
					<RecommendationCard
						key={recommendation.slug}
						recommendation={recommendation}
					/>
				))}
			</div>
		</div>
	);
};

ZeroDay Forums Mini