PHP 8.2.31
Preview: api.js Size: 992 B
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/extendify_old/src/HelpCenter/lib/api.js

import { AI_HOST } from '@constants';
import { useAIConsentStore } from '@shared/state/ai-consent';

// Additional data to send with requests
const allowList = [
	'siteId',
	'partnerId',
	'wpVersion',
	'wpLanguage',
	'devbuild',
	'isBlockTheme',
	'userId',
	'siteProfile',
];

const { showAIConsent, userGaveConsent } = useAIConsentStore.getState();

const extraBody = {
	...Object.fromEntries(
		Object.entries(window.extSharedData).filter(([key]) =>
			allowList.includes(key),
		),
	),
	showAIConsent,
	userGaveConsent,
};

export const getAnswer = ({ question, experienceLevel }) =>
	fetch(`${AI_HOST}/api/chat/ask-question`, {
		method: 'POST',
		headers: { 'Content-Type': 'application/json' },
		body: JSON.stringify({ question, experienceLevel, ...extraBody }),
	});

export const rateAnswer = ({ answerId, rating }) =>
	fetch(`${AI_HOST}/api/chat/rate-answer`, {
		method: 'POST',
		headers: { 'Content-Type': 'application/json' },
		body: JSON.stringify({ answerId, rating }),
	});

Directory Contents

Dirs: 0 × Files: 3

Name Size Perms Modified Actions
992 B lrw-r--r-- 2025-02-14 00:15:08
Edit Download
461 B lrw-r--r-- 2024-03-14 20:40:46
Edit Download
79 B lrw-r--r-- 2025-08-27 17:47:28
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).