Gatsby

IntelligemsReactProvider

interface IgUserContext {
  id?: string;
  isPreview?: boolean;
  isIntegration?: boolean;
  isPreviewAllTraffic?: boolean;
  originalSlug?: string;
  exps?: Record<string, string>;
  ign?: Record<string, string>;
}

interface IgConfig extends Nullable<IgUserContext> {
  config: PluginConfigType | null; // Internal Type
}

export type ActiveCurrency = string | (() => string);
type PriceFormat = 'dollars' | 'cents';

interface IntelligemsReactProviderProps {
  ig: IgConfig;
  organizationId: string; // required
  activeCurrencyCode?: ActiveCurrency;
  storefrontApiToken: string;
  debug?: boolean;
  priceFormat?: PriceFormat;
  version?: '12' | '13';
  children?: ReactNode;
}

export default function MyApp({ Component, pageProps }: AppProps) {
  return (
      <IntelligemsNextProvider
          storefrontApiToken={process.env.GATSBY_STOREFRONT_ACCESS_TOKEN}
          antiFlicker={true}
          organizationId={process.env.GATSBY_INTELLIGEMS_ORG_ID!}
      >
        ...
      </IntelligemsNextProvider>
  )
}

Modifying State Direclty

The following options are availble to change the Intelligems Context directly:

const igContext = useContext(IntelligemsContext);

interface IntelligemsContextType {
  igId: string | null
  organizationId: string;
  setOrganizationId: Dispatch<SetStateAction<string>>;
  ig: IgConfig | null;
  setIg: Dispatch<SetStateAction<IgConfig | null>>;
  exps: Exps;
  setExps: Dispatch<SetStateAction<Exps>>;
  ign: Ign;
  setIgn: Dispatch<SetStateAction<Ign>>;
  framework: Framework;
  setFramework: Dispatch<SetStateAction<Framework>>;
  activeCurrencyCode: string;
  setActiveCurrencyCode: Dispatch<SetStateAction<string>>;
  storefrontApiToken: string;
  setStorefrontApiToken: Dispatch<SetStateAction<string>>;
  priceFormat: PriceFormat;
  setPriceFormat: Dispatch<SetStateAction<PriceFormat>>;
  priceFormatter?: PriceFormatter;
}