import { AFFILIATE_PARAM_KEYS } from '#lib/constants' import { useRegisterAddonStore } from '#lib/stores' /** * Handles the Affiliate register and updates keys the store. * * @returns {Object} Params an object key and value after updates set store. */ export function useRegisterAddon() { const store = useRegisterAddonStore() const urlSearchParams = new URLSearchParams(window.location.search) const params = Object.fromEntries(urlSearchParams.entries()) let forceUpdateStore = false for (const key in params) { if (AFFILIATE_PARAM_KEYS.includes(key)) { forceUpdateStore = true } } if (forceUpdateStore) { store.setRegisterAddon(params) } }