Skip to content

Commit

Permalink
fix useSales init script (#1752)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkim93 authored Nov 1, 2023
1 parent 7c736ac commit 70f9395
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions blocks/subscriptions-block/components/useSales.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ import getProperties from "fusion:properties";
const useSales = () => {
const { arcSite } = useFusionContext();
const { api } = getProperties(arcSite);
const [isInit, setIsInit] = useState(!!Identity.apiOrigin);
const [isInit, setIsInit] = useState(!!Sales.apiOrigin);
const isIdentityInit = !!Identity.apiOrigin;

if (!isInit && arcSite && api?.identity?.origin) {
Identity.options({ apiOrigin: api.identity.origin });
const identityApiOrigin = api?.identity?.origin ?? api?.sales?.origin ?? api?.retail?.origin;
const salesApiOrigin = api?.sales?.origin ?? api?.identity?.origin ?? api?.retail?.origin;

if (!isIdentityInit && arcSite && identityApiOrigin) {
Identity.options({ apiOrigin: identityApiOrigin });
}

if (!isInit && arcSite && salesApiOrigin) {
Sales.options({
apiOrigin: api?.retail?.origin,
apiOrigin: salesApiOrigin,
Identity,
});

Expand Down

0 comments on commit 70f9395

Please sign in to comment.