@lana-commerce/core 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +531 -0
- package/cjs/actionLock.js +31 -0
- package/cjs/addEmptyListItem.js +7 -0
- package/cjs/aggregateOptions.js +178 -0
- package/cjs/analytics.js +90 -0
- package/cjs/analyticsProductData.js +33 -0
- package/cjs/arrayToDict.js +12 -0
- package/cjs/asyncModuleWrapper.js +52 -0
- package/cjs/averageReviewScore.js +45 -0
- package/cjs/buildconfig.js +16 -0
- package/cjs/cachedLoader.js +36 -0
- package/cjs/canonicalVariantURL.js +2 -0
- package/cjs/cartOperation.js +132 -0
- package/cjs/categorySEO.js +20 -0
- package/cjs/commonTypes.js +2 -0
- package/cjs/compact.js +8 -0
- package/cjs/configLoader.js +69 -0
- package/cjs/controlledQueue.js +46 -0
- package/cjs/convertImageURL.js +19 -0
- package/cjs/dataLoader.js +185 -0
- package/cjs/defaultVariant.js +30 -0
- package/cjs/effector/clearOnChangeAfterDelay.js +17 -0
- package/cjs/effector/combineEvery.js +8 -0
- package/cjs/effector/combineSome.js +8 -0
- package/cjs/effector/debounced.js +18 -0
- package/cjs/effector/form.js +168 -0
- package/cjs/effector/hideOnChangeAfterDelay.js +17 -0
- package/cjs/effector/requestResponse.js +30 -0
- package/cjs/effector/requestResponseMulti.js +51 -0
- package/cjs/effector/restoreNamed.js +8 -0
- package/cjs/effector/split.js +29 -0
- package/cjs/effector/validator.js +33 -0
- package/cjs/effector/wrapSignInRequired.js +13 -0
- package/cjs/exceptions.js +6 -0
- package/cjs/fetchAllItems.js +56 -0
- package/cjs/file.js +83 -0
- package/cjs/fileWebsocket.js +83 -0
- package/cjs/filterFunc.js +48 -0
- package/cjs/filterFuncBrand.js +12 -0
- package/cjs/filterFuncCategory.js +12 -0
- package/cjs/filterFuncContentBlock.js +19 -0
- package/cjs/filterFuncCustomer.js +161 -0
- package/cjs/filterFuncDataFeed.js +54 -0
- package/cjs/filterFuncOrder.js +334 -0
- package/cjs/filterFuncPreprocess.js +14 -0
- package/cjs/filterFuncProduct.js +70 -0
- package/cjs/filterFuncPurchaseOrder.js +126 -0
- package/cjs/filterFuncSupplier.js +36 -0
- package/cjs/filterFuncTransfer.js +135 -0
- package/cjs/formatAbbrevNumber.js +21 -0
- package/cjs/formatCurrency.js +47 -0
- package/cjs/formatToJSX.js +123 -0
- package/cjs/fulfillmentNumber.js +7 -0
- package/cjs/generateRandomToken.js +12 -0
- package/cjs/generateUUID.js +10 -0
- package/cjs/generated/codes.js +47 -0
- package/cjs/genericFile.js +73 -0
- package/cjs/getSalesChannelID.js +13 -0
- package/cjs/getSessionID.js +13 -0
- package/cjs/getTimezone.js +12 -0
- package/cjs/graphql/fragments/Branding.js +3 -0
- package/cjs/graphql/fragments/BrandingField.js +3 -0
- package/cjs/graphql/fragments/CartCustomItem.js +3 -0
- package/cjs/graphql/fragments/CartOrder.js +3 -0
- package/cjs/graphql/fragments/CartVariant.js +3 -0
- package/cjs/graphql/fragments/CartVariantFull.js +3 -0
- package/cjs/graphql/fragments/Category.js +3 -0
- package/cjs/graphql/fragments/CommonCartVariant.js +3 -0
- package/cjs/graphql/fragments/Currency.js +3 -0
- package/cjs/graphql/fragments/CurrencyPrice.js +3 -0
- package/cjs/graphql/fragments/CustomField.js +3 -0
- package/cjs/graphql/fragments/CustomFieldObjects.js +3 -0
- package/cjs/graphql/fragments/Customer.js +3 -0
- package/cjs/graphql/fragments/CustomerBalance.js +3 -0
- package/cjs/graphql/fragments/CustomerBalanceHistory.js +3 -0
- package/cjs/graphql/fragments/CustomerFavorite.js +3 -0
- package/cjs/graphql/fragments/CustomerFavoriteShort.js +3 -0
- package/cjs/graphql/fragments/CustomerOAuthProvider.js +3 -0
- package/cjs/graphql/fragments/CustomerOrderBrief.js +3 -0
- package/cjs/graphql/fragments/CustomerOrderFulfillment.js +3 -0
- package/cjs/graphql/fragments/CustomerOrderFull.js +3 -0
- package/cjs/graphql/fragments/CustomerPaymentSource.js +3 -0
- package/cjs/graphql/fragments/CustomerReturnBrief.js +3 -0
- package/cjs/graphql/fragments/CustomerReturnFull.js +3 -0
- package/cjs/graphql/fragments/CustomerReturnPolicy.js +3 -0
- package/cjs/graphql/fragments/CustomerSubscriptionBrief.js +3 -0
- package/cjs/graphql/fragments/CustomerSubscriptionFull.js +3 -0
- package/cjs/graphql/fragments/File.js +3 -0
- package/cjs/graphql/fragments/FileForUpload.js +3 -0
- package/cjs/graphql/fragments/FileNoFallback.js +3 -0
- package/cjs/graphql/fragments/FullAddress.js +3 -0
- package/cjs/graphql/fragments/Gateway.js +3 -0
- package/cjs/graphql/fragments/GatewayManual.js +3 -0
- package/cjs/graphql/fragments/GatewayPaypal.js +3 -0
- package/cjs/graphql/fragments/GatewayStripe.js +3 -0
- package/cjs/graphql/fragments/GatewayTest.js +3 -0
- package/cjs/graphql/fragments/IPAndUAInfo.js +3 -0
- package/cjs/graphql/fragments/InfoCountry.js +3 -0
- package/cjs/graphql/fragments/InfoCountryDedupField.js +3 -0
- package/cjs/graphql/fragments/InfoCurrency.js +3 -0
- package/cjs/graphql/fragments/InfoProvince.js +3 -0
- package/cjs/graphql/fragments/KeyValue.js +3 -0
- package/cjs/graphql/fragments/LineItemField.js +3 -0
- package/cjs/graphql/fragments/MediaFile.js +3 -0
- package/cjs/graphql/fragments/MinCurrencyPrice.js +3 -0
- package/cjs/graphql/fragments/ProductField.js +3 -0
- package/cjs/graphql/fragments/ProductFieldSet.js +3 -0
- package/cjs/graphql/fragments/ProductFlat.js +3 -0
- package/cjs/graphql/fragments/ProductQuestion.js +3 -0
- package/cjs/graphql/fragments/ProductQuestionAnswer.js +3 -0
- package/cjs/graphql/fragments/ProductQuestionPage.js +3 -0
- package/cjs/graphql/fragments/ProductReview.js +3 -0
- package/cjs/graphql/fragments/ProductReviewAnswer.js +3 -0
- package/cjs/graphql/fragments/ProductReviewAverageScore.js +3 -0
- package/cjs/graphql/fragments/ProductReviewPage.js +3 -0
- package/cjs/graphql/fragments/ProductReviewScore.js +3 -0
- package/cjs/graphql/fragments/ProductReviewSurveyAnswer.js +3 -0
- package/cjs/graphql/fragments/ProductSearchOptionAgg.js +3 -0
- package/cjs/graphql/fragments/ProductSearchResult.js +3 -0
- package/cjs/graphql/fragments/ReturnReason.js +3 -0
- package/cjs/graphql/fragments/ReviewDimension.js +3 -0
- package/cjs/graphql/fragments/ReviewDimensionSet.js +3 -0
- package/cjs/graphql/fragments/ReviewImagePage.js +3 -0
- package/cjs/graphql/fragments/ReviewQuestionProduct.js +3 -0
- package/cjs/graphql/fragments/ReviewSettings.js +3 -0
- package/cjs/graphql/fragments/SearchProduct.js +3 -0
- package/cjs/graphql/fragments/Shop.js +3 -0
- package/cjs/graphql/fragments/SubscriptionPlan.js +3 -0
- package/cjs/graphql/fragments/SurveyQuestion.js +3 -0
- package/cjs/graphql/fragments/TieredPricing.js +3 -0
- package/cjs/graphql/fragments/TieredPricingTier.js +3 -0
- package/cjs/graphql/fragments/VariantOption.js +3 -0
- package/cjs/graphql/operations/ApplyGiftCardMutation.js +3 -0
- package/cjs/graphql/operations/AuthRequestMutation.js +3 -0
- package/cjs/graphql/operations/CancelOrderMutation.js +3 -0
- package/cjs/graphql/operations/CancelSubscriptionMutation.js +3 -0
- package/cjs/graphql/operations/ConnectOAuth2Mutation.js +3 -0
- package/cjs/graphql/operations/CreateCartMutation.js +26 -0
- package/cjs/graphql/operations/CreateFavoriteMutation.js +22 -0
- package/cjs/graphql/operations/CreateFileMutation.js +6 -0
- package/cjs/graphql/operations/CreatePaymentSourceMutation.js +6 -0
- package/cjs/graphql/operations/CreateProductQuestionAnswerMutation.js +3 -0
- package/cjs/graphql/operations/CreateProductQuestionMutation.js +8 -0
- package/cjs/graphql/operations/CreateProductReviewMutation.js +18 -0
- package/cjs/graphql/operations/CreateReturnMutation.js +22 -0
- package/cjs/graphql/operations/DeleteFavoriteMutation.js +3 -0
- package/cjs/graphql/operations/DeletePaymentSourceMutation.js +3 -0
- package/cjs/graphql/operations/DeleteProductQuestionAnswerMutation.js +3 -0
- package/cjs/graphql/operations/DeleteProductQuestionMutation.js +3 -0
- package/cjs/graphql/operations/DeleteProductReviewMutation.js +3 -0
- package/cjs/graphql/operations/DisconnectOAuth2Mutation.js +3 -0
- package/cjs/graphql/operations/EditSubscriptionMutation.js +3 -0
- package/cjs/graphql/operations/FileUploadedMutation.js +6 -0
- package/cjs/graphql/operations/FlagQuestionAnswerMutation.js +3 -0
- package/cjs/graphql/operations/FlagQuestionMutation.js +3 -0
- package/cjs/graphql/operations/FlagReviewAnswerMutation.js +3 -0
- package/cjs/graphql/operations/FlagReviewMutation.js +3 -0
- package/cjs/graphql/operations/GetBrandingQuery.js +10 -0
- package/cjs/graphql/operations/GetCartQuery.js +26 -0
- package/cjs/graphql/operations/GetCustomerAddressesPageDataQuery.js +16 -0
- package/cjs/graphql/operations/GetCustomerBalanceHistoryPageQuery.js +6 -0
- package/cjs/graphql/operations/GetCustomerBalanceQuery.js +8 -0
- package/cjs/graphql/operations/GetCustomerInfoQuery.js +10 -0
- package/cjs/graphql/operations/GetCustomerQuery.js +8 -0
- package/cjs/graphql/operations/GetFavoritesQuery.js +22 -0
- package/cjs/graphql/operations/GetFileStatusQuery.js +6 -0
- package/cjs/graphql/operations/GetGatewaysQuery.js +14 -0
- package/cjs/graphql/operations/GetInfoCurrenciesQuery.js +6 -0
- package/cjs/graphql/operations/GetLastCartQuery.js +26 -0
- package/cjs/graphql/operations/GetOrderQuery.js +30 -0
- package/cjs/graphql/operations/GetOrdersPageQuery.js +24 -0
- package/cjs/graphql/operations/GetPaymentMethodsPageDataQuery.js +18 -0
- package/cjs/graphql/operations/GetProductQuestionsPageQuery.js +10 -0
- package/cjs/graphql/operations/GetProductReviewImagesPageQuery.js +8 -0
- package/cjs/graphql/operations/GetProductReviewsPageQuery.js +20 -0
- package/cjs/graphql/operations/GetProvincesQuery.js +6 -0
- package/cjs/graphql/operations/GetQuestionQuery.js +8 -0
- package/cjs/graphql/operations/GetReturnCreationInfoQuery.js +36 -0
- package/cjs/graphql/operations/GetReturnQuery.js +28 -0
- package/cjs/graphql/operations/GetReturnsPageQuery.js +22 -0
- package/cjs/graphql/operations/GetReviewDimensionsQuery.js +6 -0
- package/cjs/graphql/operations/GetReviewQuery.js +18 -0
- package/cjs/graphql/operations/GetReviewSettingsQuery.js +12 -0
- package/cjs/graphql/operations/GetShopCurrenciesQuery.js +6 -0
- package/cjs/graphql/operations/GetShopQuery.js +8 -0
- package/cjs/graphql/operations/GetSubscriptionQuery.js +36 -0
- package/cjs/graphql/operations/GetSubscriptionsPageQuery.js +22 -0
- package/cjs/graphql/operations/GetVariantPageQuery.js +20 -0
- package/cjs/graphql/operations/LoadProductNoCustomerQuery.js +62 -0
- package/cjs/graphql/operations/LoadProductQuery.js +66 -0
- package/cjs/graphql/operations/ModifyCartMutation.js +26 -0
- package/cjs/graphql/operations/ModifyCustomerMutation.js +8 -0
- package/cjs/graphql/operations/ModifyFavoriteMutation.js +22 -0
- package/cjs/graphql/operations/ModifyProductQuestionAnswerMutation.js +3 -0
- package/cjs/graphql/operations/ModifyProductQuestionMutation.js +8 -0
- package/cjs/graphql/operations/ModifyProductReviewMutation.js +18 -0
- package/cjs/graphql/operations/NewPasswordMutation.js +3 -0
- package/cjs/graphql/operations/PauseSubscriptionMutation.js +3 -0
- package/cjs/graphql/operations/ResetPasswordMutation.js +3 -0
- package/cjs/graphql/operations/ResumeSubscriptionMutation.js +3 -0
- package/cjs/graphql/operations/SearchProductsAdvancedQuery.js +24 -0
- package/cjs/graphql/operations/SearchProductsQuery.js +20 -0
- package/cjs/graphql/operations/SearchQuestionsQuery.js +8 -0
- package/cjs/graphql/operations/SearchReviewsQuery.js +18 -0
- package/cjs/graphql/operations/SignInMutation.js +3 -0
- package/cjs/graphql/operations/SignInViaEmailCompleteMutation.js +3 -0
- package/cjs/graphql/operations/SignInViaEmailInitMutation.js +3 -0
- package/cjs/graphql/operations/SignUpMutation.js +3 -0
- package/cjs/graphql/operations/SkipNextSubscriptionMutation.js +3 -0
- package/cjs/graphql/operations/UploadFileMutation.js +3 -0
- package/cjs/graphql/operations/VerifyCodeMutation.js +3 -0
- package/cjs/graphql/operations/VoteQuestionAnswerMutation.js +3 -0
- package/cjs/graphql/operations/VoteQuestionMutation.js +3 -0
- package/cjs/graphql/operations/VoteReviewAnswerMutation.js +3 -0
- package/cjs/graphql/operations/VoteReviewMutation.js +3 -0
- package/cjs/graphql/types.js +2 -0
- package/cjs/hierarchicalSearchOption.js +42 -0
- package/cjs/idgen.js +8 -0
- package/cjs/ignoreQueue.js +50 -0
- package/cjs/imageAltProps.js +13 -0
- package/cjs/invoiceFormat.js +59 -0
- package/cjs/isShippingRequired.js +20 -0
- package/cjs/isoStripTrailingZeros.js +7 -0
- package/cjs/json/commerce.js +10 -0
- package/cjs/json/commerceFileUpload.js +57 -0
- package/cjs/json/commerceTypes.js +2 -0
- package/cjs/json/common.js +320 -0
- package/cjs/json/fetchAllItems.js +61 -0
- package/cjs/json/mutator.js +957 -0
- package/cjs/json/storefront.js +10 -0
- package/cjs/json/storefrontTypes.js +2 -0
- package/cjs/lastValue.js +17 -0
- package/cjs/lineItemPrice.js +111 -0
- package/cjs/loadJWT.js +25 -0
- package/cjs/mapInvalidInput.js +33 -0
- package/cjs/mapResponseData.js +16 -0
- package/cjs/mapResponseMultiData.js +14 -0
- package/cjs/meanBy.js +15 -0
- package/cjs/media.js +16 -0
- package/cjs/modules/advancedSearch.js +127 -0
- package/cjs/modules/cart.js +708 -0
- package/cjs/modules/config/defaultAdvancedSearchGraphQLConfig.js +8 -0
- package/cjs/modules/config/defaultCartGraphQLConfig.js +14 -0
- package/cjs/modules/config/defaultProductGraphQLConfig.js +48 -0
- package/cjs/modules/config/defaultSearchGraphQLConfig.js +8 -0
- package/cjs/modules/customer.js +2174 -0
- package/cjs/modules/helpers/cartInitOption.js +22 -0
- package/cjs/modules/helpers/cookieConsent.js +33 -0
- package/cjs/modules/helpers/customerOauth2.js +64 -0
- package/cjs/modules/helpers/getOAuth2Hook.js +52 -0
- package/cjs/modules/helpers/hookUpAnalytics.js +49 -0
- package/cjs/modules/helpers/loadJWT.js +23 -0
- package/cjs/modules/helpers/misc.js +58 -0
- package/cjs/modules/imageDialog.js +78 -0
- package/cjs/modules/persist.js +55 -0
- package/cjs/modules/popupMessage.js +21 -0
- package/cjs/modules/product.js +1261 -0
- package/cjs/modules/recentlyVisitedProducts.js +72 -0
- package/cjs/modules/search.js +102 -0
- package/cjs/multiResponseToResponse.js +22 -0
- package/cjs/nonNull.js +10 -0
- package/cjs/oauthState.js +40 -0
- package/cjs/orderShippingAddress.js +7 -0
- package/cjs/package.json +3 -0
- package/cjs/pender.js +16 -0
- package/cjs/percentageOff.js +7 -0
- package/cjs/popupConnectQueue.js +62 -0
- package/cjs/preact/components/SixDigitInput.js +167 -0
- package/cjs/preact/effector.js +74 -0
- package/cjs/preact/transition/CSSTransition.js +55 -0
- package/cjs/preact/transition/Transition.js +104 -0
- package/cjs/preact/translateLocalStatic.js +31 -0
- package/cjs/productFiltering.js +173 -0
- package/cjs/productSEO.js +51 -0
- package/cjs/productSorting.js +93 -0
- package/cjs/promiseAll.js +18 -0
- package/cjs/promiseLimit.js +38 -0
- package/cjs/rdsToInitialScores.js +32 -0
- package/cjs/react/components/Portal.js +7 -0
- package/cjs/react/components/RootCloseWrapper.js +41 -0
- package/cjs/react/components/SixDigitInput.js +167 -0
- package/cjs/react/contains.js +14 -0
- package/cjs/react/popperBinder.js +70 -0
- package/cjs/react/rootClose.js +112 -0
- package/cjs/react/translateLocalStatic.js +32 -0
- package/cjs/react/useAsyncCachedValue.js +14 -0
- package/cjs/refreshTimeout.js +25 -0
- package/cjs/remoteAuth.js +59 -0
- package/cjs/request.js +348 -0
- package/cjs/requestDetails.js +76 -0
- package/cjs/rfc3339Normalize.js +10 -0
- package/cjs/script.js +172 -0
- package/cjs/seo.js +2 -0
- package/cjs/shopDomain.js +8 -0
- package/cjs/shopLinks.js +63 -0
- package/cjs/slate.js +376 -0
- package/cjs/sleep.js +10 -0
- package/cjs/splitBy.js +21 -0
- package/cjs/splitName.js +28 -0
- package/cjs/stripZeros.js +13 -0
- package/cjs/stripeError.js +65 -0
- package/cjs/tailSplit.js +12 -0
- package/cjs/tieredPrice.js +32 -0
- package/cjs/timeIt.js +15 -0
- package/cjs/toMajor.js +8 -0
- package/cjs/toMinor.js +8 -0
- package/cjs/trace.js +37 -0
- package/cjs/translateLocale.js +12 -0
- package/cjs/traverse.js +14 -0
- package/cjs/truncate.js +21 -0
- package/cjs/typedLocalStorage.js +30 -0
- package/cjs/variantImage.js +26 -0
- package/cjs/variantImageURL.js +13 -0
- package/cjs/variantImages.js +19 -0
- package/cjs/variantInventory.js +43 -0
- package/cjs/variantOptions.js +21 -0
- package/cjs/variantPrice.js +96 -0
- package/cjs/variantPriceCommerce.js +29 -0
- package/cjs/variantTitle.js +9 -0
- package/cjs/variantTitleFull.js +11 -0
- package/cjs/variantURL.js +9 -0
- package/cjs/vendor/popper/index.d.ts +160 -0
- package/cjs/vendor/popper/index.js +2657 -0
- package/cjs/vendor/popper/index.js.map +1 -0
- package/cjs/vendor/popper/package.json +3 -0
- package/cjs/websocket.js +179 -0
- package/esm/actionLock.js +24 -0
- package/esm/addEmptyListItem.js +3 -0
- package/esm/aggregateOptions.js +169 -0
- package/esm/analytics.js +91 -0
- package/esm/analyticsProductData.js +28 -0
- package/esm/arrayToDict.js +8 -0
- package/esm/asyncModuleWrapper.js +47 -0
- package/esm/averageReviewScore.js +40 -0
- package/esm/buildconfig.js +13 -0
- package/esm/cachedLoader.js +32 -0
- package/esm/canonicalVariantURL.js +1 -0
- package/esm/cartOperation.js +126 -0
- package/esm/categorySEO.js +16 -0
- package/esm/commonTypes.js +1 -0
- package/esm/compact.js +4 -0
- package/esm/configLoader.js +61 -0
- package/esm/controlledQueue.js +38 -0
- package/esm/convertImageURL.js +15 -0
- package/esm/dataLoader.js +192 -0
- package/esm/defaultVariant.js +25 -0
- package/esm/effector/clearOnChangeAfterDelay.js +13 -0
- package/esm/effector/combineEvery.js +4 -0
- package/esm/effector/combineSome.js +4 -0
- package/esm/effector/debounced.js +14 -0
- package/esm/effector/form.js +166 -0
- package/esm/effector/hideOnChangeAfterDelay.js +13 -0
- package/esm/effector/requestResponse.js +24 -0
- package/esm/effector/requestResponseMulti.js +47 -0
- package/esm/effector/restoreNamed.js +4 -0
- package/esm/effector/split.js +25 -0
- package/esm/effector/validator.js +28 -0
- package/esm/effector/wrapSignInRequired.js +9 -0
- package/esm/exceptions.js +2 -0
- package/esm/fetchAllItems.js +44 -0
- package/esm/file.js +67 -0
- package/esm/fileWebsocket.js +75 -0
- package/esm/filterFunc.js +43 -0
- package/esm/filterFuncBrand.js +9 -0
- package/esm/filterFuncCategory.js +9 -0
- package/esm/filterFuncContentBlock.js +16 -0
- package/esm/filterFuncCustomer.js +153 -0
- package/esm/filterFuncDataFeed.js +50 -0
- package/esm/filterFuncOrder.js +325 -0
- package/esm/filterFuncPreprocess.js +9 -0
- package/esm/filterFuncProduct.js +66 -0
- package/esm/filterFuncPurchaseOrder.js +122 -0
- package/esm/filterFuncSupplier.js +31 -0
- package/esm/filterFuncTransfer.js +130 -0
- package/esm/formatAbbrevNumber.js +16 -0
- package/esm/formatCurrency.js +42 -0
- package/esm/formatToJSX.js +118 -0
- package/esm/fulfillmentNumber.js +3 -0
- package/esm/generateRandomToken.js +8 -0
- package/esm/generateUUID.js +6 -0
- package/esm/generated/codes.js +44 -0
- package/esm/genericFile.js +65 -0
- package/esm/getSalesChannelID.js +9 -0
- package/esm/getSessionID.js +9 -0
- package/esm/getTimezone.js +8 -0
- package/esm/graphql/fragments/Branding.js +1 -0
- package/esm/graphql/fragments/BrandingField.js +1 -0
- package/esm/graphql/fragments/CartCustomItem.js +1 -0
- package/esm/graphql/fragments/CartOrder.js +1 -0
- package/esm/graphql/fragments/CartVariant.js +1 -0
- package/esm/graphql/fragments/CartVariantFull.js +1 -0
- package/esm/graphql/fragments/Category.js +1 -0
- package/esm/graphql/fragments/CommonCartVariant.js +1 -0
- package/esm/graphql/fragments/Currency.js +1 -0
- package/esm/graphql/fragments/CurrencyPrice.js +1 -0
- package/esm/graphql/fragments/CustomField.js +1 -0
- package/esm/graphql/fragments/CustomFieldObjects.js +1 -0
- package/esm/graphql/fragments/Customer.js +1 -0
- package/esm/graphql/fragments/CustomerBalance.js +1 -0
- package/esm/graphql/fragments/CustomerBalanceHistory.js +1 -0
- package/esm/graphql/fragments/CustomerFavorite.js +1 -0
- package/esm/graphql/fragments/CustomerFavoriteShort.js +1 -0
- package/esm/graphql/fragments/CustomerOAuthProvider.js +1 -0
- package/esm/graphql/fragments/CustomerOrderBrief.js +1 -0
- package/esm/graphql/fragments/CustomerOrderFulfillment.js +1 -0
- package/esm/graphql/fragments/CustomerOrderFull.js +1 -0
- package/esm/graphql/fragments/CustomerPaymentSource.js +1 -0
- package/esm/graphql/fragments/CustomerReturnBrief.js +1 -0
- package/esm/graphql/fragments/CustomerReturnFull.js +1 -0
- package/esm/graphql/fragments/CustomerReturnPolicy.js +1 -0
- package/esm/graphql/fragments/CustomerSubscriptionBrief.js +1 -0
- package/esm/graphql/fragments/CustomerSubscriptionFull.js +1 -0
- package/esm/graphql/fragments/File.js +1 -0
- package/esm/graphql/fragments/FileForUpload.js +1 -0
- package/esm/graphql/fragments/FileNoFallback.js +1 -0
- package/esm/graphql/fragments/FullAddress.js +1 -0
- package/esm/graphql/fragments/Gateway.js +1 -0
- package/esm/graphql/fragments/GatewayManual.js +1 -0
- package/esm/graphql/fragments/GatewayPaypal.js +1 -0
- package/esm/graphql/fragments/GatewayStripe.js +1 -0
- package/esm/graphql/fragments/GatewayTest.js +1 -0
- package/esm/graphql/fragments/IPAndUAInfo.js +1 -0
- package/esm/graphql/fragments/InfoCountry.js +1 -0
- package/esm/graphql/fragments/InfoCountryDedupField.js +1 -0
- package/esm/graphql/fragments/InfoCurrency.js +1 -0
- package/esm/graphql/fragments/InfoProvince.js +1 -0
- package/esm/graphql/fragments/KeyValue.js +1 -0
- package/esm/graphql/fragments/LineItemField.js +1 -0
- package/esm/graphql/fragments/MediaFile.js +1 -0
- package/esm/graphql/fragments/MinCurrencyPrice.js +1 -0
- package/esm/graphql/fragments/ProductField.js +1 -0
- package/esm/graphql/fragments/ProductFieldSet.js +1 -0
- package/esm/graphql/fragments/ProductFlat.js +1 -0
- package/esm/graphql/fragments/ProductQuestion.js +1 -0
- package/esm/graphql/fragments/ProductQuestionAnswer.js +1 -0
- package/esm/graphql/fragments/ProductQuestionPage.js +1 -0
- package/esm/graphql/fragments/ProductReview.js +1 -0
- package/esm/graphql/fragments/ProductReviewAnswer.js +1 -0
- package/esm/graphql/fragments/ProductReviewAverageScore.js +1 -0
- package/esm/graphql/fragments/ProductReviewPage.js +1 -0
- package/esm/graphql/fragments/ProductReviewScore.js +1 -0
- package/esm/graphql/fragments/ProductReviewSurveyAnswer.js +1 -0
- package/esm/graphql/fragments/ProductSearchOptionAgg.js +1 -0
- package/esm/graphql/fragments/ProductSearchResult.js +1 -0
- package/esm/graphql/fragments/ReturnReason.js +1 -0
- package/esm/graphql/fragments/ReviewDimension.js +1 -0
- package/esm/graphql/fragments/ReviewDimensionSet.js +1 -0
- package/esm/graphql/fragments/ReviewImagePage.js +1 -0
- package/esm/graphql/fragments/ReviewQuestionProduct.js +1 -0
- package/esm/graphql/fragments/ReviewSettings.js +1 -0
- package/esm/graphql/fragments/SearchProduct.js +1 -0
- package/esm/graphql/fragments/Shop.js +1 -0
- package/esm/graphql/fragments/SubscriptionPlan.js +1 -0
- package/esm/graphql/fragments/SurveyQuestion.js +1 -0
- package/esm/graphql/fragments/TieredPricing.js +1 -0
- package/esm/graphql/fragments/TieredPricingTier.js +1 -0
- package/esm/graphql/fragments/VariantOption.js +1 -0
- package/esm/graphql/operations/ApplyGiftCardMutation.js +1 -0
- package/esm/graphql/operations/AuthRequestMutation.js +1 -0
- package/esm/graphql/operations/CancelOrderMutation.js +1 -0
- package/esm/graphql/operations/CancelSubscriptionMutation.js +1 -0
- package/esm/graphql/operations/ConnectOAuth2Mutation.js +1 -0
- package/esm/graphql/operations/CreateCartMutation.js +23 -0
- package/esm/graphql/operations/CreateFavoriteMutation.js +19 -0
- package/esm/graphql/operations/CreateFileMutation.js +3 -0
- package/esm/graphql/operations/CreatePaymentSourceMutation.js +3 -0
- package/esm/graphql/operations/CreateProductQuestionAnswerMutation.js +1 -0
- package/esm/graphql/operations/CreateProductQuestionMutation.js +5 -0
- package/esm/graphql/operations/CreateProductReviewMutation.js +15 -0
- package/esm/graphql/operations/CreateReturnMutation.js +19 -0
- package/esm/graphql/operations/DeleteFavoriteMutation.js +1 -0
- package/esm/graphql/operations/DeletePaymentSourceMutation.js +1 -0
- package/esm/graphql/operations/DeleteProductQuestionAnswerMutation.js +1 -0
- package/esm/graphql/operations/DeleteProductQuestionMutation.js +1 -0
- package/esm/graphql/operations/DeleteProductReviewMutation.js +1 -0
- package/esm/graphql/operations/DisconnectOAuth2Mutation.js +1 -0
- package/esm/graphql/operations/EditSubscriptionMutation.js +1 -0
- package/esm/graphql/operations/FileUploadedMutation.js +3 -0
- package/esm/graphql/operations/FlagQuestionAnswerMutation.js +1 -0
- package/esm/graphql/operations/FlagQuestionMutation.js +1 -0
- package/esm/graphql/operations/FlagReviewAnswerMutation.js +1 -0
- package/esm/graphql/operations/FlagReviewMutation.js +1 -0
- package/esm/graphql/operations/GetBrandingQuery.js +7 -0
- package/esm/graphql/operations/GetCartQuery.js +23 -0
- package/esm/graphql/operations/GetCustomerAddressesPageDataQuery.js +13 -0
- package/esm/graphql/operations/GetCustomerBalanceHistoryPageQuery.js +3 -0
- package/esm/graphql/operations/GetCustomerBalanceQuery.js +5 -0
- package/esm/graphql/operations/GetCustomerInfoQuery.js +7 -0
- package/esm/graphql/operations/GetCustomerQuery.js +5 -0
- package/esm/graphql/operations/GetFavoritesQuery.js +19 -0
- package/esm/graphql/operations/GetFileStatusQuery.js +3 -0
- package/esm/graphql/operations/GetGatewaysQuery.js +11 -0
- package/esm/graphql/operations/GetInfoCurrenciesQuery.js +3 -0
- package/esm/graphql/operations/GetLastCartQuery.js +23 -0
- package/esm/graphql/operations/GetOrderQuery.js +27 -0
- package/esm/graphql/operations/GetOrdersPageQuery.js +21 -0
- package/esm/graphql/operations/GetPaymentMethodsPageDataQuery.js +15 -0
- package/esm/graphql/operations/GetProductQuestionsPageQuery.js +7 -0
- package/esm/graphql/operations/GetProductReviewImagesPageQuery.js +5 -0
- package/esm/graphql/operations/GetProductReviewsPageQuery.js +17 -0
- package/esm/graphql/operations/GetProvincesQuery.js +3 -0
- package/esm/graphql/operations/GetQuestionQuery.js +5 -0
- package/esm/graphql/operations/GetReturnCreationInfoQuery.js +33 -0
- package/esm/graphql/operations/GetReturnQuery.js +25 -0
- package/esm/graphql/operations/GetReturnsPageQuery.js +19 -0
- package/esm/graphql/operations/GetReviewDimensionsQuery.js +3 -0
- package/esm/graphql/operations/GetReviewQuery.js +15 -0
- package/esm/graphql/operations/GetReviewSettingsQuery.js +9 -0
- package/esm/graphql/operations/GetShopCurrenciesQuery.js +3 -0
- package/esm/graphql/operations/GetShopQuery.js +5 -0
- package/esm/graphql/operations/GetSubscriptionQuery.js +33 -0
- package/esm/graphql/operations/GetSubscriptionsPageQuery.js +19 -0
- package/esm/graphql/operations/GetVariantPageQuery.js +17 -0
- package/esm/graphql/operations/LoadProductNoCustomerQuery.js +59 -0
- package/esm/graphql/operations/LoadProductQuery.js +63 -0
- package/esm/graphql/operations/ModifyCartMutation.js +23 -0
- package/esm/graphql/operations/ModifyCustomerMutation.js +5 -0
- package/esm/graphql/operations/ModifyFavoriteMutation.js +19 -0
- package/esm/graphql/operations/ModifyProductQuestionAnswerMutation.js +1 -0
- package/esm/graphql/operations/ModifyProductQuestionMutation.js +5 -0
- package/esm/graphql/operations/ModifyProductReviewMutation.js +15 -0
- package/esm/graphql/operations/NewPasswordMutation.js +1 -0
- package/esm/graphql/operations/PauseSubscriptionMutation.js +1 -0
- package/esm/graphql/operations/ResetPasswordMutation.js +1 -0
- package/esm/graphql/operations/ResumeSubscriptionMutation.js +1 -0
- package/esm/graphql/operations/SearchProductsAdvancedQuery.js +21 -0
- package/esm/graphql/operations/SearchProductsQuery.js +17 -0
- package/esm/graphql/operations/SearchQuestionsQuery.js +5 -0
- package/esm/graphql/operations/SearchReviewsQuery.js +15 -0
- package/esm/graphql/operations/SignInMutation.js +1 -0
- package/esm/graphql/operations/SignInViaEmailCompleteMutation.js +1 -0
- package/esm/graphql/operations/SignInViaEmailInitMutation.js +1 -0
- package/esm/graphql/operations/SignUpMutation.js +1 -0
- package/esm/graphql/operations/SkipNextSubscriptionMutation.js +1 -0
- package/esm/graphql/operations/UploadFileMutation.js +1 -0
- package/esm/graphql/operations/VerifyCodeMutation.js +1 -0
- package/esm/graphql/operations/VoteQuestionAnswerMutation.js +1 -0
- package/esm/graphql/operations/VoteQuestionMutation.js +1 -0
- package/esm/graphql/operations/VoteReviewAnswerMutation.js +1 -0
- package/esm/graphql/operations/VoteReviewMutation.js +1 -0
- package/esm/graphql/types.js +1 -0
- package/esm/hierarchicalSearchOption.js +43 -0
- package/esm/idgen.js +4 -0
- package/esm/ignoreQueue.js +45 -0
- package/esm/imageAltProps.js +9 -0
- package/esm/invoiceFormat.js +54 -0
- package/esm/isShippingRequired.js +16 -0
- package/esm/isoStripTrailingZeros.js +3 -0
- package/esm/json/commerce.js +3 -0
- package/esm/json/commerceFileUpload.js +43 -0
- package/esm/json/commerceTypes.js +1 -0
- package/esm/json/common.js +309 -0
- package/esm/json/fetchAllItems.js +51 -0
- package/esm/json/mutator.js +952 -0
- package/esm/json/storefront.js +3 -0
- package/esm/json/storefrontTypes.js +1 -0
- package/esm/lastValue.js +12 -0
- package/esm/lineItemPrice.js +106 -0
- package/esm/loadJWT.js +20 -0
- package/esm/mapInvalidInput.js +27 -0
- package/esm/mapResponseData.js +11 -0
- package/esm/mapResponseMultiData.js +10 -0
- package/esm/meanBy.js +11 -0
- package/esm/media.js +12 -0
- package/esm/modules/advancedSearch.js +132 -0
- package/esm/modules/cart.js +699 -0
- package/esm/modules/config/defaultAdvancedSearchGraphQLConfig.js +4 -0
- package/esm/modules/config/defaultCartGraphQLConfig.js +10 -0
- package/esm/modules/config/defaultProductGraphQLConfig.js +44 -0
- package/esm/modules/config/defaultSearchGraphQLConfig.js +4 -0
- package/esm/modules/customer.js +2198 -0
- package/esm/modules/helpers/cartInitOption.js +18 -0
- package/esm/modules/helpers/cookieConsent.js +29 -0
- package/esm/modules/helpers/customerOauth2.js +53 -0
- package/esm/modules/helpers/getOAuth2Hook.js +48 -0
- package/esm/modules/helpers/hookUpAnalytics.js +44 -0
- package/esm/modules/helpers/loadJWT.js +18 -0
- package/esm/modules/helpers/misc.js +49 -0
- package/esm/modules/imageDialog.js +71 -0
- package/esm/modules/persist.js +49 -0
- package/esm/modules/popupMessage.js +17 -0
- package/esm/modules/product.js +1278 -0
- package/esm/modules/recentlyVisitedProducts.js +70 -0
- package/esm/modules/search.js +103 -0
- package/esm/multiResponseToResponse.js +18 -0
- package/esm/nonNull.js +6 -0
- package/esm/oauthState.js +35 -0
- package/esm/orderShippingAddress.js +3 -0
- package/esm/package.json +3 -0
- package/esm/pender.js +11 -0
- package/esm/percentageOff.js +3 -0
- package/esm/popupConnectQueue.js +55 -0
- package/esm/preact/components/SixDigitInput.js +159 -0
- package/esm/preact/effector.js +69 -0
- package/esm/preact/transition/CSSTransition.js +47 -0
- package/esm/preact/transition/Transition.js +100 -0
- package/esm/preact/translateLocalStatic.js +26 -0
- package/esm/productFiltering.js +164 -0
- package/esm/productSEO.js +46 -0
- package/esm/productSorting.js +89 -0
- package/esm/promiseAll.js +11 -0
- package/esm/promiseLimit.js +32 -0
- package/esm/rdsToInitialScores.js +27 -0
- package/esm/react/components/Portal.js +2 -0
- package/esm/react/components/RootCloseWrapper.js +33 -0
- package/esm/react/components/SixDigitInput.js +158 -0
- package/esm/react/contains.js +10 -0
- package/esm/react/popperBinder.js +71 -0
- package/esm/react/rootClose.js +106 -0
- package/esm/react/translateLocalStatic.js +26 -0
- package/esm/react/useAsyncCachedValue.js +10 -0
- package/esm/refreshTimeout.js +21 -0
- package/esm/remoteAuth.js +52 -0
- package/esm/request.js +323 -0
- package/esm/requestDetails.js +69 -0
- package/esm/rfc3339Normalize.js +6 -0
- package/esm/script.js +157 -0
- package/esm/seo.js +1 -0
- package/esm/shopDomain.js +4 -0
- package/esm/shopLinks.js +47 -0
- package/esm/slate.js +364 -0
- package/esm/sleep.js +3 -0
- package/esm/splitBy.js +17 -0
- package/esm/splitName.js +22 -0
- package/esm/stripZeros.js +9 -0
- package/esm/stripeError.js +53 -0
- package/esm/tailSplit.js +8 -0
- package/esm/tieredPrice.js +28 -0
- package/esm/timeIt.js +8 -0
- package/esm/toMajor.js +4 -0
- package/esm/toMinor.js +4 -0
- package/esm/trace.js +37 -0
- package/esm/translateLocale.js +7 -0
- package/esm/traverse.js +10 -0
- package/esm/truncate.js +17 -0
- package/esm/typedLocalStorage.js +24 -0
- package/esm/variantImage.js +22 -0
- package/esm/variantImageURL.js +9 -0
- package/esm/variantImages.js +15 -0
- package/esm/variantInventory.js +38 -0
- package/esm/variantOptions.js +15 -0
- package/esm/variantPrice.js +92 -0
- package/esm/variantPriceCommerce.js +25 -0
- package/esm/variantTitle.js +5 -0
- package/esm/variantTitleFull.js +7 -0
- package/esm/variantURL.js +5 -0
- package/esm/vendor/popper/index.d.ts +160 -0
- package/esm/vendor/popper/index.js +2657 -0
- package/esm/vendor/popper/index.js.map +1 -0
- package/esm/vendor/popper/package.json +3 -0
- package/esm/websocket.js +169 -0
- package/package.json +92 -0
- package/types/actionLock.d.ts +7 -0
- package/types/addEmptyListItem.d.ts +2 -0
- package/types/aggregateOptions.d.ts +33 -0
- package/types/analytics.d.ts +23 -0
- package/types/analyticsProductData.d.ts +38 -0
- package/types/arrayToDict.d.ts +2 -0
- package/types/asyncModuleWrapper.d.ts +13 -0
- package/types/averageReviewScore.d.ts +28 -0
- package/types/buildconfig.d.ts +13 -0
- package/types/cachedLoader.d.ts +10 -0
- package/types/canonicalVariantURL.d.ts +12 -0
- package/types/cartOperation.d.ts +28 -0
- package/types/categorySEO.d.ts +17 -0
- package/types/commonTypes.d.ts +10 -0
- package/types/compact.d.ts +1 -0
- package/types/configLoader.d.ts +53 -0
- package/types/controlledQueue.d.ts +17 -0
- package/types/convertImageURL.d.ts +9 -0
- package/types/dataLoader.d.ts +301 -0
- package/types/defaultVariant.d.ts +9 -0
- package/types/effector/clearOnChangeAfterDelay.d.ts +2 -0
- package/types/effector/combineEvery.d.ts +2 -0
- package/types/effector/combineSome.d.ts +2 -0
- package/types/effector/debounced.d.ts +2 -0
- package/types/effector/form.d.ts +74 -0
- package/types/effector/hideOnChangeAfterDelay.d.ts +6 -0
- package/types/effector/requestResponse.d.ts +9 -0
- package/types/effector/requestResponseMulti.d.ts +7 -0
- package/types/effector/restoreNamed.d.ts +2 -0
- package/types/effector/split.d.ts +7 -0
- package/types/effector/validator.d.ts +14 -0
- package/types/effector/wrapSignInRequired.d.ts +2 -0
- package/types/exceptions.d.ts +2 -0
- package/types/fetchAllItems.d.ts +25 -0
- package/types/file.d.ts +4 -0
- package/types/fileWebsocket.d.ts +6 -0
- package/types/filterFunc.d.ts +8 -0
- package/types/filterFuncBrand.d.ts +3 -0
- package/types/filterFuncCategory.d.ts +3 -0
- package/types/filterFuncContentBlock.d.ts +3 -0
- package/types/filterFuncCustomer.d.ts +3 -0
- package/types/filterFuncDataFeed.d.ts +8 -0
- package/types/filterFuncOrder.d.ts +3 -0
- package/types/filterFuncPreprocess.d.ts +2 -0
- package/types/filterFuncProduct.d.ts +3 -0
- package/types/filterFuncPurchaseOrder.d.ts +3 -0
- package/types/filterFuncSupplier.d.ts +3 -0
- package/types/filterFuncTransfer.d.ts +3 -0
- package/types/formatAbbrevNumber.d.ts +6 -0
- package/types/formatCurrency.d.ts +44 -0
- package/types/formatToJSX.d.ts +24 -0
- package/types/fulfillmentNumber.d.ts +1 -0
- package/types/generateRandomToken.d.ts +1 -0
- package/types/generateUUID.d.ts +1 -0
- package/types/generated/codes.d.ts +234 -0
- package/types/genericFile.d.ts +57 -0
- package/types/getSalesChannelID.d.ts +1 -0
- package/types/getSessionID.d.ts +1 -0
- package/types/getTimezone.d.ts +1 -0
- package/types/graphql/fragments/Branding.d.ts +2 -0
- package/types/graphql/fragments/BrandingField.d.ts +2 -0
- package/types/graphql/fragments/CartCustomItem.d.ts +2 -0
- package/types/graphql/fragments/CartOrder.d.ts +2 -0
- package/types/graphql/fragments/CartVariant.d.ts +2 -0
- package/types/graphql/fragments/CartVariantFull.d.ts +2 -0
- package/types/graphql/fragments/Category.d.ts +2 -0
- package/types/graphql/fragments/CommonCartVariant.d.ts +2 -0
- package/types/graphql/fragments/Currency.d.ts +2 -0
- package/types/graphql/fragments/CurrencyPrice.d.ts +2 -0
- package/types/graphql/fragments/CustomField.d.ts +2 -0
- package/types/graphql/fragments/CustomFieldObjects.d.ts +2 -0
- package/types/graphql/fragments/Customer.d.ts +2 -0
- package/types/graphql/fragments/CustomerBalance.d.ts +2 -0
- package/types/graphql/fragments/CustomerBalanceHistory.d.ts +2 -0
- package/types/graphql/fragments/CustomerFavorite.d.ts +2 -0
- package/types/graphql/fragments/CustomerFavoriteShort.d.ts +2 -0
- package/types/graphql/fragments/CustomerOAuthProvider.d.ts +2 -0
- package/types/graphql/fragments/CustomerOrderBrief.d.ts +2 -0
- package/types/graphql/fragments/CustomerOrderFulfillment.d.ts +2 -0
- package/types/graphql/fragments/CustomerOrderFull.d.ts +2 -0
- package/types/graphql/fragments/CustomerPaymentSource.d.ts +2 -0
- package/types/graphql/fragments/CustomerReturnBrief.d.ts +2 -0
- package/types/graphql/fragments/CustomerReturnFull.d.ts +2 -0
- package/types/graphql/fragments/CustomerReturnPolicy.d.ts +2 -0
- package/types/graphql/fragments/CustomerSubscriptionBrief.d.ts +2 -0
- package/types/graphql/fragments/CustomerSubscriptionFull.d.ts +2 -0
- package/types/graphql/fragments/File.d.ts +2 -0
- package/types/graphql/fragments/FileForUpload.d.ts +2 -0
- package/types/graphql/fragments/FileNoFallback.d.ts +2 -0
- package/types/graphql/fragments/FullAddress.d.ts +2 -0
- package/types/graphql/fragments/Gateway.d.ts +2 -0
- package/types/graphql/fragments/GatewayManual.d.ts +2 -0
- package/types/graphql/fragments/GatewayPaypal.d.ts +2 -0
- package/types/graphql/fragments/GatewayStripe.d.ts +2 -0
- package/types/graphql/fragments/GatewayTest.d.ts +2 -0
- package/types/graphql/fragments/IPAndUAInfo.d.ts +2 -0
- package/types/graphql/fragments/InfoCountry.d.ts +2 -0
- package/types/graphql/fragments/InfoCountryDedupField.d.ts +2 -0
- package/types/graphql/fragments/InfoCurrency.d.ts +2 -0
- package/types/graphql/fragments/InfoProvince.d.ts +2 -0
- package/types/graphql/fragments/KeyValue.d.ts +2 -0
- package/types/graphql/fragments/LineItemField.d.ts +2 -0
- package/types/graphql/fragments/MediaFile.d.ts +2 -0
- package/types/graphql/fragments/MinCurrencyPrice.d.ts +2 -0
- package/types/graphql/fragments/ProductField.d.ts +2 -0
- package/types/graphql/fragments/ProductFieldSet.d.ts +2 -0
- package/types/graphql/fragments/ProductFlat.d.ts +2 -0
- package/types/graphql/fragments/ProductQuestion.d.ts +2 -0
- package/types/graphql/fragments/ProductQuestionAnswer.d.ts +2 -0
- package/types/graphql/fragments/ProductQuestionPage.d.ts +2 -0
- package/types/graphql/fragments/ProductReview.d.ts +2 -0
- package/types/graphql/fragments/ProductReviewAnswer.d.ts +2 -0
- package/types/graphql/fragments/ProductReviewAverageScore.d.ts +2 -0
- package/types/graphql/fragments/ProductReviewPage.d.ts +2 -0
- package/types/graphql/fragments/ProductReviewScore.d.ts +2 -0
- package/types/graphql/fragments/ProductReviewSurveyAnswer.d.ts +2 -0
- package/types/graphql/fragments/ProductSearchOptionAgg.d.ts +2 -0
- package/types/graphql/fragments/ProductSearchResult.d.ts +2 -0
- package/types/graphql/fragments/ReturnReason.d.ts +2 -0
- package/types/graphql/fragments/ReviewDimension.d.ts +2 -0
- package/types/graphql/fragments/ReviewDimensionSet.d.ts +2 -0
- package/types/graphql/fragments/ReviewImagePage.d.ts +2 -0
- package/types/graphql/fragments/ReviewQuestionProduct.d.ts +2 -0
- package/types/graphql/fragments/ReviewSettings.d.ts +2 -0
- package/types/graphql/fragments/SearchProduct.d.ts +2 -0
- package/types/graphql/fragments/Shop.d.ts +2 -0
- package/types/graphql/fragments/SubscriptionPlan.d.ts +2 -0
- package/types/graphql/fragments/SurveyQuestion.d.ts +2 -0
- package/types/graphql/fragments/TieredPricing.d.ts +2 -0
- package/types/graphql/fragments/TieredPricingTier.d.ts +2 -0
- package/types/graphql/fragments/VariantOption.d.ts +2 -0
- package/types/graphql/operations/ApplyGiftCardMutation.d.ts +3 -0
- package/types/graphql/operations/AuthRequestMutation.d.ts +3 -0
- package/types/graphql/operations/CancelOrderMutation.d.ts +3 -0
- package/types/graphql/operations/CancelSubscriptionMutation.d.ts +3 -0
- package/types/graphql/operations/ConnectOAuth2Mutation.d.ts +3 -0
- package/types/graphql/operations/CreateCartMutation.d.ts +3 -0
- package/types/graphql/operations/CreateFavoriteMutation.d.ts +3 -0
- package/types/graphql/operations/CreateFileMutation.d.ts +3 -0
- package/types/graphql/operations/CreatePaymentSourceMutation.d.ts +3 -0
- package/types/graphql/operations/CreateProductQuestionAnswerMutation.d.ts +3 -0
- package/types/graphql/operations/CreateProductQuestionMutation.d.ts +3 -0
- package/types/graphql/operations/CreateProductReviewMutation.d.ts +3 -0
- package/types/graphql/operations/CreateReturnMutation.d.ts +3 -0
- package/types/graphql/operations/DeleteFavoriteMutation.d.ts +3 -0
- package/types/graphql/operations/DeletePaymentSourceMutation.d.ts +3 -0
- package/types/graphql/operations/DeleteProductQuestionAnswerMutation.d.ts +3 -0
- package/types/graphql/operations/DeleteProductQuestionMutation.d.ts +3 -0
- package/types/graphql/operations/DeleteProductReviewMutation.d.ts +3 -0
- package/types/graphql/operations/DisconnectOAuth2Mutation.d.ts +3 -0
- package/types/graphql/operations/EditSubscriptionMutation.d.ts +3 -0
- package/types/graphql/operations/FileUploadedMutation.d.ts +3 -0
- package/types/graphql/operations/FlagQuestionAnswerMutation.d.ts +3 -0
- package/types/graphql/operations/FlagQuestionMutation.d.ts +3 -0
- package/types/graphql/operations/FlagReviewAnswerMutation.d.ts +3 -0
- package/types/graphql/operations/FlagReviewMutation.d.ts +3 -0
- package/types/graphql/operations/GetBrandingQuery.d.ts +3 -0
- package/types/graphql/operations/GetCartQuery.d.ts +3 -0
- package/types/graphql/operations/GetCustomerAddressesPageDataQuery.d.ts +3 -0
- package/types/graphql/operations/GetCustomerBalanceHistoryPageQuery.d.ts +3 -0
- package/types/graphql/operations/GetCustomerBalanceQuery.d.ts +3 -0
- package/types/graphql/operations/GetCustomerInfoQuery.d.ts +3 -0
- package/types/graphql/operations/GetCustomerQuery.d.ts +3 -0
- package/types/graphql/operations/GetFavoritesQuery.d.ts +3 -0
- package/types/graphql/operations/GetFileStatusQuery.d.ts +3 -0
- package/types/graphql/operations/GetGatewaysQuery.d.ts +3 -0
- package/types/graphql/operations/GetInfoCurrenciesQuery.d.ts +3 -0
- package/types/graphql/operations/GetLastCartQuery.d.ts +3 -0
- package/types/graphql/operations/GetOrderQuery.d.ts +3 -0
- package/types/graphql/operations/GetOrdersPageQuery.d.ts +3 -0
- package/types/graphql/operations/GetPaymentMethodsPageDataQuery.d.ts +3 -0
- package/types/graphql/operations/GetProductQuestionsPageQuery.d.ts +3 -0
- package/types/graphql/operations/GetProductReviewImagesPageQuery.d.ts +3 -0
- package/types/graphql/operations/GetProductReviewsPageQuery.d.ts +3 -0
- package/types/graphql/operations/GetProvincesQuery.d.ts +3 -0
- package/types/graphql/operations/GetQuestionQuery.d.ts +3 -0
- package/types/graphql/operations/GetReturnCreationInfoQuery.d.ts +3 -0
- package/types/graphql/operations/GetReturnQuery.d.ts +3 -0
- package/types/graphql/operations/GetReturnsPageQuery.d.ts +3 -0
- package/types/graphql/operations/GetReviewDimensionsQuery.d.ts +3 -0
- package/types/graphql/operations/GetReviewQuery.d.ts +3 -0
- package/types/graphql/operations/GetReviewSettingsQuery.d.ts +3 -0
- package/types/graphql/operations/GetShopCurrenciesQuery.d.ts +3 -0
- package/types/graphql/operations/GetShopQuery.d.ts +3 -0
- package/types/graphql/operations/GetSubscriptionQuery.d.ts +3 -0
- package/types/graphql/operations/GetSubscriptionsPageQuery.d.ts +3 -0
- package/types/graphql/operations/GetVariantPageQuery.d.ts +3 -0
- package/types/graphql/operations/LoadProductNoCustomerQuery.d.ts +3 -0
- package/types/graphql/operations/LoadProductQuery.d.ts +3 -0
- package/types/graphql/operations/ModifyCartMutation.d.ts +3 -0
- package/types/graphql/operations/ModifyCustomerMutation.d.ts +3 -0
- package/types/graphql/operations/ModifyFavoriteMutation.d.ts +3 -0
- package/types/graphql/operations/ModifyProductQuestionAnswerMutation.d.ts +3 -0
- package/types/graphql/operations/ModifyProductQuestionMutation.d.ts +3 -0
- package/types/graphql/operations/ModifyProductReviewMutation.d.ts +3 -0
- package/types/graphql/operations/NewPasswordMutation.d.ts +3 -0
- package/types/graphql/operations/PauseSubscriptionMutation.d.ts +3 -0
- package/types/graphql/operations/ResetPasswordMutation.d.ts +3 -0
- package/types/graphql/operations/ResumeSubscriptionMutation.d.ts +3 -0
- package/types/graphql/operations/SearchProductsAdvancedQuery.d.ts +3 -0
- package/types/graphql/operations/SearchProductsQuery.d.ts +3 -0
- package/types/graphql/operations/SearchQuestionsQuery.d.ts +3 -0
- package/types/graphql/operations/SearchReviewsQuery.d.ts +3 -0
- package/types/graphql/operations/SignInMutation.d.ts +3 -0
- package/types/graphql/operations/SignInViaEmailCompleteMutation.d.ts +3 -0
- package/types/graphql/operations/SignInViaEmailInitMutation.d.ts +3 -0
- package/types/graphql/operations/SignUpMutation.d.ts +3 -0
- package/types/graphql/operations/SkipNextSubscriptionMutation.d.ts +3 -0
- package/types/graphql/operations/UploadFileMutation.d.ts +3 -0
- package/types/graphql/operations/VerifyCodeMutation.d.ts +3 -0
- package/types/graphql/operations/VoteQuestionAnswerMutation.d.ts +3 -0
- package/types/graphql/operations/VoteQuestionMutation.d.ts +3 -0
- package/types/graphql/operations/VoteReviewAnswerMutation.d.ts +3 -0
- package/types/graphql/operations/VoteReviewMutation.d.ts +3 -0
- package/types/graphql/types.d.ts +2471 -0
- package/types/hierarchicalSearchOption.d.ts +14 -0
- package/types/idgen.d.ts +1 -0
- package/types/ignoreQueue.d.ts +10 -0
- package/types/imageAltProps.d.ts +11 -0
- package/types/invoiceFormat.d.ts +32 -0
- package/types/isShippingRequired.d.ts +14 -0
- package/types/isoStripTrailingZeros.d.ts +1 -0
- package/types/json/commerce.d.ts +3 -0
- package/types/json/commerceFileUpload.d.ts +20 -0
- package/types/json/commerceTypes.d.ts +15422 -0
- package/types/json/common.d.ts +81 -0
- package/types/json/fetchAllItems.d.ts +15 -0
- package/types/json/mutator.d.ts +238 -0
- package/types/json/storefront.d.ts +3 -0
- package/types/json/storefrontTypes.d.ts +5059 -0
- package/types/lastValue.d.ts +10 -0
- package/types/lineItemPrice.d.ts +18 -0
- package/types/loadJWT.d.ts +1 -0
- package/types/mapInvalidInput.d.ts +15 -0
- package/types/mapResponseData.d.ts +3 -0
- package/types/mapResponseMultiData.d.ts +2 -0
- package/types/meanBy.d.ts +1 -0
- package/types/media.d.ts +3 -0
- package/types/modules/advancedSearch.d.ts +78 -0
- package/types/modules/cart.d.ts +263 -0
- package/types/modules/config/defaultAdvancedSearchGraphQLConfig.d.ts +3 -0
- package/types/modules/config/defaultCartGraphQLConfig.d.ts +6 -0
- package/types/modules/config/defaultProductGraphQLConfig.d.ts +23 -0
- package/types/modules/config/defaultSearchGraphQLConfig.d.ts +3 -0
- package/types/modules/customer.d.ts +624 -0
- package/types/modules/helpers/cartInitOption.d.ts +2 -0
- package/types/modules/helpers/cookieConsent.d.ts +4 -0
- package/types/modules/helpers/customerOauth2.d.ts +19 -0
- package/types/modules/helpers/getOAuth2Hook.d.ts +22 -0
- package/types/modules/helpers/hookUpAnalytics.d.ts +21 -0
- package/types/modules/helpers/loadJWT.d.ts +1 -0
- package/types/modules/helpers/misc.d.ts +14 -0
- package/types/modules/imageDialog.d.ts +31 -0
- package/types/modules/persist.d.ts +13 -0
- package/types/modules/popupMessage.d.ts +9 -0
- package/types/modules/product.d.ts +320 -0
- package/types/modules/recentlyVisitedProducts.d.ts +25 -0
- package/types/modules/search.d.ts +54 -0
- package/types/multiResponseToResponse.d.ts +2 -0
- package/types/nonNull.d.ts +1 -0
- package/types/oauthState.d.ts +3 -0
- package/types/orderShippingAddress.d.ts +6 -0
- package/types/pender.d.ts +5 -0
- package/types/percentageOff.d.ts +1 -0
- package/types/popupConnectQueue.d.ts +41 -0
- package/types/preact/components/SixDigitInput.d.ts +28 -0
- package/types/preact/effector.d.ts +8 -0
- package/types/preact/transition/CSSTransition.d.ts +8 -0
- package/types/preact/transition/Transition.d.ts +30 -0
- package/types/preact/translateLocalStatic.d.ts +4 -0
- package/types/productFiltering.d.ts +58 -0
- package/types/productSEO.d.ts +59 -0
- package/types/productSorting.d.ts +35 -0
- package/types/promiseAll.d.ts +5 -0
- package/types/promiseLimit.d.ts +13 -0
- package/types/rdsToInitialScores.d.ts +26 -0
- package/types/react/components/Portal.d.ts +2 -0
- package/types/react/components/RootCloseWrapper.d.ts +18 -0
- package/types/react/components/SixDigitInput.d.ts +27 -0
- package/types/react/contains.d.ts +1 -0
- package/types/react/popperBinder.d.ts +23 -0
- package/types/react/rootClose.d.ts +18 -0
- package/types/react/translateLocalStatic.d.ts +4 -0
- package/types/react/useAsyncCachedValue.d.ts +2 -0
- package/types/refreshTimeout.d.ts +5 -0
- package/types/remoteAuth.d.ts +14 -0
- package/types/request.d.ts +104 -0
- package/types/requestDetails.d.ts +16 -0
- package/types/rfc3339Normalize.d.ts +1 -0
- package/types/script.d.ts +36 -0
- package/types/seo.d.ts +5 -0
- package/types/shopDomain.d.ts +7 -0
- package/types/shopLinks.d.ts +14 -0
- package/types/slate.d.ts +47 -0
- package/types/sleep.d.ts +1 -0
- package/types/splitBy.d.ts +1 -0
- package/types/splitName.d.ts +2 -0
- package/types/stripZeros.d.ts +1 -0
- package/types/stripeError.d.ts +14 -0
- package/types/tailSplit.d.ts +1 -0
- package/types/tieredPrice.d.ts +2 -0
- package/types/timeIt.d.ts +1 -0
- package/types/toMajor.d.ts +8 -0
- package/types/toMinor.d.ts +8 -0
- package/types/trace.d.ts +17 -0
- package/types/translateLocale.d.ts +2 -0
- package/types/traverse.d.ts +1 -0
- package/types/truncate.d.ts +7 -0
- package/types/typedLocalStorage.d.ts +3 -0
- package/types/variantImage.d.ts +16 -0
- package/types/variantImageURL.d.ts +25 -0
- package/types/variantImages.d.ts +11 -0
- package/types/variantInventory.d.ts +14 -0
- package/types/variantOptions.d.ts +18 -0
- package/types/variantPrice.d.ts +37 -0
- package/types/variantPriceCommerce.d.ts +26 -0
- package/types/variantTitle.d.ts +7 -0
- package/types/variantTitleFull.d.ts +11 -0
- package/types/variantURL.d.ts +7 -0
- package/types/websocket.d.ts +33 -0
|
@@ -0,0 +1,1278 @@
|
|
|
1
|
+
import jwtDecode from "jwt-decode";
|
|
2
|
+
import { combine, createEffect, createEvent, createStore, forward, guard, restore, sample, } from "effector";
|
|
3
|
+
import { request, requestMulti, } from "../request.js";
|
|
4
|
+
import { rdsToInitialScores } from "../rdsToInitialScores.js";
|
|
5
|
+
import { combineEvery } from "../effector/combineEvery.js";
|
|
6
|
+
import { combineSome } from "../effector/combineSome.js";
|
|
7
|
+
import { compact } from "../compact.js";
|
|
8
|
+
import { createForm, createStringField } from "../effector/form.js";
|
|
9
|
+
import { generateUUID } from "../generateUUID.js";
|
|
10
|
+
import { mapResponseMultiData } from "../mapResponseMultiData.js";
|
|
11
|
+
import { nonNull } from "../nonNull.js";
|
|
12
|
+
import { requestResponseSplit, requestResponseSplitFirst } from "../effector/requestResponse.js";
|
|
13
|
+
import { requestResponseSplitMulti } from "../effector/requestResponseMulti.js";
|
|
14
|
+
import { uploadFile } from "../file.js";
|
|
15
|
+
import { validMaxLength250, validMaxLengthLongText, validNonEmpty } from "../effector/validator.js";
|
|
16
|
+
import { wrapSignInRequired } from "../effector/wrapSignInRequired.js";
|
|
17
|
+
function customerIDFromJWT(jwt) {
|
|
18
|
+
try {
|
|
19
|
+
const data = jwtDecode(jwt);
|
|
20
|
+
return data.customer_id || undefined;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function createFormToggleStateWithArgs(everythingIdle, form) {
|
|
27
|
+
const showForm = createEvent();
|
|
28
|
+
const showFormForReal = createEvent();
|
|
29
|
+
const hideForm = createEvent();
|
|
30
|
+
const hideFormForReal = createEvent();
|
|
31
|
+
const isFormVisible = createStore(null);
|
|
32
|
+
// form ui logic
|
|
33
|
+
{
|
|
34
|
+
guard({
|
|
35
|
+
source: showForm,
|
|
36
|
+
filter: everythingIdle,
|
|
37
|
+
target: showFormForReal,
|
|
38
|
+
});
|
|
39
|
+
guard({
|
|
40
|
+
source: hideForm,
|
|
41
|
+
filter: everythingIdle,
|
|
42
|
+
target: hideFormForReal,
|
|
43
|
+
});
|
|
44
|
+
// toggle form visibility
|
|
45
|
+
isFormVisible.on(showFormForReal, (_, v) => v);
|
|
46
|
+
isFormVisible.on(hideFormForReal, () => null);
|
|
47
|
+
// when form visibility changes, on false => true transition reset the form also
|
|
48
|
+
guard({
|
|
49
|
+
source: isFormVisible.updates.map(() => { }),
|
|
50
|
+
filter: isFormVisible.map((v) => v !== null),
|
|
51
|
+
target: form.reset,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
showForm,
|
|
56
|
+
hideForm,
|
|
57
|
+
isFormVisible,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function createFormToggleState(everythingIdle, form) {
|
|
61
|
+
const toggleForReal = createEvent();
|
|
62
|
+
const toggleFormVisibility = createEvent();
|
|
63
|
+
const isFormVisible = createStore(false);
|
|
64
|
+
// form ui logic
|
|
65
|
+
{
|
|
66
|
+
guard({
|
|
67
|
+
source: toggleFormVisibility,
|
|
68
|
+
filter: everythingIdle,
|
|
69
|
+
target: toggleForReal,
|
|
70
|
+
});
|
|
71
|
+
// toggle form visibility
|
|
72
|
+
isFormVisible.on(toggleForReal, (v) => !v);
|
|
73
|
+
// when form visibility changes, on false => true transition reset the form also
|
|
74
|
+
guard({
|
|
75
|
+
source: isFormVisible.updates,
|
|
76
|
+
filter: (v) => !!v,
|
|
77
|
+
target: form.reset,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
toggleFormVisibility,
|
|
82
|
+
isFormVisible,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function createProductForms(everythingIdle) {
|
|
86
|
+
// QUESTION FORM
|
|
87
|
+
const questionForm = createForm({
|
|
88
|
+
text: createStringField("text", "", [validNonEmpty, validMaxLengthLongText]),
|
|
89
|
+
});
|
|
90
|
+
const { showForm: showQuestionForm, hideForm: hideQuestionForm, isFormVisible: isQuestionFormVisible, } = createFormToggleStateWithArgs(everythingIdle, questionForm);
|
|
91
|
+
// QUESTION ANSWER FORM
|
|
92
|
+
const questionAnswerForm = createForm({
|
|
93
|
+
text: createStringField("text", "", [validNonEmpty, validMaxLengthLongText]),
|
|
94
|
+
});
|
|
95
|
+
const { showForm: showQuestionAnswerForm, hideForm: hideQuestionAnswerForm, isFormVisible: isQuestionAnswerFormVisible, } = createFormToggleStateWithArgs(everythingIdle, questionAnswerForm);
|
|
96
|
+
// REVIEW FORM
|
|
97
|
+
const reviewForm = createForm({
|
|
98
|
+
title: createStringField("title", "", [validNonEmpty, validMaxLength250]),
|
|
99
|
+
text: createStringField("text", "", [validNonEmpty, validMaxLengthLongText]),
|
|
100
|
+
});
|
|
101
|
+
const uploadReviewImageFile = createEvent();
|
|
102
|
+
const removeReviewImageFile = createEvent();
|
|
103
|
+
const appendReviewImageFile = createEvent();
|
|
104
|
+
const updateReviewImageFile = createEvent();
|
|
105
|
+
const reviewImageFiles = createStore([])
|
|
106
|
+
.on(removeReviewImageFile, (files, idx) => {
|
|
107
|
+
if (idx < 0 || idx >= files.length)
|
|
108
|
+
return files;
|
|
109
|
+
const newFiles = [...files];
|
|
110
|
+
newFiles.splice(idx, 1);
|
|
111
|
+
return newFiles;
|
|
112
|
+
})
|
|
113
|
+
.on(updateReviewImageFile, (files, data) => {
|
|
114
|
+
const idx = files.findIndex((f) => f.uuid === data.uuid);
|
|
115
|
+
if (idx === -1)
|
|
116
|
+
return files;
|
|
117
|
+
const newFiles = [...files];
|
|
118
|
+
newFiles[idx] = { ...newFiles[idx] };
|
|
119
|
+
if (data.id !== undefined)
|
|
120
|
+
newFiles[idx].id = data.id;
|
|
121
|
+
if (data.preview !== undefined)
|
|
122
|
+
newFiles[idx].preview = data.preview;
|
|
123
|
+
if (data.public_url !== undefined)
|
|
124
|
+
newFiles[idx].public_url = data.public_url;
|
|
125
|
+
if (data.status !== undefined)
|
|
126
|
+
newFiles[idx].status = data.status;
|
|
127
|
+
return newFiles;
|
|
128
|
+
})
|
|
129
|
+
.on(appendReviewImageFile, (files, data) => {
|
|
130
|
+
const newFile = {
|
|
131
|
+
uuid: data.uuid,
|
|
132
|
+
id: data.id || "",
|
|
133
|
+
preview: data.preview || "",
|
|
134
|
+
public_url: data.public_url || "",
|
|
135
|
+
status: data.status || "ok",
|
|
136
|
+
};
|
|
137
|
+
return [...files, newFile];
|
|
138
|
+
});
|
|
139
|
+
const setReviewScores = createEvent();
|
|
140
|
+
const reviewScores = restore(setReviewScores, []);
|
|
141
|
+
const setReviewRecommended = createEvent();
|
|
142
|
+
const reviewRecommended = restore(setReviewRecommended, "not_voted");
|
|
143
|
+
const { isFormVisible: isReviewFormVisible, toggleFormVisibility: toggleReviewFormVisibility } = createFormToggleState(everythingIdle, reviewForm);
|
|
144
|
+
return {
|
|
145
|
+
questionForm,
|
|
146
|
+
showQuestionForm,
|
|
147
|
+
hideQuestionForm,
|
|
148
|
+
isQuestionFormVisible,
|
|
149
|
+
questionAnswerForm,
|
|
150
|
+
showQuestionAnswerForm,
|
|
151
|
+
hideQuestionAnswerForm,
|
|
152
|
+
isQuestionAnswerFormVisible,
|
|
153
|
+
reviewForm,
|
|
154
|
+
uploadReviewImageFile,
|
|
155
|
+
removeReviewImageFile,
|
|
156
|
+
updateReviewImageFile,
|
|
157
|
+
appendReviewImageFile,
|
|
158
|
+
reviewImageFiles,
|
|
159
|
+
setReviewScores,
|
|
160
|
+
reviewScores,
|
|
161
|
+
setReviewRecommended,
|
|
162
|
+
reviewRecommended,
|
|
163
|
+
isReviewFormVisible,
|
|
164
|
+
toggleReviewFormVisibility,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function replaceReview(reviews, newReview) {
|
|
168
|
+
if (!reviews)
|
|
169
|
+
return reviews;
|
|
170
|
+
const idx = reviews.findIndex((r) => r.id === newReview.id);
|
|
171
|
+
if (idx !== -1) {
|
|
172
|
+
const newReviews = [...reviews];
|
|
173
|
+
newReviews[idx] = newReview;
|
|
174
|
+
return newReviews;
|
|
175
|
+
}
|
|
176
|
+
return reviews;
|
|
177
|
+
}
|
|
178
|
+
function replaceOrCreateOwnReview(review, newReview) {
|
|
179
|
+
if (!review)
|
|
180
|
+
return newReview;
|
|
181
|
+
if (review.id !== newReview.id)
|
|
182
|
+
return review;
|
|
183
|
+
return newReview;
|
|
184
|
+
}
|
|
185
|
+
function replaceOwnReview(review, newReview) {
|
|
186
|
+
if (!review)
|
|
187
|
+
return review;
|
|
188
|
+
if (review.id !== newReview.id)
|
|
189
|
+
return review;
|
|
190
|
+
return newReview;
|
|
191
|
+
}
|
|
192
|
+
function replaceQuestion(questions, newQuestion) {
|
|
193
|
+
if (!questions)
|
|
194
|
+
return questions;
|
|
195
|
+
const idx = questions.findIndex((r) => r.id === newQuestion.id);
|
|
196
|
+
if (idx !== -1) {
|
|
197
|
+
const newQuestions = [...questions];
|
|
198
|
+
newQuestions[idx] = newQuestion;
|
|
199
|
+
return newQuestions;
|
|
200
|
+
}
|
|
201
|
+
return questions;
|
|
202
|
+
}
|
|
203
|
+
function replaceOrCreateOwnQuestion(questions, newQuestion) {
|
|
204
|
+
if (!questions)
|
|
205
|
+
return [newQuestion];
|
|
206
|
+
const idx = questions.findIndex((q) => q.id === newQuestion.id);
|
|
207
|
+
if (idx !== -1) {
|
|
208
|
+
const newQuestions = [...questions];
|
|
209
|
+
newQuestions[idx] = newQuestion;
|
|
210
|
+
return newQuestions;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
return [...questions, newQuestion];
|
|
214
|
+
}
|
|
215
|
+
return questions;
|
|
216
|
+
}
|
|
217
|
+
function deleteQuestionFromList(questions, questionID) {
|
|
218
|
+
if (!questions)
|
|
219
|
+
return questions;
|
|
220
|
+
const idx = questions.findIndex((q) => q.id === questionID);
|
|
221
|
+
if (idx !== -1) {
|
|
222
|
+
const newQuestions = [...questions];
|
|
223
|
+
newQuestions.splice(idx, 1);
|
|
224
|
+
return newQuestions;
|
|
225
|
+
}
|
|
226
|
+
return questions;
|
|
227
|
+
}
|
|
228
|
+
function deleteQuestionAnswerFromList(questions, [questionID, questionAnswerID]) {
|
|
229
|
+
if (!questions)
|
|
230
|
+
return questions;
|
|
231
|
+
const idx = questions.findIndex((q) => q.id === questionID);
|
|
232
|
+
if (idx !== -1) {
|
|
233
|
+
const newQuestion = {
|
|
234
|
+
...questions[idx],
|
|
235
|
+
answers: questions[idx].answers?.filter((qa) => qa?.id !== questionAnswerID) || [],
|
|
236
|
+
};
|
|
237
|
+
const newQuestions = [...questions];
|
|
238
|
+
newQuestions[idx] = newQuestion;
|
|
239
|
+
return newQuestions;
|
|
240
|
+
}
|
|
241
|
+
return questions;
|
|
242
|
+
}
|
|
243
|
+
function deleteOwnReview(review, reviewID) {
|
|
244
|
+
if (review && review.id === reviewID)
|
|
245
|
+
return null;
|
|
246
|
+
return review;
|
|
247
|
+
}
|
|
248
|
+
function deleteReviewFromList(reviews, reviewID) {
|
|
249
|
+
if (!reviews)
|
|
250
|
+
return reviews;
|
|
251
|
+
const idx = reviews.findIndex((q) => q.id === reviewID);
|
|
252
|
+
if (idx !== -1) {
|
|
253
|
+
const newReviews = [...reviews];
|
|
254
|
+
newReviews.splice(idx, 1);
|
|
255
|
+
return newReviews;
|
|
256
|
+
}
|
|
257
|
+
return reviews;
|
|
258
|
+
}
|
|
259
|
+
export function createProduct(config) {
|
|
260
|
+
const configWithJWTAndLocale = combine(config.jwt, config.locale, (authToken, locale) => ({
|
|
261
|
+
...config,
|
|
262
|
+
opts: {
|
|
263
|
+
...config.opts,
|
|
264
|
+
authToken,
|
|
265
|
+
locale,
|
|
266
|
+
},
|
|
267
|
+
}));
|
|
268
|
+
const setReviewsSortBy = createEvent();
|
|
269
|
+
const setReviewsSortDesc = createEvent();
|
|
270
|
+
const setQuestionsSortBy = createEvent();
|
|
271
|
+
const setQuestionsSortDesc = createEvent();
|
|
272
|
+
const message = createEvent();
|
|
273
|
+
const pendingStores = [];
|
|
274
|
+
const pendingStoresButImageUpload = [];
|
|
275
|
+
const addPendingStore = (s, isImageUpload) => {
|
|
276
|
+
pendingStores.push(s);
|
|
277
|
+
if (!isImageUpload) {
|
|
278
|
+
pendingStoresButImageUpload.push(s);
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
const everythingIdle = createStore(true);
|
|
282
|
+
const everythingIdleButImageUpload = createStore(true);
|
|
283
|
+
const load = createEvent();
|
|
284
|
+
const unexpectedError = createEvent();
|
|
285
|
+
// state received from the server
|
|
286
|
+
const dataReviewsSortBy = createStore("rating").reset(load);
|
|
287
|
+
const dataReviewsSortDesc = createStore(true).reset(load);
|
|
288
|
+
const dataQuestionsSortBy = createStore("rating").reset(load);
|
|
289
|
+
const dataQuestionsSortDesc = createStore(true).reset(load);
|
|
290
|
+
const product = createStore(null).reset(load);
|
|
291
|
+
const totalReviews = createStore(0).reset(load);
|
|
292
|
+
const totalQuestions = createStore(0).reset(load);
|
|
293
|
+
const reviewsSortBy = createStore("rating")
|
|
294
|
+
.reset(load)
|
|
295
|
+
.on(setReviewsSortBy, (_, v) => v);
|
|
296
|
+
const reviewsSortDesc = createStore(true)
|
|
297
|
+
.reset(load)
|
|
298
|
+
.on(setReviewsSortDesc, (_, v) => v);
|
|
299
|
+
const reviews = createStore(null).reset(load);
|
|
300
|
+
const questionsSortBy = createStore("rating")
|
|
301
|
+
.reset(load)
|
|
302
|
+
.on(setQuestionsSortBy, (_, v) => v);
|
|
303
|
+
const questionsSortDesc = createStore(true)
|
|
304
|
+
.reset(load)
|
|
305
|
+
.on(setQuestionsSortDesc, (_, v) => v);
|
|
306
|
+
const questions = createStore(null).reset(load);
|
|
307
|
+
const canLoadMoreReviews = combine(totalReviews, reviews, (totalReviews, reviews) => (reviews?.length || 0) < totalReviews);
|
|
308
|
+
const canLoadMoreQuestions = combine(totalQuestions, questions, (totalQuestions, questions) => (questions?.length || 0) < totalQuestions);
|
|
309
|
+
const loadMoreReviews = createEvent();
|
|
310
|
+
const loadMoreQuestions = createEvent();
|
|
311
|
+
const loadMoreReviewsGeneric = createEvent("append");
|
|
312
|
+
const loadMoreQuestionsGeneric = createEvent("append");
|
|
313
|
+
const ownReview = createStore(null).reset(load);
|
|
314
|
+
const ownQuestions = createStore(null).reset(load);
|
|
315
|
+
const forms = createProductForms(everythingIdle);
|
|
316
|
+
const images = createStore(null).reset(load);
|
|
317
|
+
// reset form visibility on load
|
|
318
|
+
forms.isReviewFormVisible.reset(load);
|
|
319
|
+
forms.isQuestionFormVisible.reset(load);
|
|
320
|
+
forms.isQuestionAnswerFormVisible.reset(load);
|
|
321
|
+
function msgFilter(done, filter) {
|
|
322
|
+
return done.filterMap((v) => (v.result.kind === "data" ? filter(v.params) : undefined));
|
|
323
|
+
}
|
|
324
|
+
// derive initial question form values from own questions
|
|
325
|
+
{
|
|
326
|
+
const questionFormInitialValue = combine(ownQuestions, forms.isQuestionFormVisible, (questions, questionID) => {
|
|
327
|
+
const q = questions?.find((q) => q.id === questionID);
|
|
328
|
+
return {
|
|
329
|
+
text: q?.text || "",
|
|
330
|
+
};
|
|
331
|
+
});
|
|
332
|
+
forward({
|
|
333
|
+
from: questionFormInitialValue.map((v) => v.text),
|
|
334
|
+
to: forms.questionForm.text.setInitialValue,
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
// derive initial question answer form values from questions
|
|
338
|
+
{
|
|
339
|
+
const questionAnswerFormInitialValue = combine(questions, ownQuestions, forms.isQuestionAnswerFormVisible, (qs1, qs2, target) => {
|
|
340
|
+
const [questionID, questionAnswerID] = target || ["", ""];
|
|
341
|
+
const q = qs1?.find((q) => q.id === questionID) || qs2?.find((q) => q.id === questionID);
|
|
342
|
+
const qa = q?.answers?.find((qa) => qa?.id === questionAnswerID);
|
|
343
|
+
return {
|
|
344
|
+
text: qa?.text || "",
|
|
345
|
+
};
|
|
346
|
+
});
|
|
347
|
+
forward({
|
|
348
|
+
from: questionAnswerFormInitialValue.map((v) => v.text),
|
|
349
|
+
to: forms.questionAnswerForm.text.setInitialValue,
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
// derive initial review form values from product properties + review settings + own review
|
|
353
|
+
{
|
|
354
|
+
const reviewFormInitialValue = combine(configWithJWTAndLocale, product, ownReview, (config, product, ownReview) => {
|
|
355
|
+
const rds = config.reviewSettings.default_review_dimension_set || product?.review_dimension_set;
|
|
356
|
+
const title = ownReview?.title || "";
|
|
357
|
+
const text = ownReview?.text || "";
|
|
358
|
+
const scores = rdsToInitialScores(rds, config.reviewDimensions, ownReview?.scores);
|
|
359
|
+
const recommended = ownReview?.recommended || "not_voted";
|
|
360
|
+
const imageFiles = compact(ownReview?.image_files) || [];
|
|
361
|
+
return {
|
|
362
|
+
title,
|
|
363
|
+
text,
|
|
364
|
+
scores,
|
|
365
|
+
recommended,
|
|
366
|
+
imageFiles,
|
|
367
|
+
};
|
|
368
|
+
});
|
|
369
|
+
const scoresInitialValue = reviewFormInitialValue.map((v) => v.scores);
|
|
370
|
+
const recommendedInitialValue = reviewFormInitialValue.map((v) => v.recommended);
|
|
371
|
+
const reviewImageFilesInitialValue = reviewFormInitialValue.map((v) => v.imageFiles.map((f) => ({ ...f, preview: "", uuid: "", status: "ok" })));
|
|
372
|
+
forward({
|
|
373
|
+
from: reviewFormInitialValue.map((v) => v.title),
|
|
374
|
+
to: forms.reviewForm.title.setInitialValue,
|
|
375
|
+
});
|
|
376
|
+
forward({
|
|
377
|
+
from: reviewFormInitialValue.map((v) => v.text),
|
|
378
|
+
to: forms.reviewForm.text.setInitialValue,
|
|
379
|
+
});
|
|
380
|
+
// on form reset propagate initial values to their corresponding stores
|
|
381
|
+
forward({
|
|
382
|
+
from: sample(scoresInitialValue, forms.reviewForm.reset),
|
|
383
|
+
to: forms.reviewScores,
|
|
384
|
+
});
|
|
385
|
+
forward({
|
|
386
|
+
from: sample(recommendedInitialValue, forms.reviewForm.reset),
|
|
387
|
+
to: forms.reviewRecommended,
|
|
388
|
+
});
|
|
389
|
+
forward({
|
|
390
|
+
from: sample(reviewImageFilesInitialValue, forms.reviewForm.reset),
|
|
391
|
+
to: forms.reviewImageFiles,
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
// reload on configWithJWTAndLocale, but only if current product is not null
|
|
395
|
+
{
|
|
396
|
+
const hasProductID = product.map((p) => !!p);
|
|
397
|
+
const productID = product.map((p) => p?.id || "");
|
|
398
|
+
guard({
|
|
399
|
+
source: sample(productID, configWithJWTAndLocale),
|
|
400
|
+
filter: hasProductID,
|
|
401
|
+
target: load,
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
//================================================================================================================
|
|
405
|
+
// QUESTION FORM SUBMIT
|
|
406
|
+
//================================================================================================================
|
|
407
|
+
{
|
|
408
|
+
const createOrModifyQuestionFx = createEffect(async (p) => {
|
|
409
|
+
const sharedData = {
|
|
410
|
+
text: p.text,
|
|
411
|
+
};
|
|
412
|
+
if (p.question) {
|
|
413
|
+
return request(p.config.graphql.modifyQuestionMutation)({ shopID: p.config.shopID, questionID: p.question.id, data: sharedData }, p.config.opts);
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
return request(p.config.graphql.createQuestionMutation)({ shopID: p.config.shopID, data: { product_id: p.product.id, ...sharedData } }, p.config.opts);
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
addPendingStore(createOrModifyQuestionFx.pending);
|
|
420
|
+
const createOrModifyQuestionResult = requestResponseSplitFirst(createOrModifyQuestionFx.doneData);
|
|
421
|
+
// success
|
|
422
|
+
forward({
|
|
423
|
+
from: msgFilter(createOrModifyQuestionFx.done, (p) => (p.question ? "question_modified" : "question_created")),
|
|
424
|
+
to: message,
|
|
425
|
+
});
|
|
426
|
+
ownQuestions.on(createOrModifyQuestionResult.data, replaceOrCreateOwnQuestion);
|
|
427
|
+
forward({
|
|
428
|
+
from: createOrModifyQuestionResult.data,
|
|
429
|
+
to: forms.hideQuestionForm,
|
|
430
|
+
});
|
|
431
|
+
// failure
|
|
432
|
+
forward({
|
|
433
|
+
from: createOrModifyQuestionResult.error,
|
|
434
|
+
to: unexpectedError,
|
|
435
|
+
});
|
|
436
|
+
guard({
|
|
437
|
+
source: sample({
|
|
438
|
+
source: combine([configWithJWTAndLocale, forms.isQuestionFormVisible, ownQuestions, product]),
|
|
439
|
+
clock: forms.questionForm.submitted,
|
|
440
|
+
fn: ([config, questionID, ownQuestions, product], data) => {
|
|
441
|
+
const question = ownQuestions?.find((q) => q.id === questionID) || null;
|
|
442
|
+
return {
|
|
443
|
+
config,
|
|
444
|
+
...data,
|
|
445
|
+
question,
|
|
446
|
+
product: nonNull(product, "question product"),
|
|
447
|
+
};
|
|
448
|
+
},
|
|
449
|
+
}),
|
|
450
|
+
filter: everythingIdle,
|
|
451
|
+
target: createOrModifyQuestionFx,
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
//================================================================================================================
|
|
455
|
+
// QUESTION ANSWER FORM SUBMIT
|
|
456
|
+
//================================================================================================================
|
|
457
|
+
{
|
|
458
|
+
const createOrModifyQuestionAnswerFx = createEffect(async (p) => {
|
|
459
|
+
const sharedData = {
|
|
460
|
+
text: p.text,
|
|
461
|
+
};
|
|
462
|
+
let resp;
|
|
463
|
+
if (p.questionID && p.questionAnswerID) {
|
|
464
|
+
resp = await request(p.config.graphql.modifyQuestionAnswerMutation)({
|
|
465
|
+
shopID: p.config.shopID,
|
|
466
|
+
questionID: p.questionID,
|
|
467
|
+
questionAnswerID: p.questionAnswerID,
|
|
468
|
+
data: sharedData,
|
|
469
|
+
}, p.config.opts);
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
resp = await request(p.config.graphql.createQuestionAnswerMutation)({ shopID: p.config.shopID, questionID: p.questionID, data: sharedData }, p.config.opts);
|
|
473
|
+
}
|
|
474
|
+
if (resp.kind !== "data")
|
|
475
|
+
return resp;
|
|
476
|
+
return request(p.config.graphql.getQuestionQuery)({ shopID: p.config.shopID, questionID: p.questionID }, p.config.opts);
|
|
477
|
+
});
|
|
478
|
+
addPendingStore(createOrModifyQuestionAnswerFx.pending);
|
|
479
|
+
const createOrModifyQuestionAnswerResult = requestResponseSplitFirst(createOrModifyQuestionAnswerFx.doneData);
|
|
480
|
+
// success
|
|
481
|
+
forward({
|
|
482
|
+
from: msgFilter(createOrModifyQuestionAnswerFx.done, (p) => p.questionAnswerID ? "question_answer_modified" : "question_answer_created"),
|
|
483
|
+
to: message,
|
|
484
|
+
});
|
|
485
|
+
questions.on(createOrModifyQuestionAnswerResult.data, replaceQuestion);
|
|
486
|
+
ownQuestions.on(createOrModifyQuestionAnswerResult.data, replaceQuestion);
|
|
487
|
+
forward({
|
|
488
|
+
from: createOrModifyQuestionAnswerResult.data,
|
|
489
|
+
to: forms.hideQuestionAnswerForm,
|
|
490
|
+
});
|
|
491
|
+
// failure
|
|
492
|
+
forward({
|
|
493
|
+
from: createOrModifyQuestionAnswerResult.error,
|
|
494
|
+
to: unexpectedError,
|
|
495
|
+
});
|
|
496
|
+
guard({
|
|
497
|
+
source: sample({
|
|
498
|
+
source: combine([configWithJWTAndLocale, forms.isQuestionAnswerFormVisible]),
|
|
499
|
+
clock: forms.questionAnswerForm.submitted,
|
|
500
|
+
fn: ([config, target], data) => {
|
|
501
|
+
const [questionID, questionAnswerID] = target || ["", null];
|
|
502
|
+
return {
|
|
503
|
+
config,
|
|
504
|
+
...data,
|
|
505
|
+
questionID,
|
|
506
|
+
questionAnswerID,
|
|
507
|
+
};
|
|
508
|
+
},
|
|
509
|
+
}),
|
|
510
|
+
filter: everythingIdle,
|
|
511
|
+
target: createOrModifyQuestionAnswerFx,
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
//================================================================================================================
|
|
515
|
+
// DELETE REVIEW
|
|
516
|
+
//================================================================================================================
|
|
517
|
+
const deleteReview = createEvent();
|
|
518
|
+
{
|
|
519
|
+
const deleteReviewFx = createEffect(async (p) => {
|
|
520
|
+
return request(p.config.graphql.deleteReviewMutation)({ shopID: p.config.shopID, reviewID: p.reviewID }, p.config.opts);
|
|
521
|
+
});
|
|
522
|
+
addPendingStore(deleteReviewFx.pending);
|
|
523
|
+
const deleteReviewResult = requestResponseSplit(deleteReviewFx.doneData);
|
|
524
|
+
// success
|
|
525
|
+
const deletedID = deleteReviewFx.done.filterMap((v) => (v.result.kind === "data" ? v.params.reviewID : undefined));
|
|
526
|
+
forward({
|
|
527
|
+
from: deletedID.map(() => "review_deleted"),
|
|
528
|
+
to: message,
|
|
529
|
+
});
|
|
530
|
+
reviews.on(deletedID, deleteReviewFromList);
|
|
531
|
+
ownReview.on(deletedID, deleteOwnReview);
|
|
532
|
+
// failure
|
|
533
|
+
forward({
|
|
534
|
+
from: deleteReviewResult.error,
|
|
535
|
+
to: unexpectedError,
|
|
536
|
+
});
|
|
537
|
+
guard({
|
|
538
|
+
source: sample(configWithJWTAndLocale, deleteReview, (config, reviewID) => ({ config, reviewID })),
|
|
539
|
+
filter: everythingIdle,
|
|
540
|
+
target: deleteReviewFx,
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
//================================================================================================================
|
|
544
|
+
// DELETE QUESTION ANSWER
|
|
545
|
+
//================================================================================================================
|
|
546
|
+
const deleteQuestionAnswer = createEvent();
|
|
547
|
+
{
|
|
548
|
+
const deleteQuestionAnswerFx = createEffect(async (p) => {
|
|
549
|
+
return request(p.config.graphql.deleteQuestionAnswerMutation)({ shopID: p.config.shopID, questionAnswerID: p.questionAnswerID }, p.config.opts);
|
|
550
|
+
});
|
|
551
|
+
addPendingStore(deleteQuestionAnswerFx.pending);
|
|
552
|
+
const deleteQuestionAnswerResult = requestResponseSplit(deleteQuestionAnswerFx.doneData);
|
|
553
|
+
// success
|
|
554
|
+
const deletedID = deleteQuestionAnswerFx.done.filterMap((v) => v.result.kind === "data" ? [v.params.questionID, v.params.questionAnswerID] : undefined);
|
|
555
|
+
forward({
|
|
556
|
+
from: deletedID.map(() => "question_answer_deleted"),
|
|
557
|
+
to: message,
|
|
558
|
+
});
|
|
559
|
+
questions.on(deletedID, deleteQuestionAnswerFromList);
|
|
560
|
+
ownQuestions.on(deletedID, deleteQuestionAnswerFromList);
|
|
561
|
+
// failure
|
|
562
|
+
forward({
|
|
563
|
+
from: deleteQuestionAnswerResult.error,
|
|
564
|
+
to: unexpectedError,
|
|
565
|
+
});
|
|
566
|
+
guard({
|
|
567
|
+
source: sample(configWithJWTAndLocale, deleteQuestionAnswer, (config, [questionID, questionAnswerID]) => ({
|
|
568
|
+
config,
|
|
569
|
+
questionID,
|
|
570
|
+
questionAnswerID,
|
|
571
|
+
})),
|
|
572
|
+
filter: everythingIdle,
|
|
573
|
+
target: deleteQuestionAnswerFx,
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
//================================================================================================================
|
|
577
|
+
// DELETE QUESTION
|
|
578
|
+
//================================================================================================================
|
|
579
|
+
const deleteQuestion = createEvent();
|
|
580
|
+
{
|
|
581
|
+
const deleteQuestionFx = createEffect(async (p) => {
|
|
582
|
+
return request(p.config.graphql.deleteQuestionMutation)({ shopID: p.config.shopID, questionID: p.questionID }, p.config.opts);
|
|
583
|
+
});
|
|
584
|
+
addPendingStore(deleteQuestionFx.pending);
|
|
585
|
+
const deleteQuestionResult = requestResponseSplit(deleteQuestionFx.doneData);
|
|
586
|
+
// success
|
|
587
|
+
const deletedID = deleteQuestionFx.done.filterMap((v) => v.result.kind === "data" ? v.params.questionID : undefined);
|
|
588
|
+
forward({
|
|
589
|
+
from: deletedID.map(() => "question_deleted"),
|
|
590
|
+
to: message,
|
|
591
|
+
});
|
|
592
|
+
questions.on(deletedID, deleteQuestionFromList);
|
|
593
|
+
ownQuestions.on(deletedID, deleteQuestionFromList);
|
|
594
|
+
// failure
|
|
595
|
+
forward({
|
|
596
|
+
from: deleteQuestionResult.error,
|
|
597
|
+
to: unexpectedError,
|
|
598
|
+
});
|
|
599
|
+
guard({
|
|
600
|
+
source: sample(configWithJWTAndLocale, deleteQuestion, (config, questionID) => ({ config, questionID })),
|
|
601
|
+
filter: everythingIdle,
|
|
602
|
+
target: deleteQuestionFx,
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
//================================================================================================================
|
|
606
|
+
// REVIEW FORM SUBMIT
|
|
607
|
+
//================================================================================================================
|
|
608
|
+
{
|
|
609
|
+
const createOrModifyReviewFx = createEffect(async (p) => {
|
|
610
|
+
const sharedData = {
|
|
611
|
+
title: p.title,
|
|
612
|
+
text: p.text,
|
|
613
|
+
recommended: p.recommended,
|
|
614
|
+
scores: p.scores.map((s) => ({ review_dimension_id: s.review_dimension_id, score: s.score })),
|
|
615
|
+
image_file_ids: compact(p.imageFiles.map((f) => f.id || undefined)),
|
|
616
|
+
};
|
|
617
|
+
if (p.ownReview) {
|
|
618
|
+
return request(p.config.graphql.modifyReviewMutation)({ shopID: p.config.shopID, reviewID: p.ownReview.id, data: sharedData }, p.config.opts);
|
|
619
|
+
}
|
|
620
|
+
else {
|
|
621
|
+
return request(p.config.graphql.createReviewMutation)({ shopID: p.config.shopID, data: { product_id: p.product.id, ...sharedData } }, p.config.opts);
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
addPendingStore(createOrModifyReviewFx.pending);
|
|
625
|
+
const createOrModifyReviewResult = requestResponseSplitFirst(createOrModifyReviewFx.doneData);
|
|
626
|
+
// success
|
|
627
|
+
forward({
|
|
628
|
+
from: msgFilter(createOrModifyReviewFx.done, (p) => (p.ownReview ? "review_modified" : "review_created")),
|
|
629
|
+
to: message,
|
|
630
|
+
});
|
|
631
|
+
ownReview.on(createOrModifyReviewResult.data, replaceOrCreateOwnReview);
|
|
632
|
+
forward({
|
|
633
|
+
from: createOrModifyReviewResult.data,
|
|
634
|
+
to: forms.toggleReviewFormVisibility,
|
|
635
|
+
});
|
|
636
|
+
// failure
|
|
637
|
+
forward({
|
|
638
|
+
from: createOrModifyReviewResult.error,
|
|
639
|
+
to: unexpectedError,
|
|
640
|
+
});
|
|
641
|
+
guard({
|
|
642
|
+
source: sample({
|
|
643
|
+
source: combine([
|
|
644
|
+
configWithJWTAndLocale,
|
|
645
|
+
forms.reviewScores,
|
|
646
|
+
forms.reviewImageFiles,
|
|
647
|
+
forms.reviewRecommended,
|
|
648
|
+
ownReview,
|
|
649
|
+
product,
|
|
650
|
+
]),
|
|
651
|
+
clock: forms.reviewForm.submitted,
|
|
652
|
+
fn: ([config, scores, imageFiles, recommended, ownReview, product], data) => {
|
|
653
|
+
return {
|
|
654
|
+
config,
|
|
655
|
+
...data,
|
|
656
|
+
scores,
|
|
657
|
+
imageFiles,
|
|
658
|
+
recommended,
|
|
659
|
+
ownReview,
|
|
660
|
+
product: nonNull(product, "review product"),
|
|
661
|
+
};
|
|
662
|
+
},
|
|
663
|
+
}),
|
|
664
|
+
filter: everythingIdle,
|
|
665
|
+
target: createOrModifyReviewFx,
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
//================================================================================================================
|
|
669
|
+
// FILE UPLOAD
|
|
670
|
+
//================================================================================================================
|
|
671
|
+
{
|
|
672
|
+
// file upload process
|
|
673
|
+
const uploadFileEv = forms.uploadReviewImageFile.map((file) => ({ file, uuid: generateUUID() }));
|
|
674
|
+
const uploadFileFx = createEffect(async (p) => {
|
|
675
|
+
const result = await uploadFile(p.file, p.config.shopID, p.config.opts);
|
|
676
|
+
return {
|
|
677
|
+
result,
|
|
678
|
+
uuid: p.uuid,
|
|
679
|
+
};
|
|
680
|
+
});
|
|
681
|
+
addPendingStore(uploadFileFx.pending, "image_upload_store");
|
|
682
|
+
// append the file right away to the list of files with preview
|
|
683
|
+
forward({
|
|
684
|
+
from: uploadFileEv.map((v) => {
|
|
685
|
+
const preview = URL.createObjectURL(v.file);
|
|
686
|
+
return {
|
|
687
|
+
uuid: v.uuid,
|
|
688
|
+
preview,
|
|
689
|
+
status: "uploading",
|
|
690
|
+
};
|
|
691
|
+
}),
|
|
692
|
+
to: forms.appendReviewImageFile,
|
|
693
|
+
});
|
|
694
|
+
// upload file when it arrives (note that we allow uploading multiple files in parallel and we don't block on "pending")
|
|
695
|
+
guard({
|
|
696
|
+
source: sample(configWithJWTAndLocale, uploadFileEv, (config, data) => ({ config, ...data })),
|
|
697
|
+
filter: everythingIdleButImageUpload,
|
|
698
|
+
target: uploadFileFx,
|
|
699
|
+
});
|
|
700
|
+
// once upload is complete, update the file with the outcome
|
|
701
|
+
forward({
|
|
702
|
+
from: uploadFileFx.doneData.map((v) => {
|
|
703
|
+
if (v.result.kind === "ok") {
|
|
704
|
+
const file = v.result.file;
|
|
705
|
+
return {
|
|
706
|
+
uuid: v.uuid,
|
|
707
|
+
id: file.id,
|
|
708
|
+
public_url: file.public_url,
|
|
709
|
+
preview: "",
|
|
710
|
+
status: "ok",
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
else {
|
|
714
|
+
return { uuid: v.uuid, status: v.result.kind };
|
|
715
|
+
}
|
|
716
|
+
}),
|
|
717
|
+
to: forms.updateReviewImageFile,
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
//================================================================================================================
|
|
721
|
+
// LOAD EVERYTHING
|
|
722
|
+
//================================================================================================================
|
|
723
|
+
{
|
|
724
|
+
const loadFx = createEffect(async (p) => {
|
|
725
|
+
const jwt = p.config.opts?.authToken || "";
|
|
726
|
+
if (!jwt) {
|
|
727
|
+
return mapResponseMultiData(await requestMulti(p.config.graphql.loadProductNoCustomerQuery)({ shopID: p.config.shopID, productID: p.productID }, p.config.opts), (v) => ({
|
|
728
|
+
...v,
|
|
729
|
+
ownReviews: null,
|
|
730
|
+
ownQuestions: null,
|
|
731
|
+
}));
|
|
732
|
+
}
|
|
733
|
+
else {
|
|
734
|
+
const customerID = jwtDecode(p.config.opts?.authToken || "").customer_id;
|
|
735
|
+
return requestMulti(config.graphql.loadProductQuery)({ shopID: p.config.shopID, customerID, productID: p.productID }, p.config.opts);
|
|
736
|
+
}
|
|
737
|
+
});
|
|
738
|
+
addPendingStore(loadFx.pending);
|
|
739
|
+
const loadResult = requestResponseSplitMulti(loadFx.doneData);
|
|
740
|
+
// success
|
|
741
|
+
forward({ from: loadResult.data.map(() => "rating"), to: dataReviewsSortBy });
|
|
742
|
+
forward({ from: loadResult.data.map(() => true), to: dataReviewsSortDesc });
|
|
743
|
+
forward({ from: loadResult.data.map(() => "rating"), to: dataQuestionsSortBy });
|
|
744
|
+
forward({ from: loadResult.data.map(() => true), to: dataQuestionsSortDesc });
|
|
745
|
+
forward({
|
|
746
|
+
from: loadResult.data.map((v) => v.products?.[0] || null),
|
|
747
|
+
to: product,
|
|
748
|
+
});
|
|
749
|
+
forward({
|
|
750
|
+
from: loadResult.data.map((v) => compact(v.reviews?.items || null)),
|
|
751
|
+
to: reviews,
|
|
752
|
+
});
|
|
753
|
+
forward({
|
|
754
|
+
from: loadResult.data.map((v) => compact(v.questions?.items)),
|
|
755
|
+
to: questions,
|
|
756
|
+
});
|
|
757
|
+
forward({
|
|
758
|
+
from: loadResult.data.map((v) => v.ownReviews?.items?.[0] || null),
|
|
759
|
+
to: ownReview,
|
|
760
|
+
});
|
|
761
|
+
forward({
|
|
762
|
+
from: loadResult.data.map((v) => v.ownQuestions?.items || null),
|
|
763
|
+
to: ownQuestions,
|
|
764
|
+
});
|
|
765
|
+
forward({
|
|
766
|
+
from: loadResult.data.map((v) => v.reviews?.count || 0),
|
|
767
|
+
to: totalReviews,
|
|
768
|
+
});
|
|
769
|
+
forward({
|
|
770
|
+
from: loadResult.data.map((v) => v.questions?.count || 0),
|
|
771
|
+
to: totalQuestions,
|
|
772
|
+
});
|
|
773
|
+
forward({
|
|
774
|
+
from: loadResult.data.map((v) => v.images),
|
|
775
|
+
to: images,
|
|
776
|
+
});
|
|
777
|
+
// failure
|
|
778
|
+
forward({
|
|
779
|
+
from: loadResult.error,
|
|
780
|
+
to: unexpectedError,
|
|
781
|
+
});
|
|
782
|
+
guard({
|
|
783
|
+
source: sample(configWithJWTAndLocale, load, (config, productID) => ({ config, productID })),
|
|
784
|
+
filter: everythingIdle,
|
|
785
|
+
target: loadFx,
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
//================================================================================================================
|
|
789
|
+
// LOAD MORE REVIEWS
|
|
790
|
+
//================================================================================================================
|
|
791
|
+
{
|
|
792
|
+
const loadMoreReviewsFx = createEffect(async (p) => {
|
|
793
|
+
const jwt = p.config.opts?.authToken || "";
|
|
794
|
+
const customerID = jwt ? customerIDFromJWT(jwt) : undefined;
|
|
795
|
+
return request(p.config.graphql.searchReviewsQuery)({
|
|
796
|
+
shopID: p.config.shopID,
|
|
797
|
+
productID: p.productID,
|
|
798
|
+
limit: p.limit,
|
|
799
|
+
offset: p.offset,
|
|
800
|
+
sortBy: p.sortBy,
|
|
801
|
+
sortDesc: p.sortDesc,
|
|
802
|
+
notCustomerID: customerID,
|
|
803
|
+
}, p.config.opts);
|
|
804
|
+
});
|
|
805
|
+
addPendingStore(loadMoreReviewsFx.pending);
|
|
806
|
+
const loadResult = requestResponseSplit(loadMoreReviewsFx.doneData);
|
|
807
|
+
// success
|
|
808
|
+
const successParamsAndData = loadMoreReviewsFx.done.filterMap((v) => v.result.kind === "data" ? { params: v.params, data: v.result.data } : undefined);
|
|
809
|
+
forward({ from: successParamsAndData.map((v) => v.params.sortBy), to: dataReviewsSortBy });
|
|
810
|
+
forward({ from: successParamsAndData.map((v) => v.params.sortDesc), to: dataReviewsSortDesc });
|
|
811
|
+
reviews.on(successParamsAndData, (reviews, pd) => pd.params.action === "replace"
|
|
812
|
+
? [...compact(pd.data.items)]
|
|
813
|
+
: [...(reviews || []), ...compact(pd.data.items || [])]);
|
|
814
|
+
// failure
|
|
815
|
+
forward({
|
|
816
|
+
from: loadResult.error,
|
|
817
|
+
to: unexpectedError,
|
|
818
|
+
});
|
|
819
|
+
sample({ source: dataReviewsSortBy, clock: loadResult.error, target: reviewsSortBy });
|
|
820
|
+
sample({ source: dataReviewsSortDesc, clock: loadResult.error, target: reviewsSortDesc });
|
|
821
|
+
guard({
|
|
822
|
+
source: sample(combine(configWithJWTAndLocale, reviews, reviewsSortBy, reviewsSortDesc, product), loadMoreReviewsGeneric, ([config, reviews, reviewsSortBy, reviewsSortDesc, product], action) => ({
|
|
823
|
+
config,
|
|
824
|
+
productID: nonNull(product, "load more reviews product").id,
|
|
825
|
+
limit: 10,
|
|
826
|
+
offset: action === "replace" ? 0 : reviews?.length || 0,
|
|
827
|
+
sortBy: reviewsSortBy,
|
|
828
|
+
sortDesc: reviewsSortDesc,
|
|
829
|
+
action,
|
|
830
|
+
})),
|
|
831
|
+
filter: combineEvery(everythingIdle),
|
|
832
|
+
target: loadMoreReviewsFx,
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
//================================================================================================================
|
|
836
|
+
// LOAD MORE QUESTIONS
|
|
837
|
+
//================================================================================================================
|
|
838
|
+
{
|
|
839
|
+
const loadMoreQuestionsFx = createEffect(async (p) => {
|
|
840
|
+
const jwt = p.config.opts?.authToken || "";
|
|
841
|
+
const customerID = jwt ? customerIDFromJWT(jwt) : undefined;
|
|
842
|
+
return request(p.config.graphql.searchQuestionsQuery)({
|
|
843
|
+
shopID: p.config.shopID,
|
|
844
|
+
productID: p.productID,
|
|
845
|
+
limit: p.limit,
|
|
846
|
+
offset: p.offset,
|
|
847
|
+
sortBy: p.sortBy,
|
|
848
|
+
sortDesc: p.sortDesc,
|
|
849
|
+
notCustomerID: customerID,
|
|
850
|
+
}, p.config.opts);
|
|
851
|
+
});
|
|
852
|
+
addPendingStore(loadMoreQuestionsFx.pending);
|
|
853
|
+
const loadResult = requestResponseSplit(loadMoreQuestionsFx.doneData);
|
|
854
|
+
// success
|
|
855
|
+
const successParamsAndData = loadMoreQuestionsFx.done.filterMap((v) => v.result.kind === "data" ? { params: v.params, data: v.result.data } : undefined);
|
|
856
|
+
forward({ from: successParamsAndData.map((v) => v.params.sortBy), to: dataQuestionsSortBy });
|
|
857
|
+
forward({ from: successParamsAndData.map((v) => v.params.sortDesc), to: dataQuestionsSortDesc });
|
|
858
|
+
questions.on(successParamsAndData, (questions, pd) => pd.params.action === "replace"
|
|
859
|
+
? [...compact(pd.data.items)]
|
|
860
|
+
: [...(questions || []), ...compact(pd.data.items || [])]);
|
|
861
|
+
// failure
|
|
862
|
+
forward({
|
|
863
|
+
from: loadResult.error,
|
|
864
|
+
to: unexpectedError,
|
|
865
|
+
});
|
|
866
|
+
sample({ source: dataQuestionsSortBy, clock: loadResult.error, target: questionsSortBy });
|
|
867
|
+
sample({ source: dataQuestionsSortDesc, clock: loadResult.error, target: questionsSortDesc });
|
|
868
|
+
guard({
|
|
869
|
+
source: sample(combine(configWithJWTAndLocale, questions, questionsSortBy, questionsSortDesc, product), loadMoreQuestionsGeneric, ([config, questions, questionsSortBy, questionsSortDesc, product], action) => ({
|
|
870
|
+
config,
|
|
871
|
+
productID: nonNull(product, "load more questions product").id,
|
|
872
|
+
limit: 10,
|
|
873
|
+
offset: action === "replace" ? 0 : questions?.length || 0,
|
|
874
|
+
sortBy: questionsSortBy,
|
|
875
|
+
sortDesc: questionsSortDesc,
|
|
876
|
+
action,
|
|
877
|
+
})),
|
|
878
|
+
filter: combineEvery(everythingIdle),
|
|
879
|
+
target: loadMoreQuestionsFx,
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
//================================================================================================================
|
|
883
|
+
// VOTE REVIEW
|
|
884
|
+
//================================================================================================================
|
|
885
|
+
const voteReviewYes = createEvent();
|
|
886
|
+
const voteReviewNo = createEvent();
|
|
887
|
+
const voteReviewDelete = createEvent();
|
|
888
|
+
{
|
|
889
|
+
const voteReviewFx = createEffect(async (p) => {
|
|
890
|
+
const resp = await request(config.graphql.voteReviewMutation)({ shopID: p.config.shopID, reviewID: p.reviewID, y: p.y, delete: p.delete }, p.config.opts);
|
|
891
|
+
if (resp.kind !== "data")
|
|
892
|
+
return resp;
|
|
893
|
+
return request(config.graphql.getReviewQuery)({ shopID: p.config.shopID, reviewID: p.reviewID }, p.config.opts);
|
|
894
|
+
});
|
|
895
|
+
addPendingStore(voteReviewFx.pending);
|
|
896
|
+
const voteResult = requestResponseSplitFirst(voteReviewFx.doneData);
|
|
897
|
+
// success
|
|
898
|
+
forward({
|
|
899
|
+
from: msgFilter(voteReviewFx.done, (p) => {
|
|
900
|
+
if (p.delete)
|
|
901
|
+
return "review_vote_deleted";
|
|
902
|
+
return p.y ? "review_voted_yes" : "review_voted_no";
|
|
903
|
+
}),
|
|
904
|
+
to: message,
|
|
905
|
+
});
|
|
906
|
+
reviews.on(voteResult.data, replaceReview);
|
|
907
|
+
ownReview.on(voteResult.data, replaceOwnReview);
|
|
908
|
+
// failure
|
|
909
|
+
forward({
|
|
910
|
+
from: voteResult.error,
|
|
911
|
+
to: unexpectedError,
|
|
912
|
+
});
|
|
913
|
+
guard({
|
|
914
|
+
source: sample(configWithJWTAndLocale, voteReviewYes, (config, reviewID) => ({
|
|
915
|
+
config,
|
|
916
|
+
reviewID,
|
|
917
|
+
y: true,
|
|
918
|
+
delete: false,
|
|
919
|
+
})),
|
|
920
|
+
filter: everythingIdle,
|
|
921
|
+
target: voteReviewFx,
|
|
922
|
+
});
|
|
923
|
+
guard({
|
|
924
|
+
source: sample(configWithJWTAndLocale, voteReviewNo, (config, reviewID) => ({
|
|
925
|
+
config,
|
|
926
|
+
reviewID,
|
|
927
|
+
y: false,
|
|
928
|
+
delete: false,
|
|
929
|
+
})),
|
|
930
|
+
filter: everythingIdle,
|
|
931
|
+
target: voteReviewFx,
|
|
932
|
+
});
|
|
933
|
+
guard({
|
|
934
|
+
source: sample(configWithJWTAndLocale, voteReviewDelete, (config, reviewID) => ({
|
|
935
|
+
config,
|
|
936
|
+
reviewID,
|
|
937
|
+
y: false,
|
|
938
|
+
delete: true,
|
|
939
|
+
})),
|
|
940
|
+
filter: everythingIdle,
|
|
941
|
+
target: voteReviewFx,
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
//================================================================================================================
|
|
945
|
+
// FLAG REVIEW
|
|
946
|
+
//================================================================================================================
|
|
947
|
+
const flagReview = createEvent();
|
|
948
|
+
const flagReviewDelete = createEvent();
|
|
949
|
+
{
|
|
950
|
+
const flagReviewFx = createEffect(async (p) => {
|
|
951
|
+
const resp = await request(config.graphql.flagReviewMutation)({ shopID: p.config.shopID, reviewID: p.reviewID, delete: p.delete }, p.config.opts);
|
|
952
|
+
if (resp.kind !== "data")
|
|
953
|
+
return resp;
|
|
954
|
+
return request(config.graphql.getReviewQuery)({ shopID: p.config.shopID, reviewID: p.reviewID }, p.config.opts);
|
|
955
|
+
});
|
|
956
|
+
addPendingStore(flagReviewFx.pending);
|
|
957
|
+
const flagResult = requestResponseSplitFirst(flagReviewFx.doneData);
|
|
958
|
+
// success
|
|
959
|
+
forward({
|
|
960
|
+
from: msgFilter(flagReviewFx.done, (p) => (p.delete ? "review_unflagged" : "review_flagged")),
|
|
961
|
+
to: message,
|
|
962
|
+
});
|
|
963
|
+
reviews.on(flagResult.data, replaceReview);
|
|
964
|
+
ownReview.on(flagResult.data, replaceOwnReview);
|
|
965
|
+
// failure
|
|
966
|
+
forward({
|
|
967
|
+
from: flagResult.error,
|
|
968
|
+
to: unexpectedError,
|
|
969
|
+
});
|
|
970
|
+
guard({
|
|
971
|
+
source: sample(configWithJWTAndLocale, flagReview, (config, reviewID) => ({ config, reviewID, delete: false })),
|
|
972
|
+
filter: everythingIdle,
|
|
973
|
+
target: flagReviewFx,
|
|
974
|
+
});
|
|
975
|
+
guard({
|
|
976
|
+
source: sample(configWithJWTAndLocale, flagReviewDelete, (config, reviewID) => ({
|
|
977
|
+
config,
|
|
978
|
+
reviewID,
|
|
979
|
+
delete: true,
|
|
980
|
+
})),
|
|
981
|
+
filter: everythingIdle,
|
|
982
|
+
target: flagReviewFx,
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
//================================================================================================================
|
|
986
|
+
// VOTE QUESTION
|
|
987
|
+
//================================================================================================================
|
|
988
|
+
const voteQuestionYes = createEvent();
|
|
989
|
+
const voteQuestionNo = createEvent();
|
|
990
|
+
const voteQuestionDelete = createEvent();
|
|
991
|
+
{
|
|
992
|
+
const voteQuestionFx = createEffect(async (p) => {
|
|
993
|
+
const resp = await request(config.graphql.voteQuestionMutation)({ shopID: p.config.shopID, questionID: p.questionID, y: p.y, delete: p.delete }, p.config.opts);
|
|
994
|
+
if (resp.kind !== "data")
|
|
995
|
+
return resp;
|
|
996
|
+
return request(config.graphql.getQuestionQuery)({ shopID: p.config.shopID, questionID: p.questionID }, p.config.opts);
|
|
997
|
+
});
|
|
998
|
+
addPendingStore(voteQuestionFx.pending);
|
|
999
|
+
const voteResult = requestResponseSplitFirst(voteQuestionFx.doneData);
|
|
1000
|
+
// success
|
|
1001
|
+
forward({
|
|
1002
|
+
from: msgFilter(voteQuestionFx.done, (p) => {
|
|
1003
|
+
if (p.delete)
|
|
1004
|
+
return "question_vote_deleted";
|
|
1005
|
+
return p.y ? "question_voted_yes" : "question_voted_no";
|
|
1006
|
+
}),
|
|
1007
|
+
to: message,
|
|
1008
|
+
});
|
|
1009
|
+
questions.on(voteResult.data, replaceQuestion);
|
|
1010
|
+
ownQuestions.on(voteResult.data, replaceQuestion);
|
|
1011
|
+
// failure
|
|
1012
|
+
forward({
|
|
1013
|
+
from: voteResult.error,
|
|
1014
|
+
to: unexpectedError,
|
|
1015
|
+
});
|
|
1016
|
+
guard({
|
|
1017
|
+
source: sample(configWithJWTAndLocale, voteQuestionYes, (config, questionID) => ({
|
|
1018
|
+
config,
|
|
1019
|
+
questionID,
|
|
1020
|
+
y: true,
|
|
1021
|
+
delete: false,
|
|
1022
|
+
})),
|
|
1023
|
+
filter: everythingIdle,
|
|
1024
|
+
target: voteQuestionFx,
|
|
1025
|
+
});
|
|
1026
|
+
guard({
|
|
1027
|
+
source: sample(configWithJWTAndLocale, voteQuestionNo, (config, questionID) => ({
|
|
1028
|
+
config,
|
|
1029
|
+
questionID,
|
|
1030
|
+
y: false,
|
|
1031
|
+
delete: false,
|
|
1032
|
+
})),
|
|
1033
|
+
filter: everythingIdle,
|
|
1034
|
+
target: voteQuestionFx,
|
|
1035
|
+
});
|
|
1036
|
+
guard({
|
|
1037
|
+
source: sample(configWithJWTAndLocale, voteQuestionDelete, (config, questionID) => ({
|
|
1038
|
+
config,
|
|
1039
|
+
questionID,
|
|
1040
|
+
y: false,
|
|
1041
|
+
delete: true,
|
|
1042
|
+
})),
|
|
1043
|
+
filter: everythingIdle,
|
|
1044
|
+
target: voteQuestionFx,
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
//================================================================================================================
|
|
1048
|
+
// FLAG QUESTION
|
|
1049
|
+
//================================================================================================================
|
|
1050
|
+
const flagQuestion = createEvent();
|
|
1051
|
+
const flagQuestionDelete = createEvent();
|
|
1052
|
+
{
|
|
1053
|
+
const flagQuestionFx = createEffect(async (p) => {
|
|
1054
|
+
const resp = await request(config.graphql.flagQuestionMutation)({ shopID: p.config.shopID, questionID: p.questionID, delete: p.delete }, p.config.opts);
|
|
1055
|
+
if (resp.kind !== "data")
|
|
1056
|
+
return resp;
|
|
1057
|
+
return request(config.graphql.getQuestionQuery)({ shopID: p.config.shopID, questionID: p.questionID }, p.config.opts);
|
|
1058
|
+
});
|
|
1059
|
+
addPendingStore(flagQuestionFx.pending);
|
|
1060
|
+
const flagResult = requestResponseSplitFirst(flagQuestionFx.doneData);
|
|
1061
|
+
// success
|
|
1062
|
+
forward({
|
|
1063
|
+
from: msgFilter(flagQuestionFx.done, (p) => (p.delete ? "question_unflagged" : "question_flagged")),
|
|
1064
|
+
to: message,
|
|
1065
|
+
});
|
|
1066
|
+
questions.on(flagResult.data, replaceQuestion);
|
|
1067
|
+
ownQuestions.on(flagResult.data, replaceQuestion);
|
|
1068
|
+
// failure
|
|
1069
|
+
forward({
|
|
1070
|
+
from: flagResult.error,
|
|
1071
|
+
to: unexpectedError,
|
|
1072
|
+
});
|
|
1073
|
+
guard({
|
|
1074
|
+
source: sample(configWithJWTAndLocale, flagQuestion, (config, questionID) => ({
|
|
1075
|
+
config,
|
|
1076
|
+
questionID,
|
|
1077
|
+
delete: false,
|
|
1078
|
+
})),
|
|
1079
|
+
filter: everythingIdle,
|
|
1080
|
+
target: flagQuestionFx,
|
|
1081
|
+
});
|
|
1082
|
+
guard({
|
|
1083
|
+
source: sample(configWithJWTAndLocale, flagQuestionDelete, (config, questionID) => ({
|
|
1084
|
+
config,
|
|
1085
|
+
questionID,
|
|
1086
|
+
delete: true,
|
|
1087
|
+
})),
|
|
1088
|
+
filter: everythingIdle,
|
|
1089
|
+
target: flagQuestionFx,
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
//================================================================================================================
|
|
1093
|
+
// VOTE QUESTION ANSWER
|
|
1094
|
+
//================================================================================================================
|
|
1095
|
+
const voteQuestionAnswerYes = createEvent();
|
|
1096
|
+
const voteQuestionAnswerNo = createEvent();
|
|
1097
|
+
const voteQuestionAnswerDelete = createEvent();
|
|
1098
|
+
{
|
|
1099
|
+
const voteQuestionAnswerFx = createEffect(async (p) => {
|
|
1100
|
+
const resp = await request(config.graphql.voteQuestionAnswerMutation)({ shopID: p.config.shopID, questionAnswerID: p.questionAnswerID, y: p.y, delete: p.delete }, p.config.opts);
|
|
1101
|
+
if (resp.kind !== "data")
|
|
1102
|
+
return resp;
|
|
1103
|
+
return request(config.graphql.getQuestionQuery)({ shopID: p.config.shopID, questionID: p.questionID }, p.config.opts);
|
|
1104
|
+
});
|
|
1105
|
+
addPendingStore(voteQuestionAnswerFx.pending);
|
|
1106
|
+
const voteResult = requestResponseSplitFirst(voteQuestionAnswerFx.doneData);
|
|
1107
|
+
// success
|
|
1108
|
+
forward({
|
|
1109
|
+
from: msgFilter(voteQuestionAnswerFx.done, (p) => {
|
|
1110
|
+
if (p.delete)
|
|
1111
|
+
return "question_answer_vote_deleted";
|
|
1112
|
+
return p.y ? "question_answer_voted_yes" : "question_answer_voted_no";
|
|
1113
|
+
}),
|
|
1114
|
+
to: message,
|
|
1115
|
+
});
|
|
1116
|
+
questions.on(voteResult.data, replaceQuestion);
|
|
1117
|
+
ownQuestions.on(voteResult.data, replaceQuestion);
|
|
1118
|
+
// failure
|
|
1119
|
+
forward({
|
|
1120
|
+
from: voteResult.error,
|
|
1121
|
+
to: unexpectedError,
|
|
1122
|
+
});
|
|
1123
|
+
guard({
|
|
1124
|
+
source: sample(configWithJWTAndLocale, voteQuestionAnswerYes, (config, [questionID, questionAnswerID]) => ({
|
|
1125
|
+
config,
|
|
1126
|
+
questionID,
|
|
1127
|
+
questionAnswerID,
|
|
1128
|
+
y: true,
|
|
1129
|
+
delete: false,
|
|
1130
|
+
})),
|
|
1131
|
+
filter: everythingIdle,
|
|
1132
|
+
target: voteQuestionAnswerFx,
|
|
1133
|
+
});
|
|
1134
|
+
guard({
|
|
1135
|
+
source: sample(configWithJWTAndLocale, voteQuestionAnswerNo, (config, [questionID, questionAnswerID]) => ({
|
|
1136
|
+
config,
|
|
1137
|
+
questionID,
|
|
1138
|
+
questionAnswerID,
|
|
1139
|
+
y: false,
|
|
1140
|
+
delete: false,
|
|
1141
|
+
})),
|
|
1142
|
+
filter: everythingIdle,
|
|
1143
|
+
target: voteQuestionAnswerFx,
|
|
1144
|
+
});
|
|
1145
|
+
guard({
|
|
1146
|
+
source: sample(configWithJWTAndLocale, voteQuestionAnswerDelete, (config, [questionID, questionAnswerID]) => ({
|
|
1147
|
+
config,
|
|
1148
|
+
questionID,
|
|
1149
|
+
questionAnswerID,
|
|
1150
|
+
y: false,
|
|
1151
|
+
delete: true,
|
|
1152
|
+
})),
|
|
1153
|
+
filter: everythingIdle,
|
|
1154
|
+
target: voteQuestionAnswerFx,
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
//================================================================================================================
|
|
1158
|
+
// FLAG QUESTION ANSWER
|
|
1159
|
+
//================================================================================================================
|
|
1160
|
+
const flagQuestionAnswer = createEvent();
|
|
1161
|
+
const flagQuestionAnswerDelete = createEvent();
|
|
1162
|
+
{
|
|
1163
|
+
const flagQuestionAnswerFx = createEffect(async (p) => {
|
|
1164
|
+
const resp = await request(config.graphql.flagQuestionAnswerMutation)({ shopID: p.config.shopID, questionAnswerID: p.questionAnswerID, delete: p.delete }, p.config.opts);
|
|
1165
|
+
if (resp.kind !== "data")
|
|
1166
|
+
return resp;
|
|
1167
|
+
return request(config.graphql.getQuestionQuery)({ shopID: p.config.shopID, questionID: p.questionID }, p.config.opts);
|
|
1168
|
+
});
|
|
1169
|
+
addPendingStore(flagQuestionAnswerFx.pending);
|
|
1170
|
+
const flagResult = requestResponseSplitFirst(flagQuestionAnswerFx.doneData);
|
|
1171
|
+
// success
|
|
1172
|
+
forward({
|
|
1173
|
+
from: msgFilter(flagQuestionAnswerFx.done, (p) => p.delete ? "question_answer_unflagged" : "question_answer_flagged"),
|
|
1174
|
+
to: message,
|
|
1175
|
+
});
|
|
1176
|
+
questions.on(flagResult.data, replaceQuestion);
|
|
1177
|
+
ownQuestions.on(flagResult.data, replaceQuestion);
|
|
1178
|
+
// failure
|
|
1179
|
+
forward({
|
|
1180
|
+
from: flagResult.error,
|
|
1181
|
+
to: unexpectedError,
|
|
1182
|
+
});
|
|
1183
|
+
guard({
|
|
1184
|
+
source: sample(configWithJWTAndLocale, flagQuestionAnswer, (config, [questionID, questionAnswerID]) => ({
|
|
1185
|
+
config,
|
|
1186
|
+
questionID,
|
|
1187
|
+
questionAnswerID,
|
|
1188
|
+
delete: false,
|
|
1189
|
+
})),
|
|
1190
|
+
filter: everythingIdle,
|
|
1191
|
+
target: flagQuestionAnswerFx,
|
|
1192
|
+
});
|
|
1193
|
+
guard({
|
|
1194
|
+
source: sample(configWithJWTAndLocale, flagQuestionAnswerDelete, (config, [questionID, questionAnswerID]) => ({
|
|
1195
|
+
config,
|
|
1196
|
+
questionID,
|
|
1197
|
+
questionAnswerID,
|
|
1198
|
+
delete: true,
|
|
1199
|
+
})),
|
|
1200
|
+
filter: everythingIdle,
|
|
1201
|
+
target: flagQuestionAnswerFx,
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
const somethingPending = combineSome(...pendingStores);
|
|
1205
|
+
const somethingPendingButImageUpload = combineSome(...pendingStoresButImageUpload);
|
|
1206
|
+
forward({
|
|
1207
|
+
from: somethingPending.map((v) => !v),
|
|
1208
|
+
to: everythingIdle,
|
|
1209
|
+
});
|
|
1210
|
+
forward({
|
|
1211
|
+
from: somethingPendingButImageUpload.map((v) => !v),
|
|
1212
|
+
to: everythingIdleButImageUpload,
|
|
1213
|
+
});
|
|
1214
|
+
forward({
|
|
1215
|
+
from: [setReviewsSortBy.map(() => "replace"), setReviewsSortDesc.map(() => "replace")],
|
|
1216
|
+
to: loadMoreReviewsGeneric,
|
|
1217
|
+
});
|
|
1218
|
+
forward({
|
|
1219
|
+
from: [setQuestionsSortBy.map(() => "replace"), setQuestionsSortDesc.map(() => "replace")],
|
|
1220
|
+
to: loadMoreQuestionsGeneric,
|
|
1221
|
+
});
|
|
1222
|
+
forward({
|
|
1223
|
+
from: loadMoreReviews.map(() => "append"),
|
|
1224
|
+
to: loadMoreReviewsGeneric,
|
|
1225
|
+
});
|
|
1226
|
+
forward({
|
|
1227
|
+
from: loadMoreQuestions.map(() => "append"),
|
|
1228
|
+
to: loadMoreQuestionsGeneric,
|
|
1229
|
+
});
|
|
1230
|
+
// a special event which is fired when user invokes some event which requires auth, but jwt is missing
|
|
1231
|
+
const signInRequired = createEvent();
|
|
1232
|
+
return {
|
|
1233
|
+
signInRequired,
|
|
1234
|
+
message,
|
|
1235
|
+
load,
|
|
1236
|
+
unexpectedError,
|
|
1237
|
+
product,
|
|
1238
|
+
images,
|
|
1239
|
+
reviews,
|
|
1240
|
+
reviewsSortBy,
|
|
1241
|
+
reviewsSortDesc,
|
|
1242
|
+
setReviewsSortBy,
|
|
1243
|
+
setReviewsSortDesc,
|
|
1244
|
+
questions,
|
|
1245
|
+
questionsSortBy,
|
|
1246
|
+
questionsSortDesc,
|
|
1247
|
+
setQuestionsSortBy,
|
|
1248
|
+
setQuestionsSortDesc,
|
|
1249
|
+
ownReview,
|
|
1250
|
+
ownQuestions,
|
|
1251
|
+
somethingPending,
|
|
1252
|
+
forms,
|
|
1253
|
+
voteReviewYes: wrapSignInRequired(config.jwt, signInRequired, voteReviewYes),
|
|
1254
|
+
voteReviewNo: wrapSignInRequired(config.jwt, signInRequired, voteReviewNo),
|
|
1255
|
+
voteReviewDelete: wrapSignInRequired(config.jwt, signInRequired, voteReviewDelete),
|
|
1256
|
+
flagReview: wrapSignInRequired(config.jwt, signInRequired, flagReview),
|
|
1257
|
+
flagReviewDelete: wrapSignInRequired(config.jwt, signInRequired, flagReviewDelete),
|
|
1258
|
+
voteQuestionYes: wrapSignInRequired(config.jwt, signInRequired, voteQuestionYes),
|
|
1259
|
+
voteQuestionNo: wrapSignInRequired(config.jwt, signInRequired, voteQuestionNo),
|
|
1260
|
+
voteQuestionDelete: wrapSignInRequired(config.jwt, signInRequired, voteQuestionDelete),
|
|
1261
|
+
flagQuestion: wrapSignInRequired(config.jwt, signInRequired, flagQuestion),
|
|
1262
|
+
flagQuestionDelete: wrapSignInRequired(config.jwt, signInRequired, flagQuestionDelete),
|
|
1263
|
+
deleteReview: wrapSignInRequired(config.jwt, signInRequired, deleteReview),
|
|
1264
|
+
deleteQuestion: wrapSignInRequired(config.jwt, signInRequired, deleteQuestion),
|
|
1265
|
+
deleteQuestionAnswer: wrapSignInRequired(config.jwt, signInRequired, deleteQuestionAnswer),
|
|
1266
|
+
voteQuestionAnswerYes: wrapSignInRequired(config.jwt, signInRequired, voteQuestionAnswerYes),
|
|
1267
|
+
voteQuestionAnswerNo: wrapSignInRequired(config.jwt, signInRequired, voteQuestionAnswerNo),
|
|
1268
|
+
voteQuestionAnswerDelete: wrapSignInRequired(config.jwt, signInRequired, voteQuestionAnswerDelete),
|
|
1269
|
+
flagQuestionAnswer: wrapSignInRequired(config.jwt, signInRequired, flagQuestionAnswer),
|
|
1270
|
+
flagQuestionAnswerDelete: wrapSignInRequired(config.jwt, signInRequired, flagQuestionAnswerDelete),
|
|
1271
|
+
totalReviews,
|
|
1272
|
+
totalQuestions,
|
|
1273
|
+
canLoadMoreReviews,
|
|
1274
|
+
canLoadMoreQuestions,
|
|
1275
|
+
loadMoreReviews,
|
|
1276
|
+
loadMoreQuestions,
|
|
1277
|
+
};
|
|
1278
|
+
}
|