$40 GRAYBYTE WORDPRESS FILE MANAGER $64

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 172.67.217.254 | ADMIN IP 216.73.216.180
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : mail

/home/bravrvjk/dantho.rw/wp-content/plugins/extendify/src/Shared/state/

HOME
Current File : /home/bravrvjk/dantho.rw/wp-content/plugins/extendify/src/Shared/state//ai-consent.js
import apiFetch from '@wordpress/api-fetch';
import { create } from 'zustand';
import { devtools, persist } from 'zustand/middleware';

/**
 * Implementation of a custom storage engine for Zustand's persist middleware.
 * It replicates the Storage interface defined in https://developer.mozilla.org/en-US/docs/Web/API/Storage
 *
 * This storage uses a WordPress custom endpoint to persist the consent in `wp_usermeta`.
 */
const storage = {
	setItem: (_name, store) =>
		apiFetch({
			path: '/extendify/v1/shared/update-user-meta',
			method: 'POST',
			data: { option: 'ai_consent', value: store.state.userGaveConsent },
		}),
};

const state = (set, get) => ({
	showAIConsent: window.extSharedData?.showAIConsent ?? false,
	consentTermsCustom: window.extSharedData?.consentTermsCustom ?? '',
	userGaveConsent: window.extSharedData?.userGaveConsent ?? false,
	setUserGaveConsent: (userGaveConsent) => set({ userGaveConsent }),
	// Context refers to the feature where the function is being used.
	shouldShowAIConsent: (context) => {
		const { showAIConsent, consentTermsCustom, userGaveConsent } = get();
		const enabled = showAIConsent && consentTermsCustom;
		const display = {
			launch: enabled,
			draft: enabled && !userGaveConsent,
			'help-center': enabled && !userGaveConsent,
		};
		return display?.[context] ?? false;
	},
});

export const useAIConsentStore = create(
	persist(devtools(state, { name: 'Extendify AI Consent' }), {
		name: 'extendify-ai-consent',
		storage,
		skipHydration: true,
	}),
);


Current_dir [ WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
6 Nov 2025 10.43 AM
bravrvjk / bravrvjk
0755
activity.js
1.224 KB
8 Oct 2024 2.19 PM
bravrvjk / bravrvjk
0644
ai-consent.js
1.479 KB
19 May 2025 4.47 PM
bravrvjk / bravrvjk
0644
generate-images.js
1.884 KB
23 Oct 2025 8.20 PM
bravrvjk / bravrvjk
0644
site-profile.js
1.515 KB
13 Mar 2025 9.10 PM
bravrvjk / bravrvjk
0644
unsplash-cache.js
0.646 KB
13 Mar 2025 9.10 PM
bravrvjk / bravrvjk
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF