PHP 8.2.31
Preview: site-profile.js Size: 914 B
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/extendify_old/src/Shared/state/site-profile.js

import apiFetch from '@wordpress/api-fetch';
import { create } from 'zustand';
import { createJSONStorage, devtools, persist } from 'zustand/middleware';

const { siteProfile } = window.extSharedData;

const state = (set) => ({
	siteProfile,
	setSiteProfile(data) {
		set((state) => {
			const updatedProfile = {
				...state.siteProfile,
				...data,
			};
			return { siteProfile: updatedProfile };
		});
	},
	resetState() {
		set({ siteProfile });
	},
});

const path = '/extendify/v1/shared/site-profile';
const storage = {
	getItem: async () => await apiFetch({ path }),
	setItem: async (_name, state) => {
		await apiFetch({
			path,
			method: 'POST',
			data: { siteProfile: JSON.stringify(state) },
		});
	},
};

export const useSiteProfileStore = create(
	persist(devtools(state, { name: 'Extendify Site Profile' }), {
		storage: createJSONStorage(() => storage),
		skipHydration: false,
	}),
	state,
);

Directory Contents

Dirs: 1 × Files: 5

Name Size Perms Modified Actions
__tests__ DIR
- drwxr-xr-x 2026-04-28 02:40:02
Edit Download
1.22 KB lrw-r--r-- 2026-02-19 03:27:14
Edit Download
1.53 KB lrw-r--r-- 2025-12-17 19:09:10
Edit Download
1.88 KB lrw-r--r-- 2026-02-19 03:27:14
Edit Download
914 B lrw-r--r-- 2026-02-27 04:48:52
Edit Download
661 B lrw-r--r-- 2026-02-19 03:27:14
Edit Download

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