mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-24 13:01:56 +00:00
30 lines
915 B
TypeScript
30 lines
915 B
TypeScript
import { create } from "zustand";
|
|
|
|
import type { CloudUpgradeFeature } from "@/types/cloud-upgrade";
|
|
|
|
interface CloudUpgradeStoreState {
|
|
activeFeature: CloudUpgradeFeature | null;
|
|
returnFocusElement: HTMLElement | null;
|
|
openCloudUpgrade: (
|
|
feature: CloudUpgradeFeature,
|
|
returnFocusElement?: HTMLElement,
|
|
) => void;
|
|
closeCloudUpgrade: () => void;
|
|
}
|
|
|
|
// Upgrade prompts are ephemeral and shared so only one modal can be open.
|
|
export const useCloudUpgradeStore = create<CloudUpgradeStoreState>((set) => ({
|
|
activeFeature: null,
|
|
returnFocusElement: null,
|
|
openCloudUpgrade: (activeFeature, requestedReturnFocusElement) =>
|
|
set({
|
|
activeFeature,
|
|
returnFocusElement:
|
|
requestedReturnFocusElement ??
|
|
(document.activeElement instanceof HTMLElement
|
|
? document.activeElement
|
|
: null),
|
|
}),
|
|
closeCloudUpgrade: () => set({ activeFeature: null }),
|
|
}));
|