Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

685 B
Raw Blame
import { adminClient, Subject, usePermissions, useResourceKey } from '@spree/dashboard-core'
import { useQuery } from '@tanstack/react-query'

const HOUR = 60 * 60 * 1000

/**
 * Whether a newer Spree release exists. Only fetched for staff who can manage
 * the store: the endpoint refuses everyone else, and the running version is
 * not theirs to see.
 */
export function useUpdateStatus() {
  const { permissions } = usePermissions()

  return useQuery({
    queryKey: useResourceKey('update-status'),
    queryFn: () => adminClient.updates.get(),
    enabled: permissions.can('manage', Subject.Store),
    staleTime: HOUR,
    refetchOnWindowFocus: false,
    retry: false,
  })
}