import { create } from 'zustand';

interface NavigationTargetState {
  navigationTarget: string | null;
  setNavigationTarget: (target: string | null) => void;
  getNavigationTarget: () => string | null;
}

const useNavigationTargetStore = create<NavigationTargetState>((set, get) => ({
  navigationTarget: null,
  setNavigationTarget: (target: string | null) => {
    set({ navigationTarget: target })
  },
  getNavigationTarget: () => {
    const target = get().navigationTarget;
    if (target) {
      set({ navigationTarget: null });
    }
    return target;
  },
}));

export function useNavigationTarget() {
  return useNavigationTargetStore();
}