import { useAppStateContext } from '../context/user.data.context'; /** The site type /me reports for an account that sells nothing by the piece. */ export const CONTENT_SITE_TYPE = 'CONTENT'; /** * Whether the account sells nothing by the piece: a service business, an * agency, a clinic or a publisher, marked CONTENT. Its screens speak of * services and visitors and leave out the parts of a store (the cart, add to * cart, product clicks, orders). Anything else, including an older /me * without the field, reads as a store. * * @param {string | null | undefined} siteType - The account's site_type, as /me reports it. * @return {boolean} True for a content site. */ export const isContentSiteType = ( siteType: string | null | undefined ): boolean => siteType === CONTENT_SITE_TYPE; /** * Whether the signed-in account is a content site, read off the /me the app * already holds. Before /me has answered it reads as a store, the same as an * older payload without the field. * * @return {boolean} True for a content site. */ export const useContentSite = (): boolean => { const { user } = useAppStateContext(); return isContentSiteType(user?.site_type); };