PHP 8.2.31
Preview: user.js Size: 899 B
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/extendify_old/src/Library/state/user.js

import { safeParseJson } from '@shared/lib/parsing';
import apiFetch from '@wordpress/api-fetch';
import { create } from 'zustand';
import { createJSONStorage, persist } from 'zustand/middleware';

const storage = {
	getItem: async () => await apiFetch({ path: '/wp/v2/users/me' }),
	setItem: async (_name, value) =>
		await apiFetch({
			path: '/wp/v2/users/me',
			method: 'PUT',
			data: { extendify_library_user: value },
		}),
};

export const useUserStore = create(
	persist(
		(set, get) => ({
			openOnNewPage: true,
			updateUserOption: (key, value) => {
				if (!Object.keys(get()).includes(key)) return;
				set({ [key]: value });
			},
			...(safeParseJson(window.extLibraryData.userInfo)?.state ?? {}),
		}),
		{
			name: 'extendify_library_user',
			storage: createJSONStorage(() => storage),
			partialize: (state) => ({ ...state, ready: false }),
			skipHydration: true,
		},
	),
);

Directory Contents

Dirs: 0 × Files: 4

Name Size Perms Modified Actions
299 B lrw-r--r-- 2025-03-13 21:10:44
Edit Download
482 B lrw-r--r-- 2023-10-21 00:04:20
Edit Download
945 B lrw-r--r-- 2026-02-27 04:48:52
Edit Download
899 B lrw-r--r-- 2026-02-19 03:27:14
Edit Download

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