id
stringlengths
12
53
messages
listlengths
3
3
code_store-on-localhost_0ee717e5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/header/index.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport Row from './components/Row'\nimport Spacer from './components/Spacer'\nimport Logo from '../StoreComponents/Logo'\nimport Menu from '../Menu/Menu'\nimport MenuItem from '../Menu/MenuItem'\nimport Submenu from '../Menu/Submenu'\nimport FlexCol from '../FlexLayout/Col'\nimport FlexRow from '../FlexLayout/FlexLayout'\nimport InfoCard from '../StoreComponents/InfoCard'\nimport Drawer from '../Drawer/Drawer'\nimport SearchBar from '../StoreComponents/SearchBar'\nimport LocaleSwitcher from '../LocaleSwitcher/LocaleSwitcher'\nimport Login from '../Login/Login'\nimport Minicart from '../Minicart/index'\nimport NotificationBar from '../StoreComponents/NotificationBar'\n// import MinicartBase from '../Minicart/BaseContent'\n// import ProductList from '../Minicart/ProductList'\n// import Sticky from '../Sticky'\n\nimport useDevice from '../DeviceDetector/useDevice'\n\n// import CustomHeader from './components/CustomHeader'\n\n// \"header-layout.desktop\": {\n// \"children\": [\n// \"header-row#1-desktop\",\n// \"header-row#2-desktop\",\n// \"header-row#3-desktop\",\n// \"header-row#4-desktop\"\n// ]\n// },\n\n// \"header-row#1-desktop\": {\n// \"children\": [\"telemarketing\"],\n// \"props\": {\n// \"fullWidth\": true\n// }\n// },\n\n// \"header-row#2-desktop\": {\n// \"children\": [\"notification.bar#home\"],\n// \"props\": {\n// \"fullWidth\": \"true\"\n// }\n// },\n// \"notification.bar#home\": {\n// \"props\": {\n// \"content\": \"SELECTED ITEMS ON SALE! CHECK IT OUT!\"\n// }\n// },\n// \"header-row#3-desktop\": {\n// \"children\": [\n// \"vtex.menu@2.x:menu#websites\",\n// \"header-spacer\",\n// \"vtex.menu@2.x:menu#institutional\"\n// ],\n// \"props\": {\n// \"blockClass\": \"menu-link\",\n// \"inverted\": \"true\"\n// }\n// },\n// \"header-row#4-desktop\": {\n// \"children\": [\n// \"logo#desktop\",\n// \"vtex.menu@2.x:menu#category-menu\",\n// \"header-spacer\",\n// \"header-spacer\",\n// \"search-bar\",\n// \"locale-switcher\",\n// \"login\",\n// \"minicart.v2\"\n// ],\n// \"props\": {\n// \"sticky\": true,\n// \"blockClass\": \"main-header\"\n// }\n// },\n// \"logo#desktop\": {\n// \"props\": {\n// \"title\": \"Logo\",\n// \"href\": \"/\",\n// \"url\": \"https://storecomponents.vteximg.com.br/arquivos/store-theme-logo.png\",\n// \"width\": \"180\"\n// }\n// },\n// \"header-layout.mobile\": {\n// \"children\": [\"header-row#1-mobile\"]\n// },\n// \"header-row#1-mobile\": {\n// \"children\": [\n// \"drawer\",\n// \"logo#mobile\",\n// \"header-spacer\",\n// \"login\",\n// \"minicart.v2\"\n// ],\n// \"props\": {\n// \"sticky\": true,\n// \"blockClass\": \"main-header-mobile\"\n// }\n// },\n// \"drawer\": {\n// \"children\": [\"menu#drawer\"]\n// },\n\n// \"menu#drawer\": {\n// \"children\": [\n// \"menu-item#category-apparel\",\n// \"menu-item#category-home\",\n// \"menu-item#more\"\n// ],\n// \"props\": {\n// \"orientation\": \"vertical\"\n// }\n// },\n\n// \"logo#mobile\": {\n// \"props\": {\n// \"title\": \"Logo\",\n// \"href\": \"/\",\n// \"url\": \"https://storecomponents.vteximg.com.br/arquivos/store-theme-logo-mobile.png\",\n// \"width\": \"70\"\n// }\n// }\n// }\n\n// \"minicart-base-content\": {\n// \"blocks\": [\"minicart-empty-state\"],\n// \"children\": [\"minicart-product-list\", \"sticky-layout#minicart-footer\"]\n// },\n\nconst CategoryMenu = () => (\n <MenuItem id=\"menu-item-category-apparel\" type=\"custom\" iconId={null} highlight={false} itemProps={{ type: \"internal\", href: \"/apparel---accessories/\", noFollow: false, tagTitle:\"Apparel & Accessories\", text:\"Apparel & Accessories\"}}>\n <Submenu width=\"auto\">\n <Menu orientation=\"vertical\">\n <MenuItem id=\"menu-item-category-apparel-clothing\" type=\"custom\" iconId={null} highlight={false} itemProps={{ type: \"internal\", href: \"/apparel---accessories/clothing/\", noFollow: false, tagTitle:\"Clothing\", text:\"Clothing\"}}/>\n <MenuItem id=\"menu-item-category-apparel-accessories\" type=\"custom\" iconId={null} highlight={false} itemProps={{ type: \"internal\", href: \"/apparel---accessories/accessories/\", noFollow: false, tagTitle:\"Accessories\", text:\"Accessories\"}}/>\n <MenuItem id=\"menu-item-category-apparel-eyeglasses\" type=\"custom\" iconId={null} highlight={false} itemProps={{ type: \"internal\", href: \"/apparel---accessories/eyeglasses/\", noFollow: false, tagTitle:\"Eyeglasses\", text:\"Eyeglasses\"}}/>\n </Menu>\n </Submenu>\n </MenuItem>\n)\n\nconst MenuMore = () => (\n <MenuItem id=\"menu-item-custom-sale\" type=\"custom\" iconId={null} highlight={false} itemProps={{ type: \"internal\", href: \"#\", noFollow: false, tagTitle:\"More\", text:\"More\"}}>\n <Submenu width=\"100%\">\n <FlexRow>\n <FlexCol>\n <Menu orientation=\"vertical\">\n <MenuItem id=\"menu-item-about-us\" type=\"custom\" iconId={null} highlight={false} itemProps={{ type: \"internal\", href: \"/about-us\", noFollow: false, tagTitle:\"About us\", text:\"About us\"}} />\n </Menu>\n </FlexCol>\n <FlexCol>\n <InfoCard id=\"info-card-home\" isFullModeStyle={false} textPosition=\"left\" imageUrl=\"https://storecomponents.vteximg.com.br/arquivos/banner-infocard2.png\" headline=\"Clearance Sale\" callToActionText=\"DISCOVER\" callToActionUrl=\"/sale/d\" blockClass=\"info-card-home\" textAlignment=\"center\" />\n </FlexCol>\n </FlexRow>\n </Submenu>\n </MenuItem>\n)\n\nconst DesktopHeader = () => {\n return (\n <div>\n <Row fullWidth>\n <NotificationBar content=\"SELECTED ITEMS ON SALE! CHECK IT OUT!\" />\n </Row>\n <Row blockClass=\"menu-link\" inverted>\n <Menu>\n <MenuItem id=\"menu-item-shop\" type=\"custom\" iconId={null} highlight={false} itemProps={{ type: \"internal\", href: \"#\", noFollow: false, tagTitle:\"Shop\", text:\"Shop\"}} />\n <MenuItem id=\"menu-item-about-us\" type=\"custom\" iconId={null} highlight={false} itemProps={{ type: \"internal\", href: \"/about-us\", noFollow: false, tagTitle:\"about-us\", text:\"About Us\"}} />\n </Menu>\n <Spacer />\n <Menu>\n <MenuItem id=\"menu-item-vtex-website\" type=\"custom\" iconId={null} highlight={false} itemProps={{ type: \"external\", href: \"http://vtex.com\", noFollow: false, tagTitle:\"visit vtex.com\", text:\"visit vtex.com\"}} />\n </Menu>\n </Row>\n <Row blockClass=\"main-header\" sticky>\n <Logo title=\"Logo\" href=\"/\" url=\"https://storecomponents.vteximg.com.br/arquivos/store-theme-logo.png\" width=\"180\" />\n <Menu>\n <CategoryMenu />\n <MenuItem id=\"menu-item-category-home\" type=\"custom\" iconId={null} highlight={false} itemProps={{ type: \"internal\", href: \"/home---decor/\", noFollow: false, tagTitle:\"Home & Decor\", text:\"Home & Decor\"}}/>\n <MenuMore />\n </Menu>\n <Spacer />\n <Spacer />\n <SearchBar />\n <LocaleSwitcher />\n <Login />\n <Minicart type=\"popup\" showRemoveButton showDiscount showSku labelMiniCartEmpty=\"\" labelButtonFinishShopping=\"Go to checkout\" enableQuantitySelector maxQuantity={10} labelClasses=\"gray\" productSummaryProps={{}}/>\n </Row>\n </div>\n ) \n}\n\nconst MobileHeader = () => {\n return (\n <Row blockClass=\"main-header-mobile\" sticky>\n <Drawer>\n <CategoryMenu />\n <MenuItem id=\"menu-item-category-home\" type=\"custom\" iconId={null} highlight={false} itemProps={{ type: \"internal\", href: \"/home---decor/\", noFollow: false, tagTitle:\"Home & Decor\", text:\"Home & Decor\"}}/>\n <MenuMore />\n </Drawer>\n <Logo title=\"Logo\" href=\"/\" url=\"https://storecomponents.vteximg.com.br/arquivos/store-theme-logo-mobile.png\" width=\"70\" />\n <Spacer />\n <Login />\n <Minicart type=\"popup\" showRemoveButton showDiscount showSku labelMiniCartEmpty=\"\" labelButtonFinishShopping=\"Go to checkout\" enableQuantitySelector maxQuantity={10} labelClasses=\"gray\" productSummaryProps={{}}/>\n </Row>\n )\n}\n\nconst Header = () => {\n const { isMobile } = useDevice()\n return isMobile ? <MobileHeader/> : <DesktopHeader />\n}\n\n// Header.schema = LegacyHeader.schema\n\nexport default Header\n\n```" } ]
code_store-on-localhost_1d79df73
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/header/Row.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport Row from './components/Row'\n\nexport default Row\n\n```" } ]
code_store-on-localhost_8eb975ca
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/header/Border.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport Border from './components/Border'\n\nexport default Border\n\n```" } ]
code_store-on-localhost_c89f1724
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummaryContext/ProductSummaryContext.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useReducer } from 'react'\nimport { createContext, useContext } from 'react'\n\nconst ProductSummaryContext = createContext<State | undefined>(undefined)\nconst ProductDispatchContext = createContext<Dispatch | undefined>(undefined)\n\ninterface State {\n product: any\n isHovering: boolean\n isLoading: boolean\n selectedItem: any,\n selectedQuantity: number,\n productQuery?: string,\n}\n\ntype Dispatch = (action: Action) => void\n\ntype SetProductAction = {\n type: 'SET_PRODUCT',\n args: {\n product: any\n }\n}\n\ntype SetProductQueryAction = {\n type: 'SET_PRODUCT_QUERY',\n args: {\n query: string\n }\n}\n\ntype SetHoverAction = {\n type: 'SET_HOVER'\n args: {\n isHovering: boolean\n }\n}\n\ntype SetLoadingAction = {\n type: 'SET_LOADING'\n args: {\n isLoading: boolean\n }\n}\n\ntype SetProductQuantity = {\n type: 'SET_QUANTITY'\n args: {\n quantity: number\n }\n}\n\ntype Action = SetProductAction | SetHoverAction | SetLoadingAction | SetProductQuantity | SetProductQueryAction\n\nexport function reducer(state: State, action: Action) {\n switch (action.type) {\n case 'SET_PRODUCT': {\n const product = action.args.product\n return {\n ...state,\n product: product,\n //TODO: STOP USING PRODUCT.SKU https://app.clubhouse.io/vtex/story/18547/productsummarycontext-refactor\n selectedItem: product.sku\n }\n }\n case 'SET_HOVER': {\n return {\n ...state,\n isHovering: action.args.isHovering\n }\n }\n case 'SET_LOADING': {\n return {\n ...state,\n isLoading: action.args.isLoading\n }\n }\n case 'SET_QUANTITY': {\n return {\n ...state,\n selectedQuantity: action.args.quantity,\n }\n }\n case 'SET_PRODUCT_QUERY':\n return {\n ...state,\n query: action.args.query,\n }\n default:\n return state\n }\n}\n\nfunction ProductSummaryProvider({ product, children }) {\n const initialState = {\n product,\n isHovering: false,\n isLoading: false,\n selectedItem: null,\n selectedQuantity: 1,\n }\n\n const [state, dispatch] = useReducer(reducer, initialState)\n\n return (\n <ProductSummaryContext.Provider value={state}>\n <ProductDispatchContext.Provider value={dispatch}>\n {children}\n </ProductDispatchContext.Provider>\n </ProductSummaryContext.Provider>\n )\n}\n\nfunction useProductSummaryDispatch() {\n const context = useContext(ProductDispatchContext)\n\n if (context === undefined) {\n throw new Error('useProductSummaryDispatch must be used within a ProductSummaryDispatchProvider')\n }\n\n return context\n}\n\nfunction useProductSummary() {\n const context = useContext(ProductSummaryContext)\n\n if (context === undefined) {\n throw new Error('useProductSummary must be used within a ProductSummaryProvider')\n }\n\n return context\n}\n\nexport default {\n ProductSummaryProvider,\n useProductSummary,\n useProductSummaryDispatch,\n}\n```" } ]
code_store-on-localhost_5ae82d79
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreResources/Mutations.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport { loader } from 'graphql.macro'\n\nconst addToCart = loader('./mutations/addToCart.gql')\nconst updateItems = loader('./mutations/updateItems.gql')\nconst updateOrderFormProfile = loader('./mutations/updateOrderFormProfile.gql')\nconst updateOrderFormShipping = loader('./mutations/updateOrderFormShipping.gql')\nconst updateOrderFormCheckin = loader('./mutations/updateOrderFormCheckin.gql')\n\nexport default {\n addToCart,\n updateItems,\n updateOrderFormProfile,\n updateOrderFormShipping,\n updateOrderFormCheckin,\n}\n\n```" } ]
code_store-on-localhost_dc03652a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreResources/OrderFormContext.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component, useContext } from 'react'\nimport hoistNonReactStatics from 'hoist-non-react-statics'\nimport PropTypes from 'prop-types'\n\nconst OrderFormContext = React.createContext({})\nconst { Provider } = OrderFormContext\n\nfunction orderFormConsumer(WrappedComponent) {\n const WithOrderForm = (props) => {\n const { orderFormContext } = useContext(OrderFormContext)\n return <WrappedComponent {...props} orderFormContext={orderFormContext} />\n }\n WithOrderForm.displayName = `OrderFormContext(${Component.displayName ||\n Component.name ||\n 'Component'})`\n WithOrderForm.WrappedComponent = WrappedComponent\n \n return hoistNonReactStatics(\n WithOrderForm,\n WrappedComponent\n )\n}\n\nconst useOrderForm = () => {\n const context = useContext(OrderFormContext)\n\n return context.orderFormContext\n}\n\nconst contextPropTypes = PropTypes.shape({\n /* Toast message that will be displayed */\n\n message: PropTypes.shape({\n isSuccess: PropTypes.bool,\n message: PropTypes.string,\n }).isRequired,\n /* Is information still loading*/\n\n loading: PropTypes.bool.isRequired,\n /* Function to refetch the orderForm query */\n\n refetch: PropTypes.func.isRequired,\n /* Function to add a new item into the orderForm */\n\n addItem: PropTypes.func.isRequired,\n /* Function to update the orderForm */\n\n updateOrderForm: PropTypes.func.isRequired,\n /* Function to update the orderForm profile data*/\n\n updateOrderFormProfile: PropTypes.func.isRequired,\n /* Function to update the orderForm and refetch the data*/\n\n updateAndRefetchOrderForm: PropTypes.func.isRequired,\n /* Function to update the message */\n\n updateToastMessage: PropTypes.func.isRequired,\n /* Function to update the shipping data */\n\n updateOrderFormShipping: PropTypes.func.isRequired,\n /* Order form */\n\n orderForm: PropTypes.shape({\n /* Order form id */\n\n orderFormId: PropTypes.string,\n /* Total price of the order */\n\n value: PropTypes.number,\n /* Items in the mini cart */\n\n items: PropTypes.arrayOf(PropTypes.object),\n /* CustomData in the OrderForm */\n\n customData: PropTypes.shape({\n customApps: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.string,\n fields: PropTypes.object\n })\n )\n }),\n /* Shipping Address */\n\n shippingData: PropTypes.shape({\n address: PropTypes.shape({\n addressName: PropTypes.string,\n addressType: PropTypes.string,\n city: PropTypes.string,\n complement: PropTypes.string,\n country: PropTypes.string,\n id: PropTypes.string,\n neighborhood: PropTypes.string,\n number: PropTypes.string,\n postalCode: PropTypes.string,\n receiverName: PropTypes.string,\n reference: PropTypes.string,\n state: PropTypes.string,\n street: PropTypes.string,\n userId: PropTypes.string,\n }),\n /* Available Addresses */\n\n availableAddresses: PropTypes.arrayOf(PropTypes.object),\n }),\n }),\n}).isRequired\n\nexport default {\n orderFormConsumer,\n contextPropTypes,\n Provider,\n useOrderForm,\n}\n\n```" } ]
code_store-on-localhost_5a3615d1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreResources/package.json from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"devDependencies\": {\n \"prop-types\": \"^15.6.2\",\n \"react\": \"^16.6.3\"\n },\n \"dependencies\": {\n \"hoist-non-react-statics\": \"^3.3.0\",\n \"react-apollo\": \"^2.5.8\"\n },\n \"version\": \"0.44.0\"\n}\n\n```" } ]
code_store-on-localhost_098bde2d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreResources/PWAContext.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\n/* eslint-disable react-hooks/exhaustive-deps */\nimport { loader } from 'graphql.macro'\nimport React, {\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport { useQuery } from 'react-apollo'\nimport { Helmet } from 'react-helmet'\n\nimport { usePixel } from '../PixelContext/PixelContext'\n\nconst pwaData = loader('./queries/pwaData.gql')\n\nconst PWAContext = React.createContext(null)\n\nconst PWAProvider = ({ rootPath, children }) => {\n const { data, loading, error } = useQuery(pwaData, { ssr: false })\n const { manifest, iOSIcons, splashes, pwaSettings } = data || {}\n const { push } = usePixel()\n\n const deferredPrompt = useRef(null)\n /* beforeinstallprompt event is fired even after the userChoice is to cancel (and there is no need to re-render) */\n const captured = useRef(false)\n\n const [alreadyInstalled, setAlreadyInstalled] = useState(false)\n const [installDismissed, setInstallDismissed] = useState(false)\n\n\n useEffect(() => {\n const handleBeforeInstall = e => {\n const { promptOnCustomEvent, disablePrompt } = pwaSettings\n if (promptOnCustomEvent !== 'default' && !captured.current) {\n e.preventDefault()\n\n if (disablePrompt) {\n return false\n }\n\n deferredPrompt.current = e\n captured.current = true\n return false\n }\n return true\n }\n\n window.addEventListener('beforeinstallprompt', handleBeforeInstall)\n return () =>\n window.removeEventListener('beforeinstallprompt', handleBeforeInstall)\n }, [captured, pwaSettings])\n\n useEffect( () => {\n const webAppInstalled = localStorage.getItem('webAppInstalled')\n if (webAppInstalled) {\n setAlreadyInstalled(webAppInstalled)\n }\n const webAppInstallDismissed = localStorage.getItem('webAppInstallDismissed')\n if (webAppInstallDismissed) {\n setInstallDismissed(webAppInstallDismissed)\n }\n }, [])\n\n const showInstallPrompt = useCallback(() => {\n const prompt = deferredPrompt.current\n if (prompt) {\n prompt.prompt()\n prompt.userChoice.then(choiceResult => {\n if (choiceResult.outcome === 'accepted') {\n localStorage.setItem('webAppInstalled', 'true')\n } else {\n localStorage.setItem('webAppInstallDismissed', 'true')\n }\n push({\n event: 'installWebApp',\n userChoice: choiceResult.outcome\n })\n deferredPrompt.current = null\n })\n }\n }, [])\n\n const context = useMemo( () => {\n if (pwaSettings) {\n const { disablePrompt, promptOnCustomEvent } = pwaSettings\n /* browsers for ios devices doesn't support install prompt */\n const isIOS = navigator && !!navigator.userAgent.match(/(iPod|iPhone|iPad)/)\n\n return {\n showInstallPrompt,\n settings: {\n promptOnCustomEvent: (disablePrompt || isIOS || installDismissed || alreadyInstalled) ? '' \n : promptOnCustomEvent\n }\n }\n }\n }, [showInstallPrompt, pwaSettings, alreadyInstalled])\n\n const hasManifest = !loading && manifest && !error\n\n return (\n <PWAContext.Provider value={context}>\n {hasManifest && (\n <Helmet\n meta={[\n { name: 'theme-color', content: manifest.theme_color },\n { name: 'apple-mobile-web-app-capable', content: 'yes' },\n ]}\n link={[\n {\n rel: 'manifest',\n href: `${rootPath}/pwa/manifest.json`,\n },\n ...(iOSIcons\n ? iOSIcons.map(icon => ({\n rel: 'apple-touch-icon',\n sizes: icon.sizes,\n href: `${rootPath}${icon.src}`,\n }))\n : []),\n ...(splashes\n ? splashes.map(splash => ({\n href: `${rootPath}${splash.src}`,\n sizes: splash.sizes,\n rel: 'apple-touch-startup-image',\n }))\n : []),\n ].filter(Boolean)}\n />\n )}\n {children}\n </PWAContext.Provider>\n )\n}\n\nconst usePWA = () => {\n return useContext(PWAContext)\n}\n\nexport default { PWAContext, PWAProvider, usePWA }\n\n```" } ]
code_store-on-localhost_9159176a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreResources/Queries.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport { loader } from 'graphql.macro'\n\nconst orderForm = loader('./queries/orderForm.gql')\nconst product = loader('./queries/product.gql')\nconst productPreviewFragment = loader('./queries/productPreview.gql')\nconst recommendationsAndBenefits = loader('./queries/recommendationsAndBenefits.gql')\nconst search = loader('./queries/search.gql')\nconst productSearch = loader('./queries/productSearch.gql')\nconst productSearchV2 = loader('./queries/productSearchV2.gql')\nconst session = loader('./queries/session.gql')\nconst productBenefits = loader('./queries/productBenefits.gql')\nconst address = loader('./queries/address.gql')\nconst searchMetadata = loader('./queries/searchMetadata.gql')\nconst productCategoryTree = loader('./queries/UNSTABLE__productCategoryTree.gql')\nconst facets = loader('./queries/facets.gql')\n\nexport default {\n address,\n orderForm,\n product,\n productSearch,\n productSearchV2,\n productPreviewFragment,\n recommendationsAndBenefits,\n search,\n session,\n productBenefits,\n UNSTABLE__productCategoryTree: productCategoryTree,\n searchMetadata,\n facets,\n}\n\n```" } ]
code_store-on-localhost_2a305fba
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/FormatCurrency/typings/storefront.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { FunctionComponent } from 'react'\n\ndeclare global {\n interface StorefrontFunctionComponent<P = {}> extends FunctionComponent<P> {\n getSchema?(props: P): object\n schema?: object\n }\n\n interface StorefrontComponent<P = {}, S = {}> extends Component<P, S> {\n getSchema?(props: P): object\n schema: object\n }\n}\n\n```" } ]
code_store-on-localhost_72c5f92f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/FormatCurrency/typings/vtex.render-runtime.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.render-runtime' {\n interface RuntimeContext {\n culture: {\n currency: string\n customCurrencyDecimalDigits?: number | null\n customCurrencySymbol?: string | null\n }\n }\n\n export const useRuntime = () => RuntimeContext\n}\n\n```" } ]
code_store-on-localhost_180f23b9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/FormatCurrency/typings/graphql.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.graphql' {\n import { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\n```" } ]
code_store-on-localhost_d6740479
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/FormatCurrency/typings/vtex.styleguide.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.styleguide' {\n import { ComponentType } from 'react'\n\n export const Input: ComponentType<InputProps>\n\n interface InputProps {\n [key: string]: any\n }\n}\n\n```" } ]
code_store-on-localhost_52901d11
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/FormatCurrency/__tests__/FormattedCurrency.test.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { render } from '@vtex/test-tools/react'\nimport FormattedCurrency from '../FormattedCurrency'\nimport { useRuntime, RuntimeContext } from '../../../../../vtex.render-runtime'\n\nconst mockedUseRuntime = useRuntime as jest.Mock<RuntimeContext>\n\ntest('Use currencyCode as default format', () => {\n mockedUseRuntime.mockImplementation(() => ({\n culture: {\n currency: 'USD',\n customCurrencyDecimalDigits: null,\n customCurrencySymbol: null,\n },\n }))\n\n const { getByText, rerender } = render(<FormattedCurrency value={10} />)\n\n getByText('$10.00')\n\n mockedUseRuntime.mockImplementation(() => ({\n culture: {\n currency: 'BRL',\n customCurrencyDecimalDigits: null,\n customCurrencySymbol: null,\n },\n }))\n\n rerender(<FormattedCurrency value={10} />)\n\n getByText('R$10.00')\n})\n\ntest('should use custom decimal digits', () => {\n mockedUseRuntime.mockImplementation(() => ({\n culture: {\n currency: 'BRL',\n customCurrencyDecimalDigits: 0,\n customCurrencySymbol: null,\n },\n }))\n\n const { getByText } = render(<FormattedCurrency value={10} />)\n\n getByText('R$10')\n})\n\n```" } ]
code_store-on-localhost_b67575d5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StackLayout/typings/vtex.css-handles.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.css-handles' {\n type CssHandlesInput = readonly string[]\n type ValueOf<T extends readonly any[]> = T[number]\n type CssHandles<T extends CssHandlesInput> = Record<ValueOf<T>, string>\n interface CssHandlesOptions {\n migrationFrom?: string | string[]\n }\n\n export const useCssHandles: <T extends CssHandlesInput>(\n handles: T,\n options: CssHandlesOptions = {}\n ) => CssHandles<T>\n export const applyModifiers: (\n handles: string,\n modifier: string | string[]\n ) => string\n}\n\n```" } ]
code_store-on-localhost_f2d0a16c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StackLayout/typings/global.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { FunctionComponent } from 'react'\nimport { TachyonsScaleInput } from '../hooks/tachyons'\n\ndeclare global {\n interface StorefrontFunctionComponent<P = {}> extends FunctionComponent<P> {\n schema?: object\n getSchema?(props?: P): object\n }\n\n interface StorefrontComponent<P = {}, S = {}> extends Component<P, S> {\n schema?: object\n getSchema?(props: P): object\n }\n\n interface StorefrontElement extends ReactElement {\n schema?: object\n getSchema?(props: P): object\n }\n}\n\n```" } ]
code_store-on-localhost_1de0d8e9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Drawer/modules/getPointerPosition.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nfunction isMouseEvent(event: TouchEvent | MouseEvent): event is MouseEvent {\n return !!(event as MouseEvent).clientX\n}\n\nfunction isTouchEvent(event: TouchEvent | MouseEvent): event is TouchEvent {\n const touches = (event as TouchEvent).touches\n if (!touches) return false\n return touches.length > 0\n}\n\nexport default function getPointerPosition(event: TouchEvent | MouseEvent) {\n if (isMouseEvent(event)) {\n return {\n x: event.clientX,\n y: event.clientY,\n source: 'mouse',\n timeStamp: event.timeStamp,\n }\n }\n\n if (!isTouchEvent(event)) {\n return null\n }\n\n const touch = event.touches[0]\n\n return {\n x: touch.clientX,\n y: touch.clientY,\n source: 'touch',\n timeStamp: event.timeStamp,\n }\n}\n\n```" } ]
code_store-on-localhost_ef7a0ed2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Drawer/modules/animation.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport parseMeasure from './parseMeasure'\n\nconst animations = []\n\nconst createAnimation = ({ object, prop, stop, isStopped }) => ({\n object,\n prop,\n stop,\n isStopped,\n})\n\nconst stopConflictingAnimations = animation =>\n animations.filter(cur => {\n const isConflicting =\n cur.object === animation.object && cur.prop === animation.prop\n if (isConflicting) {\n cur.stop()\n }\n return !cur.isStopped()\n })\n\nfunction animate({\n object,\n prop,\n target,\n duration,\n speed,\n acceleration,\n maxSpeed,\n onUpdate = null,\n onComplete = null,\n}) {\n const targetFps = 60\n const frameDuration = 1000 / targetFps\n\n const [targetValue, targetUnit, isTargetUnitless] = parseMeasure(target)\n const [originValue, originUnit] = parseMeasure(object[prop])\n const unit = isTargetUnitless ? originUnit : targetUnit\n const delta = targetValue - originValue\n\n const ease = v => v * (2 - v)\n const maxTimeMultiplier = 2\n\n let stopped = false\n\n const stop = () => {\n stopped = true\n }\n const isStopped = () => {\n return stopped\n }\n\n let current = duration ? 0 : originValue\n let last = null\n\n const update = now => {\n if (stopped) return\n let timeMultiplier = 1\n if (last != null) {\n const deltaTime = now - last\n timeMultiplier = deltaTime / frameDuration\n if (timeMultiplier > maxTimeMultiplier) timeMultiplier = maxTimeMultiplier\n }\n last = now\n\n if (duration) {\n const step = frameDuration / (duration * 1000)\n current += step * timeMultiplier\n if (current >= 1) {\n current = 1\n if (onComplete != null) {\n onComplete()\n }\n stop()\n }\n\n const value = `${originValue + ease(current) * delta}${unit}`\n\n object[prop] = value\n\n if (onUpdate != null) {\n onUpdate(value)\n }\n } else if (speed) {\n current += speed / (targetFps * timeMultiplier)\n\n if (acceleration) {\n speed *= acceleration\n }\n\n if (maxSpeed && speed > maxSpeed) {\n speed = maxSpeed\n }\n\n if (\n (speed > 0 && current >= targetValue) ||\n (speed < 0 && current <= targetValue)\n ) {\n current = targetValue\n if (onComplete != null) {\n onComplete()\n }\n stop()\n }\n const formattedValue = `${current}${unit}`\n object[prop] = formattedValue\n\n if (onUpdate != null) {\n onUpdate(formattedValue)\n }\n }\n\n requestAnimationFrame(update)\n }\n update()\n\n const animation = createAnimation({ object, prop, stop, isStopped })\n stopConflictingAnimations(animation)\n\n animations.push(animation)\n\n return stop\n}\n\nexport { animate }\n\n```" } ]
code_store-on-localhost_6c7c5f37
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Drawer/modules/parseMeasure.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\ntype Measure = number | string\n\ntype Value = number\ntype Unit = string\ntype IsUnitless = boolean\n\ntype ParsedMeasure = [Value, Unit, IsUnitless]\n\nfunction parseMeasure(value: Measure): ParsedMeasure | null {\n if (typeof value === 'number') {\n return [value, 'px', true]\n }\n const matchResult = value.match(/([-\\d]*)([^0-9\\n]+)/)\n if (!matchResult) {\n return null\n }\n const parsedValue = matchResult[1]\n const parsedUnit = matchResult[2]\n\n return [parseInt(parsedValue), parsedUnit, false]\n}\n\nexport default parseMeasure\n\n```" } ]
code_store-on-localhost_0a5d7eb6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Drawer/modules/useLockScroll.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { useRef, useState, useEffect } from 'react'\nimport styles from '../styles.css'\n\n// https://stackoverflow.com/a/3464890/5313009\nconst getScrollPosition = () => {\n const documentElement =\n window && window.document && window.document.documentElement\n if (!documentElement) {\n return 0\n }\n return (\n (window.pageYOffset || documentElement.scrollTop) -\n (documentElement.clientTop || 0)\n )\n}\n\nconst propertiesNames = ['top', 'width'] as const\n\ninterface PropertyStyle {\n name: keyof CSSStyleDeclaration\n value: string\n}\n\nconst useLockScroll = () => {\n const initialized = useRef(false)\n const [isLocked, setLocked] = useState(false)\n type ScrollPosition = number | null\n const [lockedScrollPosition, setLockedScrollPosition] = useState<\n ScrollPosition\n >(null)\n\n useEffect(() => {\n if (!initialized.current && !isLocked) {\n // Prevent this from running at first, if it's not locked.\n // Important because this triggers re-layout, thus slowing\n // down the rendering unnecessarily.\n initialized.current = true\n return\n }\n /** Locks scroll of the root HTML element if the\n * drawer menu is open\n */\n const shouldLockScroll = isLocked\n\n if (window && window.document) {\n const bodyBounds = document.body.getBoundingClientRect()\n\n /** iOS doesn't lock the scroll of the body by just setting overflow to hidden.\n * It requires setting the position of the HTML element to fixed, which also\n * resets the scroll position.\n * This code is intended to record the scroll position and set it as\n * the element's position, and revert it once the menu is closed.\n */\n const scrollPosition =\n lockedScrollPosition == null\n ? getScrollPosition()\n : lockedScrollPosition\n\n if (lockedScrollPosition == null && shouldLockScroll) {\n setLockedScrollPosition(scrollPosition)\n }\n\n if (lockedScrollPosition != null && !shouldLockScroll) {\n window && window.scrollTo(0, scrollPosition)\n setLockedScrollPosition(null)\n }\n\n const properties: PropertyStyle[] = [\n {\n name: 'top',\n value: `-${scrollPosition}px`,\n },\n {\n name: 'width',\n value: `${bodyBounds.width}px`,\n },\n ]\n\n if (shouldLockScroll) {\n properties.forEach(prop => {\n window.document.body.style[prop.name as any] = prop.value\n })\n\n window.document.body.classList.add(styles.hiddenBody)\n } else {\n properties.forEach(prop => {\n window.document.body.style.removeProperty(prop.name as any)\n })\n window.document.body.classList.remove(styles.hiddenBody)\n }\n }\n\n return () => {\n propertiesNames.forEach(prop => {\n window.document.body.style.removeProperty(prop)\n })\n window.document.body.classList.remove(styles.hiddenBody)\n }\n }, [isLocked]) // eslint-disable-line react-hooks/exhaustive-deps\n // ☝️ no need to trigger this on lockedScrollPosition changes\n\n return setLocked\n}\n\nexport default useLockScroll\n\n```" } ]
code_store-on-localhost_b79af45a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/typings/vtex.store-components.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.store-components' {\n import { ComponentType, ReactElement } from 'react'\n\n declare const Container: ComponentType<ContainerProps>\n\n interface ContainerProps {\n className: string\n }\n}\n\n```" } ]
code_store-on-localhost_8e82de41
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/typings/vtex.render-runtime.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* Typings for `render-runtime` */\ndeclare module 'vtex.render-runtime' {\n import { Component, ComponentType, ReactElement, ReactType } from 'react'\n\n export interface NavigationOptions {\n page: string\n params?: any\n }\n\n export interface RenderContextProps {\n runtime: {\n navigate: (options: NavigationOptions) => void\n }\n }\n\n interface ExtensionPointProps {\n id: string\n key: Record<string, any>\n }\n\n interface Pages {\n [name: string]: Page\n }\n\n interface Route {\n domain: string\n blockId: string\n canonicalPath?: string\n id: string\n params: Record<string, string>\n path: string\n title?: string\n }\n\n interface Culture {\n availableLocales: string[]\n locale: string\n language: string\n country: string\n currency: string\n }\n\n export interface RenderRuntime {\n account: string\n accountId: string\n appsEtag: string\n workspace: string\n disableSSR: boolean\n hints: {\n desktop: boolean\n mobile: boolean\n phone: boolean\n tablet: boolean\n }\n page: string\n route: Route\n version: string\n culture: Culture\n pages: Pages\n preview: boolean\n production: boolean\n publicEndpoint: string\n renderMajor: number\n query?: Record<string, string>\n start: boolean\n runtimeMeta: {\n version: string\n config?: any\n }\n settings: {\n app: Record<string, any>\n }\n segmentToken: string\n rootPath?: string\n workspaceCookie: string\n hasNewExtensions: boolean\n platform: string\n }\n\n export const ExtensionPoint: ComponentType<ExtensionPointProps>\n\n interface ChildBlockProps {\n id: string\n }\n\n export const ChildBlock: ComponentType<ChildBlockProps>\n export const useChildBlock = function({ id: string }): object {}\n\n export const Helmet: ReactElement\n export const Link: ReactType\n export const NoSSR: ReactElement\n export const RenderContextConsumer: ReactElement\n export const canUseDOM: boolean\n export const useRuntime: () => RenderRuntime\n export const withRuntimeContext: <TOriginalProps extends {}>(\n Component: ComponentType<TOriginalProps & RenderContextProps>\n ) => ComponentType<TOriginalProps>\n}\n\n```" } ]
code_store-on-localhost_413d70a8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/typings/vtex.native-types.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.native-types' {\n import { ComponentType } from 'react'\n import { InjectedIntl } from 'react-intl'\n\n export const IOMessage: ComponentType<{ id: string }>\n\n interface Options {\n intl: InjectedIntl\n id: string\n }\n\n export const formatIOMessage: (options: Options) => string\n}\n\n```" } ]
code_store-on-localhost_1ba2b71f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/typings/global.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { FunctionComponent, ReactElement } from 'react'\n\ndeclare global {\n interface StorefrontFunctionComponent<P = {}> extends FunctionComponent<P> {\n getSchema?(props: P): object\n schema?: object\n }\n\n interface StorefrontComponent<P = {}, S = {}> extends Component<P, S> {\n getSchema?(props: P): object\n schema: object\n }\n\n interface StorefrontElement extends ReactElement {\n getSchema?(props: P): object\n schema: object\n }\n}\n\n```" } ]
code_store-on-localhost_69271ce5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/typings/css.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const css: any\n export default css\n}\n\n```" } ]
code_store-on-localhost_3a329713
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/typings/graphql.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.graphql' {\n import { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\n```" } ]
code_store-on-localhost_d88b4224
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/legacy/Footer.test.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport { render } from '@vtex/test-tools/react'\n\nimport Footer from './Footer'\n\ndescribe('<Footer /> component', () => {\n const renderComponent = customProps => {\n const props = {\n socialNetworks: [\n {\n url: 'https://www.facebook.com/',\n socialNetwork: 'Facebook',\n },\n ],\n sectionLinks: [\n {\n title: 'Section title',\n links: [{ url: 'mockedUrl', title: 'Some title' }],\n },\n ],\n badges: [{ image: 'imageURL' }],\n paymentForms: [\n {\n title: 'Title payment',\n paymentTypes: ['MasterCard', 'Visa', 'Diners Club'],\n },\n ],\n showPaymentFormsInColor: true,\n showSocialNetworksInColor: true,\n showVtexLogoInColor: true,\n logo: 'logoUrl',\n ...customProps,\n }\n\n return render(<Footer {...props} />)\n }\n\n it('should be rendered', () => {\n const { asFragment } = renderComponent()\n expect(asFragment()).toBeDefined()\n })\n\n it('should match the snapshot', () => {\n const { asFragment } = renderComponent()\n expect(asFragment()).toMatchSnapshot()\n })\n\n it('should contain the section links', () => {\n const sectionLinks = [\n {\n title: 'We have one section title',\n links: [\n { url: 'someUrl', title: 'someTitle' },\n { url: 'anotherUrl', title: 'anotherTitle' },\n ],\n },\n {\n title: 'We have two section titles',\n links: [{ url: 'yetAnotherUrl', title: 'yetAnotherUrl' }],\n },\n ]\n\n const { getByText } = renderComponent({ sectionLinks })\n\n sectionLinks.forEach(({ title, links }) => {\n expect(getByText(title)).toBeTruthy()\n\n links.forEach(({ title }) => {\n expect(getByText(title)).toBeTruthy()\n })\n })\n })\n\n it('should contain the payment forms', () => {\n const paymentForms = [\n {\n title: 'Credit',\n paymentTypes: ['MasterCard', 'Visa', 'Diners Club'],\n },\n {\n title: 'Debit',\n paymentTypes: ['MasterCard', 'Visa'],\n },\n ]\n\n const { getByText } = renderComponent({ paymentForms })\n\n paymentForms.forEach(({ title }) => {\n expect(getByText(title)).toBeTruthy()\n })\n })\n})\n\n```" } ]
code_store-on-localhost_0a831d38
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/legacy/FooterVtexLogo.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport classNames from 'classnames'\nimport { withRuntimeContext } from '../../../../../vtex.render-runtime'\nimport { PLATFORM_GOCOMMERCE } from '../modules/platformCode'\nimport withImage from '../components/withImage'\nimport footer from './footer.css'\n\n/**\n * \"Powered By Vtex\" image's component, used in Footer\n */\nconst FooterVtexLogo = ({ runtime, logoUrl, imageSrc }) => {\n if (!imageSrc) {\n return null\n }\n\n const isPlatformGCResult = runtime.platform === PLATFORM_GOCOMMERCE\n const vtexLogoItemClasses = classNames(footer.vtexLogoItem, {\n w4: isPlatformGCResult,\n 'h3 w3': !isPlatformGCResult,\n })\n\n return (\n <div\n className={`${footer.badgeList} flex flex-row justify-center pv4-s pa0-ns items-center ml-auto-m`}\n >\n {logoUrl && (\n <span className={`${footer.badge} pa2-s pa1-ns`}>\n <img\n className={`${footer.logoImage} h3`}\n alt={runtime.platform}\n src={logoUrl}\n />\n </span>\n )}\n <span className={`${footer.badge} pa2-s pa1-ns nt7-ns`}>\n <img\n className={vtexLogoItemClasses}\n alt={runtime.platform}\n src={imageSrc}\n />\n </span>\n </div>\n )\n}\n\nFooterVtexLogo.displayName = 'FooterVtexLogo'\n\nFooterVtexLogo.propTypes = {\n /** Get the account name to find the correct platfom */\n runtime: PropTypes.shape({\n account: PropTypes.string.isRequired,\n platform: PropTypes.string.isRequired,\n }).isRequired,\n /** If true, the original logo (with color) is used. If not, the grayscale's one */\n showInColor: PropTypes.bool,\n /** The source for an external customizable logo to show above \"Powered By Vtex\" */\n logoUrl: PropTypes.string,\n imageSrc: PropTypes.string,\n}\n\nconst getImagePathFromProps = ({ runtime, showInColor }) =>\n `${runtime.platform}${showInColor ? '' : '-bw'}.svg`\n\nexport default withRuntimeContext(\n withImage(getImagePathFromProps)(FooterVtexLogo)\n)\n\n```" } ]
code_store-on-localhost_7f3bf928
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/legacy/FooterPaymentFormMatrix.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\nimport React, { Component } from 'react'\n\nimport FooterPaymentFormList from './FooterPaymentFormList'\n\nimport footer from './footer.css'\n\nexport default class FooterPaymentFormMatrix extends Component {\n static propTypes = {\n /** Payment forms array */\n paymentForms: PropTypes.arrayOf(\n PropTypes.shape({\n /** Payment form title */\n title: PropTypes.string,\n /** Payment types */\n paymentTypes: PropTypes.arrayOf(PropTypes.string.isRequired),\n })\n ),\n /** Determines if the icons are colorful */\n showPaymentFormsInColor: PropTypes.bool,\n }\n\n render() {\n const { paymentForms, ...otherProps } = this.props\n\n return (\n paymentForms && (\n <div className={`${footer.paymentMatrix} flex flex-wrap`}>\n {paymentForms.map((paymentFormsItem, index) => (\n <div\n key={`payment-container-${index}`}\n className={footer.paymentMatrixItem}\n >\n <FooterPaymentFormList\n horizontal\n titleId={paymentFormsItem.title}\n list={paymentFormsItem.paymentTypes.map(paymentType => ({\n paymentType,\n }))}\n {...otherProps}\n />\n </div>\n ))}\n </div>\n )\n )\n }\n}\n\n```" } ]
code_store-on-localhost_e3ddf327
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/legacy/FooterLinkList.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\nimport React from 'react'\nimport { injectIntl, intlShape } from 'react-intl'\nimport formatIOMessage from '../../NativeTypes/formatIOMessage'\n\nimport footerList from './footerList'\nimport footer from './footer.css'\n\nconst FooterLinkItem = ({ url, title, target, intl }) =>\n title ? (\n <a\n className={`${\n footer.listLink\n } dib no-underline underline-hover mb0 mt2 w-100 t-small truncate c-muted-1 pointer`}\n href={formatIOMessage({ id: url, intl })}\n target={target ? target : '_self'}\n >\n <IOMessage id={title} />\n </a>\n ) : null\n\nFooterLinkItem.displayName = 'FooterLinkItem'\n\nFooterLinkItem.propTypes = {\n url: PropTypes.string,\n title: PropTypes.string,\n target: PropTypes.oneOf(['_self', '_blank']),\n intl: intlShape,\n}\n\nconst FooterLinkItemWithIntl = injectIntl(FooterLinkItem)\n\nexport { FooterLinkItemWithIntl as FooterLinkItem }\n\nexport default footerList(FooterLinkItemWithIntl)\n\n```" } ]
code_store-on-localhost_a681a2b0
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/legacy/FooterPaymentFormList.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nimport footerList from './footerList'\nimport withImage from '../components/withImage'\nimport footer from './footer.css'\n\n/**\n * Shows an image for the payments forms accepted\n */\nconst FooterPaymentFormItem = ({ imageSrc }) => {\n if (!imageSrc) {\n return null\n }\n\n return (\n <img className={`${footer.paymentFormItem} pr0 w2 h2`} src={imageSrc} />\n )\n}\n\nFooterPaymentFormItem.displayName = 'FooterPaymentFormItem'\n\nFooterPaymentFormItem.propTypes = {\n /** Indicates which one of the payments forms should the component show its image */\n paymentType: PropTypes.string.isRequired,\n /** If true, the original logo (with color) is used. If not, the grayscale's one */\n showInColor: PropTypes.bool.isRequired,\n}\n\nconst getImagePathFromProps = ({ paymentType, showInColor }) =>\n `${paymentType.toLowerCase()}${showInColor ? '' : '-bw'}.svg`\n\nexport default footerList(\n withImage(getImagePathFromProps)(FooterPaymentFormItem)\n)\n\n```" } ]
code_store-on-localhost_a796314c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/legacy/propTypes.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\n\nexport const objectLikeLinkArray = PropTypes.arrayOf(\n PropTypes.shape({\n url: PropTypes.string,\n title: PropTypes.string,\n target: PropTypes.oneOf(['_self', '_blank']),\n })\n)\n\nexport const objectLikeBadgeArray = PropTypes.arrayOf(\n PropTypes.shape({\n image: PropTypes.string,\n })\n)\n\n```" } ]
code_store-on-localhost_4cc45b28
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/legacy/FooterLinksMatrix.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\nimport React, { Component, Fragment } from 'react'\n\nimport Accordion from './Accordion'\nimport FooterLinkList, { FooterLinkItem } from './FooterLinkList'\nimport { objectLikeLinkArray } from './propTypes'\nimport footer from './footer.css'\n\nexport default class FooterLinksMatrix extends Component {\n static propTypes = {\n /** Links to be shown */\n links: PropTypes.arrayOf(\n PropTypes.shape({\n /** Link section title */\n title: PropTypes.string,\n /** Link section links */\n links: objectLikeLinkArray,\n })\n ),\n }\n\n render() {\n const { links } = this.props\n\n if (!links) {\n return null\n }\n\n return (\n <div className={`${footer.matrixContainer} flex flex-wrap`}>\n {links.map((linkItem, index) => (\n <Fragment key={`links-container-${index}`}>\n <div className={`${footer.matrixItem} flex flex-auto dn-s flex-ns`}>\n <FooterLinkList titleId={linkItem.title} list={linkItem.links} />\n </div>\n <div\n className={`${\n footer.matrixItemSmall\n } bb b--muted-2 dn-ns db-s w-100 ph2 pv3`}\n >\n <Accordion title={linkItem.title}>\n {linkItem.links.map(link => (\n <div\n key={`${link.title}-${index}`}\n className={`${footer.accordionItem} pt1`}\n >\n <FooterLinkItem {...link} />\n </div>\n ))}\n </Accordion>\n </div>\n </Fragment>\n ))}\n </div>\n )\n }\n}\n\n```" } ]
code_store-on-localhost_0900e505
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/legacy/FooterSocialNetworkList.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\nimport React from 'react'\n\nimport footerList from './footerList'\nimport withImage from '../components/withImage'\nimport footer from './footer.css'\n\n/**\n * Shows an image for an specific social network\n */\nconst FooterSocialNetworkItem = ({ imageSrc, url }) => {\n if (!imageSrc) {\n return null\n }\n\n return (\n <a\n href={url}\n target=\"_blank\"\n rel=\"noopener\"\n className={`${footer.socialNetworkList} c-muted-1`}>\n <img className={`${footer.socialNetworkItem} w2 h2`} src={imageSrc} />\n </a>\n )\n}\n\nFooterSocialNetworkItem.displayName = 'FooterSocialNetworkItem'\n\nFooterSocialNetworkItem.propTypes = {\n /** Social network icon source */\n imageSrc: PropTypes.string,\n /** For which link should the user be redirected if the image is clicked */\n url: PropTypes.string,\n /** If true, the original logo (with color) is used. If not, the grayscale's one */\n showInColor: PropTypes.bool.isRequired,\n /** Indicates from which social network should the image be displayed */\n socialNetwork: PropTypes.oneOf([\n 'Facebook',\n 'Twitter',\n 'Instagram',\n 'Youtube',\n ]),\n}\nconst getImagePathFromProps = ({ socialNetwork, showInColor }) =>\n `${socialNetwork.toLowerCase()}${showInColor ? '' : '-bw'}.svg`\n\nexport default footerList(\n withImage(getImagePathFromProps)(FooterSocialNetworkItem)\n)\n\n```" } ]
code_store-on-localhost_54ca1b40
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/legacy/FooterBadgeList.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nimport footerList from './footerList'\n\nconst FooterBadgeItem = ({ image }) => {\n return (image && <img src={image} />) || null\n}\n\nFooterBadgeItem.displayName = 'FooterBadgeItem'\n\nFooterBadgeItem.propTypes = {\n image: PropTypes.string,\n}\n\nexport default footerList(FooterBadgeItem)\n\n\n```" } ]
code_store-on-localhost_583bb447
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/legacy/footer.css from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.footer {\n --vpadding: 1.25rem;\n --vpadding-limits: 1.5rem;\n --icon-filling: #727273;\n --tilte-min-height: 0.875rem;\n}\n\n.listTitle {\n min-height: var(--tilte-min-height);\n}\n\n.accordionIcon path {\n fill: var(--icon-filling);\n}\n\n/* Mobile */\n@media screen and (min-width: 10em) {\n .container {\n flex-direction: column;\n }\n}\n\n@media screen and (min-width: 40em) {\n .container {\n flex-flow: row wrap;\n }\n}\n\n@media screen and (min-width: 64em) {\n .container {\n padding-top: var(--vpadding);\n padding-bottom: var(--vpadding);\n }\n\n .container:first-of-type {\n padding-top: var(--vpadding-limits);\n }\n\n .container:last-of-type {\n padding-bottom: var(--vpadding-limits);\n }\n}\n\n.accordion {}\n\n.accordionTitle {}\n\n.listLink {}\n\n.matrixContainer {}\n\n.matrixItem {}\n\n.matrixItemSmall {}\n\n.accordionItem {}\n\n.listContainer {}\n\n.listContainerRightAligned {}\n\n.listContainerHorizontal {}\n\n.list {}\n\n.listHorizontal {}\n\n.listItem {}\n\n.listItemHorizontal {}\n\n.paymentFormItem {}\n\n.paymentMatrix {}\n\n.paymentMatrixItem {}\n\n.socialNetworkItem {}\n\n.vtexLogoItem {}\n\n.badgeList {}\n\n.badge {}\n\n.logoImage {}\n\n.textInformation {}\n\n.links {}\n\n.socialNetworkContainer {}\n\n.textContainer {}\n\n.socialNetworkList {}\n\n.navigation {}\n\n.payment {}\n\n```" } ]
code_store-on-localhost_1a7ea00c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/legacy/Footer.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\nimport React, { Component } from 'react'\nimport classNames from 'classnames'\nimport Container from '../../StoreComponents/Container'\nimport IOMessage from '../../NativeTypes/IOMessage'\n\nimport FooterBadgeList from './FooterBadgeList'\nimport FooterLinksMatrix from './FooterLinksMatrix'\nimport FooterPaymentFormMatrix from './FooterPaymentFormMatrix'\nimport FooterVtexLogo from './FooterVtexLogo'\nimport FooterSocialNetworkList from './FooterSocialNetworkList'\nimport { objectLikeBadgeArray, objectLikeLinkArray } from './propTypes'\n\nimport footer from './footer.css'\n\n/**\n * Footer component that appears in the bottom of every page.\n * Can be configured by the pages editor.\n */\nexport default class Footer extends Component {\n static displayName = 'Footer'\n\n static propTypes = {\n /** Social Networks */\n socialNetworks: objectLikeLinkArray,\n /** Links Sections */\n sectionLinks: PropTypes.arrayOf(\n PropTypes.shape({\n /** Link section title */\n title: PropTypes.string,\n /** Link section links */\n links: objectLikeLinkArray,\n })\n ),\n /** Badges */\n badges: objectLikeBadgeArray,\n /** Payment Forms */\n paymentForms: PropTypes.arrayOf(\n PropTypes.shape({\n /** Payment Form title */\n title: PropTypes.string,\n /** Payment Types */\n paymentTypes: PropTypes.arrayOf(PropTypes.string),\n })\n ),\n /** Determines if the icons are colorful */\n showPaymentFormsInColor: PropTypes.bool,\n /** Determines if the icons are colorful */\n showSocialNetworksInColor: PropTypes.bool,\n /** Determines if VTEX logo are colorful */\n showVtexLogoInColor: PropTypes.bool,\n /** Logo URL */\n logo: PropTypes.string,\n /** Store Informations */\n storeInformations: PropTypes.arrayOf(PropTypes.objectOf(PropTypes.string)),\n }\n\n static defaultProps = {\n showPaymentFormsInColor: false,\n showSocialNetworksInColor: false,\n showVtexLogoInColor: false,\n socialNetworks: [\n {\n socialNetwork: 'Facebook',\n url: '#',\n },\n ],\n sectionLinks: [],\n badges: [],\n paymentForms: [\n {\n title: 'admin/editor.footer.paymentForms.paymentForm',\n paymentTypes: ['MasterCard'],\n },\n ],\n storeInformations: [],\n }\n\n getInformationCssClasses = (listLength, index) => {\n let paddingClass\n const defaultClasses = `${footer.textInformation} w-100 w-50-ns t-mini ma0`\n // Only apply vertical paddings if there is more than 1 element\n if (listLength > 1) {\n if (index === 0) {\n paddingClass = 'pt4-s pb4-s pr4-ns'\n } else if (index + 1 === listLength) {\n paddingClass = 'pt4-s pb4-ns pl4-ns'\n } else {\n paddingClass = 'pv4-s'\n }\n }\n return classNames(defaultClasses, paddingClass)\n }\n\n render() {\n const {\n showPaymentFormsInColor,\n showSocialNetworksInColor,\n showVtexLogoInColor,\n logo,\n sectionLinks,\n socialNetworks,\n paymentForms,\n badges,\n storeInformations,\n } = this.props\n\n return (\n <footer className={`${footer.footer} bt bw1 b--muted-4 mt4 pv5`}>\n <Container className=\"justify-center flex\">\n <div className=\"w-100 mw9\">\n <nav\n className={`${footer.container} ${\n footer.navigation\n } pt5-s flex justify-between bg-base c-muted-1`}>\n <div className={`${footer.links} t-small w-100-s w-80-ns pb5-s`}>\n <FooterLinksMatrix links={sectionLinks} />\n </div>\n <div className={`${footer.socialNetworkContainer} pv5-s pa1-ns`}>\n <FooterSocialNetworkList\n titleId=\"store/social-networks\"\n list={socialNetworks}\n horizontal\n alignRight\n titleCapitals\n showInColor={showSocialNetworksInColor}\n />\n </div>\n </nav>\n <div\n className={`${footer.container} ${\n footer.payment\n } pv5-s flex justify-between bg-base c-muted-1`}>\n <FooterPaymentFormMatrix\n paymentForms={paymentForms}\n horizontal\n showInColor={showPaymentFormsInColor}\n />\n </div>\n <div\n className={`${footer.container} ${\n footer.informationContainer\n } pt5-s flex justify-between bg-base c-muted-1`}>\n <div\n className={`${\n footer.textContainer\n } w-100-s pb5-s w-80-ns flex flex-wrap`}>\n {storeInformations &&\n storeInformations.map(({ storeInformation }, index) => (\n <p\n key={`information-${index}`}\n className={this.getInformationCssClasses(\n storeInformations.length,\n index\n )}>\n <IOMessage id={storeInformation} />\n </p>\n ))}\n </div>\n <FooterVtexLogo\n logoUrl={logo}\n showInColor={showVtexLogoInColor}\n />\n <FooterBadgeList list={badges} />\n </div>\n </div>\n </Container>\n </footer>\n )\n }\n}\n\n```" } ]
code_store-on-localhost_9e9540e0
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/legacy/footerList.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport classNames from 'classnames'\nimport PropTypes from 'prop-types'\nimport React, { Component } from 'react'\nimport { injectIntl, intlShape } from 'react-intl'\n\nimport footer from './footer.css'\n\nconst getDisplayName = Component => {\n return Component.displayName || Component.name || 'Component'\n}\n\nexport default WrappedComponent => {\n class FooterList extends Component {\n static displayName = `FooterList(${getDisplayName(WrappedComponent)})`\n\n static propTypes = {\n titleId: PropTypes.string,\n list: PropTypes.array,\n intl: intlShape.isRequired,\n alignRight: PropTypes.bool,\n horizontal: PropTypes.bool,\n titleCapitals: PropTypes.bool,\n }\n\n static defaultProps = {\n alignRight: false,\n horizontal: false,\n }\n\n formatMessage(id) {\n return (\n (this.props.intl.messages[id] &&\n this.props.intl.formatMessage({ id })) ||\n id\n )\n }\n\n render() {\n const {\n list,\n titleId,\n alignRight,\n horizontal,\n titleCapitals,\n ...otherProps\n } = this.props\n\n if (!list || list.length === 0) return null\n\n const titleClasses = classNames(`${footer.listTitle} t-small ma0 db`, {\n ttu: !titleCapitals,\n })\n\n const listContainerClasses = classNames(\n `${footer.listContainer} pl0 w-100 mt0-ns`,\n {\n [`${footer.listContainerRightAligned} ml-auto-m`]: alignRight,\n [`${footer.listContainerHorizontal} w-auto-m`]: horizontal,\n }\n )\n\n const listClasses = classNames(\n `${footer.list} list flex flex-column flex-wrap pa0 mb0 mt3`,\n {\n [`${footer.listHorizontal} flex-row flex-wrap`]: horizontal,\n }\n )\n\n const listItemClasses = classNames(`${footer.listItem} mr0 mr3`, {\n [`${footer.listItemHorizontal}`]: horizontal,\n })\n\n return (\n <div className={listContainerClasses}>\n {titleId && (\n <span className={titleClasses}>{this.formatMessage(titleId)}</span>\n )}\n <ul className={listClasses}>\n {list.map((item, index) => (\n <li key={index} className={listItemClasses}>\n <WrappedComponent {...otherProps} {...item} />\n </li>\n ))}\n </ul>\n </div>\n )\n }\n }\n\n return injectIntl(FooterList)\n}\n\n```" } ]
code_store-on-localhost_4e57bb89
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/legacy/Accordion.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\nimport React, { Component } from 'react'\nimport { Collapse } from 'react-collapse'\nimport { injectIntl, intlShape } from 'react-intl'\n\nimport IconCaret from '../StoreIcons/IconCaret'\n\nimport footer from './footer.css'\n\nclass Accordion extends Component {\n static propTypes = {\n /** Title shown in Accordion */\n title: PropTypes.string,\n /** Accordion children. Components shown inside Collapse */\n children: PropTypes.node.isRequired,\n /** Internationalization */\n intl: intlShape.isRequired,\n }\n\n state = {\n open: false,\n }\n\n handleClick = () => {\n this.setState(({ open }) => ({ open: !open }))\n }\n\n translate = id => {\n return this.props.intl.messages[id]\n ? this.props.intl.formatMessage({ id })\n : id\n }\n\n render() {\n const { children, title } = this.props\n const { open } = this.state\n\n return (\n <div className={`${footer.accordion} pv2`}>\n <div\n role=\"button\"\n tabIndex={0}\n className=\"pointer\"\n onKeyDown={e => {\n if (e.key === 'Enter') {\n this.handleClick()\n }\n }}\n onClick={this.handleClick}\n >\n <div>\n {title && (\n <span className={`${footer.accordionTitle} dib ma0 ttu`}>\n {this.translate(title)}\n </span>\n )}\n <span className={`${footer.accordionIcon} fr`}>\n {open ? (\n <IconCaret orientation=\"down\" />\n ) : (\n <IconCaret orientation=\"right\" />\n )}\n </span>\n </div>\n </div>\n\n <div style={{ overflowY: 'auto' }}>\n <Collapse isOpened={open}>{children}</Collapse>\n </div>\n </div>\n )\n }\n}\n\nexport default injectIntl(Accordion)\n\n```" } ]
code_store-on-localhost_6c3e483a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/components/PaymentMethodIcon.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { injectIntl, WrappedComponentProps } from 'react-intl'\nimport formatIOMessage from '../../NativeTypes/formatIOMessage'\nimport useCssHandles from '../../CssHandles/useCssHandles'\n\nimport withImage from './withImage'\n\ninterface PaymentMethodIconProps extends WrappedComponentProps {\n imageSrc?: string\n /** If true, the original logo (with color) is used. If not, the grayscale's one */\n showInColor?: boolean\n /** Indicates which one of the payments method should the component show its image */\n paymentMethod: PaymentMethod\n}\n\nconst CSS_HANDLES = ['paymentMethodIcon', 'paymentMethodIconImage']\n\n/**\n * Shows an image for the payments forms accepted\n */\nconst PaymentMethodIcon: StorefrontFunctionComponent<\n PaymentMethodIconProps\n> = ({ imageSrc, paymentMethod, intl }) => {\n const handles = useCssHandles(CSS_HANDLES)\n\n if (!imageSrc) {\n return null\n }\n\n return (\n <div className={`${handles.paymentMethodIcon} w2 h2 mh2 flex items-center`}>\n <img\n className={`${handles.paymentMethodIconImage} w-100`}\n src={imageSrc}\n alt={formatIOMessage({ id: paymentMethod, intl })}\n title={formatIOMessage({ id: paymentMethod, intl })}\n />\n </div>\n )\n}\n\nexport enum PaymentMethod {\n 'diners club' = 'diners club',\n 'mastercard' = 'mastercard',\n 'visa' = 'visa',\n}\n\nconst getImagePathFromProps = ({\n paymentMethod,\n showInColor,\n}: PaymentMethodIconProps) =>\n `${paymentMethod.toLowerCase()}${showInColor ? '' : '-bw'}.svg`\n\nexport default withImage(getImagePathFromProps)(injectIntl(PaymentMethodIcon))\n\n```" } ]
code_store-on-localhost_387dffdc
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/components/SocialNetwork.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { injectIntl, WrappedComponentProps } from 'react-intl'\nimport formatIOMessage from '../../NativeTypes/formatIOMessage'\nimport useCssHandles from '../../CssHandles/useCssHandles'\nimport applyModifiers from '../../CssHandles/applyModifiers'\n\nimport withImage from './withImage'\n\ninterface SocialNetworkProps extends WrappedComponentProps {\n imageSrc: string\n showInColor: boolean\n url: string\n name: string\n}\n\nconst CSS_HANDLES = ['socialNetworkLink', 'socialNetworkImage'] as const\n\n/**\n * Shows an image for an specific social network\n */\nconst SocialNetwork: React.FC<SocialNetworkProps> = ({\n imageSrc,\n url,\n name,\n intl,\n}) => {\n const handles = useCssHandles(CSS_HANDLES)\n\n if (!imageSrc) {\n return null\n }\n\n const normalizedName = String(name).toLowerCase()\n\n return (\n <a\n href={formatIOMessage({ id: url, intl })}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={`${handles.socialNetworkLink} ${applyModifiers(\n handles.socialNetworkLink,\n normalizedName\n )} c-muted-1 w2 h2 mh2 flex items-center`}\n >\n <img\n className={`${handles.socialNetworkImage} ${applyModifiers(\n handles.socialNetworkImage,\n normalizedName\n )}`}\n src={imageSrc}\n alt={formatIOMessage({ id: name, intl })}\n title={formatIOMessage({ id: name, intl })}\n />\n </a>\n )\n}\n\nSocialNetwork.displayName = 'SocialNetwork'\n\nconst getImagePathFromProps = ({ name, showInColor }: SocialNetworkProps) =>\n `${name.toLowerCase()}${showInColor ? '' : '-bw'}.svg`\n\nexport default withImage(getImagePathFromProps)(injectIntl(SocialNetwork))\n\n```" } ]
code_store-on-localhost_becf4310
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/components/withImage.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\n\nfunction getDisplayName(Component) {\n return Component.displayName || Component.name || 'Component'\n}\n\n/**\n * HOC used for lazily load an image in the 'images' folder right above\n * this component.\n *\n * Used for loading the logos for the Footer\n *\n * @param {Function} getImageFilename\n */\nexport default getImageFilename => {\n return WrappedComponent => {\n class WithImage extends Component {\n static displayName = `WithImage(${getDisplayName(WrappedComponent)})`\n static getSchema = WrappedComponent.getSchema\n static schema = WrappedComponent.schema\n\n state = {}\n\n _isMounted = false\n\n componentDidMount() {\n const imageName = getImageFilename(this.props)\n this._isMounted = true\n this.lazyImport(imageName)\n }\n\n componentWillUnmount() {\n this._isMounted = false\n }\n\n componentDidUpdate() {\n const imageName = getImageFilename(this.props)\n if (imageName !== this.state.imageName) {\n this.lazyImport(imageName)\n }\n }\n\n lazyImport = imageName => {\n return import(`../images/${imageName}`).then(imageSrc => {\n if (this._isMounted) {\n this.setState({ imageSrc: imageSrc.default, imageName })\n }\n })\n }\n\n render() {\n return (\n <WrappedComponent {...this.props} imageSrc={this.state.imageSrc} />\n )\n }\n }\n\n return WithImage\n }\n}\n\n```" } ]
code_store-on-localhost_67d9b876
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/components/withImage.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { FC, ComponentType } from 'react'\n\nexport default (mapper: (props: any) => void) => (\n component: ComponentType<any>\n) => FC\n\n```" } ]
code_store-on-localhost_c45c4515
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Footer/__tests__/PoweredBy.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { render, waitForElement } from '@vtex/test-tools/react'\n\nimport PoweredBy from '../PoweredBy'\n\ndescribe('PoweredBy', () => {\n it('should get the platform from runtime', async () => {\n const { getByAltText } = render(<PoweredBy />)\n\n const element = await waitForElement(() => getByAltText('VTEX'))\n\n const src = element.getAttribute('src')\n\n expect(src).toBe('vtex-bw.svg')\n })\n})\n\n```" } ]
code_store-on-localhost_112e2d54
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductListContext/utils/parser.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { pathOr, head } from 'ramda'\n\nimport { Product } from '../ProductListContext'\n\nimport { changeImageUrlSize, toHttps } from './urlHelpers'\n\nconst defaultImage = { imageUrl: '', imageLabel: '' }\nconst defaultReference = { Value: '' }\nconst defaultSeller = { commertialOffer: { Price: 0, ListPrice: 0 } }\n\nfunction findAvailableProduct(item: any) {\n return item.sellers.find(\n ({ commertialOffer = {} }: { commertialOffer: any }) =>\n commertialOffer.AvailableQuantity > 0\n )\n}\n\nexport function parseToProductImpression(product: Product): Product {\n const parsedProduct = { ...product }\n const items = parsedProduct.items || []\n const sku = items.find(findAvailableProduct) || head(items)\n if (sku) {\n const [seller = defaultSeller] = pathOr([], ['sellers'], sku)\n const [referenceId = defaultReference] = pathOr([], ['referenceId'], sku)\n const [image = defaultImage] = pathOr([], ['images'], sku)\n\n const resizedImage = changeImageUrlSize(toHttps(image.imageUrl), 500)\n const parsedImage = { ...image, imageUrl: resizedImage }\n parsedProduct.sku = {\n ...sku,\n seller,\n referenceId,\n image: parsedImage,\n }\n }\n return parsedProduct\n}\n\n```" } ]
code_store-on-localhost_f798be6d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductListContext/utils/urlHelpers.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nexport const DEFAULT_WIDTH = 'auto'\nexport const DEFAULT_HEIGHT = 'auto'\nexport const MAX_WIDTH = 3000\nexport const MAX_HEIGHT = 4000\n\n/**\n * Having the url below as base for the LEGACY file manager,\n * https://storecomponents.vteximg.com.br/arquivos/ids/155472/Frame-3.jpg?v=636793763985400000\n * the following regex will match https://storecomponents.vteximg.com.br/arquivos/ids/155472\n *\n * Also matches urls with defined sizes like:\n * https://storecomponents.vteximg.com.br/arquivos/ids/155473-160-auto\n * @type {RegExp}\n *\n * On the new vtex.file-manager isn't necessary replace the URL, just add the param on the querystring, like:\n * \"?width=WIDTH&height=HEIGHT&aspect=true\"\n *\n */\nconst baseUrlRegex = /.+ids\\/(\\d+)/\nconst httpRegex = /http:\\/\\//\nconst legacyUrlPattern = '/arquivos/ids/'\n\nexport function toHttps(url: any) {\n return url.replace(httpRegex, 'https://')\n}\n\nexport function cleanImageUrl(imageUrl: any) {\n const result = baseUrlRegex.exec(imageUrl)\n if (!result) return\n if (result.length > 0) return result[0]\n return\n}\n\nfunction replaceLegacyFileManagerUrl(imageUrl: any, width: any, height: any) {\n const isLegacyUrl = imageUrl.includes(legacyUrlPattern)\n if (!isLegacyUrl) return imageUrl\n return `${cleanImageUrl(imageUrl)}-${width}-${height}`\n}\n\nexport function changeImageUrlSize(\n imageUrl: any,\n width: number | string = DEFAULT_WIDTH,\n height: number | string = DEFAULT_HEIGHT\n) {\n if (!imageUrl) return\n if (typeof width === 'number') width = Math.min(width, MAX_WIDTH)\n if (typeof height === 'number') height = Math.min(height, MAX_HEIGHT)\n\n const normalizedImageUrl = replaceLegacyFileManagerUrl(\n imageUrl,\n width,\n height\n )\n const queryStringSeparator = normalizedImageUrl.includes('?') ? '&' : '?'\n\n return `${normalizedImageUrl}${queryStringSeparator}width=${width}&height=${height}&aspect=true`\n}\n\n```" } ]
code_store-on-localhost_00563f1f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/CheckoutResources/fragments/address.graphql from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nfragment Address on Address {\n addressId\n addressType\n city\n complement\n country\n neighborhood\n number\n postalCode\n receiverName\n reference\n state\n street\n}\n\n```" } ]
code_store-on-localhost_1add8fac
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/CheckoutResources/fragments/orderForm.graphql from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\n# import './address.graphql'\n\nfragment OrderFormFragment on OrderForm {\n id\n items {\n additionalInfo {\n brandName\n }\n parentAssemblyBinding\n sellingPriceWithAssemblies\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n }\n }\n }\n availability\n detailUrl\n id\n imageUrls {\n at1x\n at2x\n at3x\n }\n listPrice\n measurementUnit\n name\n price\n productCategories\n productCategoryIds\n productRefId\n productId\n quantity\n sellingPrice\n skuName\n skuSpecifications {\n fieldName\n fieldValues\n }\n uniqueId\n }\n canEditData\n marketingData {\n coupon\n }\n totalizers {\n id\n name\n value\n }\n shipping {\n countries\n availableAddresses {\n ...Address\n }\n selectedAddress {\n ...Address\n }\n deliveryOptions {\n id\n price\n estimate\n isSelected\n }\n }\n messages {\n couponMessages {\n code\n }\n generalMessages {\n code\n text\n status\n }\n }\n value\n}\n\n```" } ]
code_store-on-localhost_e4f61c09
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/CheckoutResources/mutations/insertCoupon.graphql from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\n# import '../fragments/orderForm.graphql'\n\nmutation insertCoupon($text: String) {\n insertCoupon(text: $text) @context(provider: \"vtex.checkout-graphql\") {\n ...OrderFormFragment\n }\n}\n\nfragment Address on Address @context(provider: \"vtex.checkout-graphql\") {\n addressId\n addressType\n city\n complement\n country\n neighborhood\n number\n postalCode\n receiverName\n reference\n state\n street\n}\n\n\nfragment OrderFormFragment on OrderForm @context(provider: \"vtex.checkout-graphql\") {\n id\n items {\n additionalInfo {\n brandName\n }\n parentAssemblyBinding\n sellingPriceWithAssemblies\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n }\n }\n }\n availability\n detailUrl\n id\n imageUrls {\n at1x\n at2x\n at3x\n }\n listPrice\n measurementUnit\n name\n price\n productCategories\n productCategoryIds\n productRefId\n productId\n quantity\n sellingPrice\n skuName\n skuSpecifications {\n fieldName\n fieldValues\n }\n uniqueId\n }\n canEditData\n marketingData {\n coupon\n }\n totalizers {\n id\n name\n value\n }\n shipping {\n countries\n availableAddresses {\n ...Address\n }\n selectedAddress {\n ...Address\n }\n deliveryOptions {\n id\n price\n estimate\n isSelected\n }\n }\n messages {\n couponMessages {\n code\n }\n generalMessages {\n code\n text\n status\n }\n }\n value\n}\n\n\n```" } ]
code_store-on-localhost_d16e2d95
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/CheckoutResources/mutations/selectDeliveryOption.graphql from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\n# import '../fragments/orderForm.graphql'\n\nmutation selectDeliveryOption($deliveryOptionId: String) {\n selectDeliveryOption(deliveryOptionId: $deliveryOptionId)\n @context(provider: \"vtex.checkout-graphql\") {\n ...OrderFormFragment\n }\n}\n\nfragment Address on Address @context(provider: \"vtex.checkout-graphql\") {\n addressId\n addressType\n city\n complement\n country\n neighborhood\n number\n postalCode\n receiverName\n reference\n state\n street\n}\n\n\nfragment OrderFormFragment on OrderForm @context(provider: \"vtex.checkout-graphql\") {\n id\n items {\n additionalInfo {\n brandName\n }\n parentAssemblyBinding\n sellingPriceWithAssemblies\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n }\n }\n }\n availability\n detailUrl\n id\n imageUrls {\n at1x\n at2x\n at3x\n }\n listPrice\n measurementUnit\n name\n price\n productCategories\n productCategoryIds\n productRefId\n productId\n quantity\n sellingPrice\n skuName\n skuSpecifications {\n fieldName\n fieldValues\n }\n uniqueId\n }\n canEditData\n marketingData {\n coupon\n }\n totalizers {\n id\n name\n value\n }\n shipping {\n countries\n availableAddresses {\n ...Address\n }\n selectedAddress {\n ...Address\n }\n deliveryOptions {\n id\n price\n estimate\n isSelected\n }\n }\n messages {\n couponMessages {\n code\n }\n generalMessages {\n code\n text\n status\n }\n }\n value\n}\n\n```" } ]
code_store-on-localhost_d9e9164e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/CheckoutResources/mutations/updateItems.graphql from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\n# import '../fragments/orderForm.graphql'\n\nmutation updateItems($orderItems: [ItemInput]) {\n updateItems(orderItems: $orderItems) @context(provider: \"vtex.checkout-graphql\") {\n ...OrderFormFragment\n }\n}\n\nfragment Address on Address @context(provider: \"vtex.checkout-graphql\") {\n addressId\n addressType\n city\n complement\n country\n neighborhood\n number\n postalCode\n receiverName\n reference\n state\n street\n}\n\n\nfragment OrderFormFragment on OrderForm @context(provider: \"vtex.checkout-graphql\") {\n id\n items {\n additionalInfo {\n brandName\n }\n parentAssemblyBinding\n sellingPriceWithAssemblies\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n }\n }\n }\n availability\n detailUrl\n id\n imageUrls {\n at1x\n at2x\n at3x\n }\n listPrice\n measurementUnit\n name\n price\n productCategories\n productCategoryIds\n productRefId\n productId\n quantity\n sellingPrice\n skuName\n skuSpecifications {\n fieldName\n fieldValues\n }\n uniqueId\n }\n canEditData\n marketingData {\n coupon\n }\n totalizers {\n id\n name\n value\n }\n shipping {\n countries\n availableAddresses {\n ...Address\n }\n selectedAddress {\n ...Address\n }\n deliveryOptions {\n id\n price\n estimate\n isSelected\n }\n }\n messages {\n couponMessages {\n code\n }\n generalMessages {\n code\n text\n status\n }\n }\n value\n}\n\n\n```" } ]
code_store-on-localhost_d0087692
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/CheckoutResources/mutations/estimateShipping.graphql from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\n# import '../fragments/orderForm.graphql'\n\nmutation estimateShipping($addressInput: AddressInput) {\n estimateShipping(address: $addressInput)\n @context(provider: \"vtex.checkout-graphql\") {\n ...OrderFormFragment\n }\n}\n\nfragment Address on Address @context(provider: \"vtex.checkout-graphql\") {\n addressId\n addressType\n city\n complement\n country\n neighborhood\n number\n postalCode\n receiverName\n reference\n state\n street\n}\n\n\nfragment OrderFormFragment on OrderForm @context(provider: \"vtex.checkout-graphql\") {\n id\n items {\n additionalInfo {\n brandName\n }\n parentAssemblyBinding\n sellingPriceWithAssemblies\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n }\n }\n }\n availability\n detailUrl\n id\n imageUrls {\n at1x\n at2x\n at3x\n }\n listPrice\n measurementUnit\n name\n price\n productCategories\n productCategoryIds\n productRefId\n productId\n quantity\n sellingPrice\n skuName\n skuSpecifications {\n fieldName\n fieldValues\n }\n uniqueId\n }\n canEditData\n marketingData {\n coupon\n }\n totalizers {\n id\n name\n value\n }\n shipping {\n countries\n availableAddresses {\n ...Address\n }\n selectedAddress {\n ...Address\n }\n deliveryOptions {\n id\n price\n estimate\n isSelected\n }\n }\n messages {\n couponMessages {\n code\n }\n generalMessages {\n code\n text\n status\n }\n }\n value\n}\n\n```" } ]
code_store-on-localhost_941094f5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/CheckoutResources/mutations/addToCart.graphql from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\n# import '../fragments/orderForm.graphql'\n\nmutation addToCart($items: [ItemInput]) {\n addToCart(items: $items) @context(provider: \"vtex.checkout-graphql\") {\n ...OrderFormFragment\n }\n}\n\nfragment Address on Address @context(provider: \"vtex.checkout-graphql\") {\n addressId\n addressType\n city\n complement\n country\n neighborhood\n number\n postalCode\n receiverName\n reference\n state\n street\n}\n\n\nfragment OrderFormFragment on OrderForm @context(provider: \"vtex.checkout-graphql\") {\n id\n items {\n additionalInfo {\n brandName\n }\n parentAssemblyBinding\n sellingPriceWithAssemblies\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n }\n }\n }\n availability\n detailUrl\n id\n imageUrls {\n at1x\n at2x\n at3x\n }\n listPrice\n measurementUnit\n name\n price\n productCategories\n productCategoryIds\n productRefId\n productId\n quantity\n sellingPrice\n skuName\n skuSpecifications {\n fieldName\n fieldValues\n }\n uniqueId\n }\n canEditData\n marketingData {\n coupon\n }\n totalizers {\n id\n name\n value\n }\n shipping {\n countries\n availableAddresses {\n ...Address\n }\n selectedAddress {\n ...Address\n }\n deliveryOptions {\n id\n price\n estimate\n isSelected\n }\n }\n messages {\n couponMessages {\n code\n }\n generalMessages {\n code\n text\n status\n }\n }\n value\n}\n\n```" } ]
code_store-on-localhost_6cc03a6e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/CheckoutResources/typings/graphql.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.graphql' {\n import { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\n```" } ]
code_store-on-localhost_9b64db1d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/CheckoutResources/queries/orderForm.graphql from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\n# import '../fragments/orderForm.graphql'\n\nquery orderFormCheckout {\n orderForm @context(provider: \"vtex.checkout-graphql\") {\n ...OrderFormFragment\n }\n}\n\nfragment Address on Address @context(provider: \"vtex.checkout-graphql\") {\n addressId\n addressType\n city\n complement\n country\n neighborhood\n number\n postalCode\n receiverName\n reference\n state\n street\n}\n\n\nfragment OrderFormFragment on OrderForm @context(provider: \"vtex.checkout-graphql\") {\n id\n items {\n additionalInfo {\n brandName\n }\n parentAssemblyBinding\n sellingPriceWithAssemblies\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n options {\n assemblyId\n id\n quantity\n seller\n inputValues\n }\n }\n }\n availability\n detailUrl\n id\n imageUrls {\n at1x\n at2x\n at3x\n }\n listPrice\n measurementUnit\n name\n price\n productCategories\n productCategoryIds\n productRefId\n productId\n quantity\n sellingPrice\n skuName\n skuSpecifications {\n fieldName\n fieldValues\n }\n uniqueId\n }\n canEditData\n marketingData {\n coupon\n }\n totalizers {\n id\n name\n value\n }\n shipping {\n countries\n availableAddresses {\n ...Address\n }\n selectedAddress {\n ...Address\n }\n deliveryOptions {\n id\n price\n estimate\n isSelected\n }\n }\n messages {\n couponMessages {\n code\n }\n generalMessages {\n code\n text\n status\n }\n }\n value\n}\n\n```" } ]
code_store-on-localhost_c3fd4e23
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/CheckoutResources/utils/useCheckoutURL.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { useQuery } from 'react-apollo'\nimport { loader } from 'graphql.macro'\n\nconst installedApp = loader('./graphql/installedApp.graphql')\n\nconst CHECKOUT_URL = {\n V0: '/checkout/#/cart',\n V1: '/cart',\n}\n\nexport const useCheckoutURL = () => {\n const { data } = useQuery(installedApp, {\n ssr: false,\n variables: {\n slug: 'vtex.checkout',\n },\n })\n\n const version = data?.installedApp?.version\n const major = version && parseInt(version.split('.')[0])\n\n return {\n url: major > 0 ? CHECKOUT_URL.V1 : CHECKOUT_URL.V0,\n major,\n }\n}\n\n```" } ]
code_store-on-localhost_9a049510
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/CheckoutResources/utils/__tests__/useCheckoutURL.test.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport { flushPromises, render } from '@vtex/test-tools/react'\nimport { MockedProvider } from '@apollo/react-testing'\n\nimport installedApp from '../graphql/installedApp.graphql'\nimport { useCheckoutURL } from '../useCheckoutURL'\n\ndescribe('useCheckoutURL', () => {\n it('should return the correct URL when checkout major is 0', async () => {\n jest.useFakeTimers()\n\n const Component: FC = () => {\n const { url } = useCheckoutURL()\n return <div>{url}</div>\n }\n\n const mockInstalledApp = {\n request: {\n query: installedApp,\n variables: {\n slug: 'vtex.checkout',\n },\n },\n result: {\n data: {\n installedApp: {\n version: '0.4.2',\n },\n },\n },\n }\n\n const { getByText } = render(<Component />, {\n graphql: { mocks: [mockInstalledApp] },\n MockedProvider,\n })\n\n await flushPromises()\n jest.runAllTimers()\n\n expect(getByText('/checkout/#/cart')).toBeTruthy()\n })\n\n it('should return the correct URL when checkout major is 1', async () => {\n jest.useFakeTimers()\n\n const Component = () => {\n const { url } = useCheckoutURL()\n return <div>{url}</div>\n }\n\n const mockInstalledApp = {\n request: {\n query: installedApp,\n variables: {\n slug: 'vtex.checkout',\n },\n },\n result: {\n data: {\n installedApp: {\n version: '1.4.2',\n },\n },\n },\n }\n\n const { getByText } = render(<Component />, {\n graphql: { mocks: [mockInstalledApp] },\n MockedProvider,\n })\n\n await flushPromises()\n jest.runAllTimers()\n\n expect(getByText('/cart')).toBeTruthy()\n })\n})\n\n```" } ]
code_store-on-localhost_a0a52406
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/CheckoutResources/utils/graphql/installedApp.graphql from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery installedApp($slug: String!) {\n installedApp(slug: $slug) {\n version\n }\n}\n\n```" } ]
code_store-on-localhost_de45d280
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/LocaleSwitcher/typings/storefront.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { FunctionComponent, ReactElement } from 'react'\n\ndeclare global {\n interface StorefrontFunctionComponent<P = {}> extends FunctionComponent<P> {\n getSchema?(props: P): object\n schema?: object\n }\n\n interface StorefrontComponent<P = {}, S = {}> extends Component<P, S> {\n getSchema?(props: P): object\n schema: object\n }\n}\n\n```" } ]
code_store-on-localhost_4ced3edc
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/LocaleSwitcher/typings/vtex.render-runtime.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* Typings for `render-runtime` */\ndeclare module 'vtex.render-runtime' {\n import { Component, ComponentType, ReactElement, ReactType } from 'react'\n\n export interface NavigationOptions {\n page: string\n params?: any\n }\n\n export interface RenderContextProps {\n runtime: {\n navigate: (options: NavigationOptions) => void\n }\n }\n\n interface ExtensionPointProps {\n id: string\n [key: string]: any\n }\n\n export const ExtensionPoint: ComponentType<ExtensionPointProps>\n\n interface ChildBlockProps {\n id: string\n }\n\n export const ChildBlock: ComponentType<ChildBlockProps>\n export const useChildBlock = function({ id: string }): object {}\n\n export const Helmet: ReactElement\n export const Link: ReactType\n export const NoSSR: ReactElement\n export const RenderContextConsumer: ReactElement\n export const canUseDOM: boolean\n export const withRuntimeContext: <TOriginalProps extends {}>(\n Component: ComponentType<TOriginalProps & RenderContextProps>\n ) => ComponentType<TOriginalProps>\n}\n\n```" } ]
code_store-on-localhost_2daa2cff
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/LocaleSwitcher/typings/css.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const css: any\n export default css\n}\n\n```" } ]
code_store-on-localhost_8b075478
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/LocaleSwitcher/typings/graphql.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.graphql' {\n import { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n```" } ]
code_store-on-localhost_5a7d44b4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/LocaleSwitcher/typings/vtex.styleguide.d.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.styleguide' {\n import { ComponentType } from 'react'\n\n export const Input: ComponentType<InputProps>\n\n interface InputProps {\n [key: string]: any\n }\n}\n\n```" } ]
code_store-on-localhost_3c35ea79
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/LocaleSwitcher/queries/locales.gql from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery Locales {\n languages @context(provider: \"vtex.messages\") {\n default\n supported\n }\n currentBinding @context(provider: \"vtex.tenant-graphql\") {\n supportedLocales\n }\n}\n```" } ]
code_store-on-localhost_3f926074
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/legacy/index.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\n/* eslint-disable react/jsx-handler-names */\nimport PropTypes from 'prop-types'\nimport React, { Component } from 'react'\nimport ProductName from '../../StoreComponents/ProductName'\nimport ProductPrice from '../../StoreComponents/ProductPrice'\n\nimport ProductSummaryNormal from './components/ProductSummaryNormal'\nimport ProductSummarySmall from './components/ProductSummarySmall'\nimport ProductSummaryInline from './components/ProductSummaryInline'\nimport ProductSummaryInlinePrice from './components/ProductSummaryInlinePrice'\nimport displayButtonTypes, {\n getDisplayButtonNames,\n getDisplayButtonValues,\n} from '../utils/displayButtonTypes'\nimport { productShape } from '../utils/propTypes'\n\nconst DISPLAY_MODE_MAP = {\n normal: ProductSummaryNormal,\n small: ProductSummarySmall,\n inline: ProductSummaryInline,\n inlinePrice: ProductSummaryInlinePrice,\n}\n\n/**\n * Product Summary component. Summarizes the product information.\n */\nclass ProductSummary extends Component {\n static propTypes = {\n /** Product that owns the informations */\n product: productShape,\n /** Shows the product list price */\n showListPrice: PropTypes.bool,\n /** Should redirect to checkout after clicking on buy */\n isOneClickBuy: PropTypes.bool,\n /** Set pricing labels' visibility */\n showLabels: PropTypes.bool,\n /** Set installments' visibility */\n showInstallments: PropTypes.bool,\n /** Set the borders product's visibility */\n showBorders: PropTypes.bool,\n /** Set the discount badge's visibility */\n showBadge: PropTypes.bool,\n /** Set the product description visibility */\n showDescription: PropTypes.bool,\n /** Set the quantity selector visibility */\n showQuantitySelector: PropTypes.bool,\n /** Text of selling Price's label */\n labelSellingPrice: PropTypes.string,\n /** Text of list Price's label */\n labelListPrice: PropTypes.string,\n /** Text shown on badge */\n badgeText: PropTypes.string,\n /** Custom buy button text */\n buyButtonText: PropTypes.string,\n /** Defines the display mode of buy button */\n displayBuyButton: PropTypes.oneOf(getDisplayButtonValues()),\n /** Hides the buy button completely . If active, the button will not be shown in any condition */\n hideBuyButton: PropTypes.bool,\n /** Defines if the collection badges are shown */\n showCollections: PropTypes.bool,\n /** Name schema props */\n nameSchema: PropTypes.object,\n /** Display mode of the summary used in the search result */\n displayMode: PropTypes.oneOf(['normal', 'small', 'inline', 'inlinePrice']),\n /** Function that is executed when a product is clicked */\n actionOnClick: PropTypes.func,\n /** Set the price align to left */\n priceAlignLeft: PropTypes.bool,\n muted: PropTypes.bool,\n index: PropTypes.number,\n }\n\n static defaultProps = {\n showListPrice: true,\n showInstallments: true,\n showLabels: true,\n showBadge: true,\n showQuantitySelector: true,\n showCollections: false,\n showDescription: false,\n displayBuyButton: displayButtonTypes.DISPLAY_ALWAYS.value,\n isOneClickBuy: false,\n nameSchema: {\n showProductReference: false,\n showBrandName: false,\n showSku: false,\n },\n displayMode: 'normal',\n showBorders: false,\n muted: false,\n }\n\n state = {\n isHovering: false,\n isUpdatingItems: false,\n }\n\n handleMouseLeave = () => {\n this.setState({ isHovering: false })\n }\n\n handleMouseEnter = () => {\n this.setState({ isHovering: true })\n }\n\n handleItemsStateUpdate = isLoading =>\n this.setState({ isUpdatingItems: isLoading })\n\n render() {\n const {\n product,\n actionOnClick,\n displayMode,\n displayBuyButton,\n isOneClickBuy,\n buyButtonText,\n showBorders,\n showDescription,\n showBadge,\n badgeText,\n showCollections,\n showListPrice,\n showLabels,\n showInstallments,\n labelSellingPrice,\n labelListPrice,\n nameSchema: showFieldsProps,\n showQuantitySelector,\n priceAlignLeft,\n muted,\n index,\n } = this.props\n\n const imageProps = {\n product,\n showBadge,\n badgeText,\n showCollections,\n displayMode,\n }\n const nameProps = { product, showFieldsProps }\n\n const priceProps = {\n product,\n showListPrice,\n showLabels,\n showInstallments,\n labelSellingPrice,\n labelListPrice,\n isLoading: this.state.isUpdatingItems,\n }\n\n const buyButtonProps = {\n product,\n displayBuyButton,\n isOneClickBuy,\n buyButtonText,\n isHovering: this.state.isHovering,\n }\n\n const ProductSummaryComponent =\n DISPLAY_MODE_MAP[displayMode] || ProductSummaryNormal\n\n return (\n <ProductSummaryComponent\n product={product}\n showBorders={showBorders}\n showDescription={showDescription}\n handleMouseEnter={this.handleMouseEnter}\n handleMouseLeave={this.handleMouseLeave}\n handleItemsStateUpdate={this.handleItemsStateUpdate}\n actionOnClick={actionOnClick}\n imageProps={imageProps}\n nameProps={nameProps}\n priceProps={priceProps}\n buyButtonProps={buyButtonProps}\n showQuantitySelector={showQuantitySelector}\n priceAlignLeft={priceAlignLeft}\n muted={muted}\n index={index}\n />\n )\n }\n}\n\nconst defaultSchema = {\n title: 'admin/editor.productSummary.title',\n description: 'admin/editor.productSummary.description',\n type: 'object',\n properties: {\n isOneClickBuy: {\n type: 'boolean',\n title: 'admin/editor.productSummary.isOneClickBuy.title',\n default: false,\n isLayout: true,\n },\n showBadge: {\n type: 'boolean',\n title: 'admin/editor.productSummary.showBadge.title',\n default: true,\n isLayout: true,\n },\n displayBuyButton: {\n title: 'admin/editor.productSummary.displayBuyButton.title',\n type: 'string',\n enum: getDisplayButtonValues(),\n enumNames: getDisplayButtonNames(),\n default: displayButtonTypes.DISPLAY_ALWAYS.value,\n isLayout: true,\n },\n showCollections: {\n type: 'boolean',\n title: 'admin/editor.productSummary.showCollections.title',\n default: false,\n isLayout: true,\n },\n\n ...ProductPrice.schema.properties,\n },\n}\n\nProductSummary.getSchema = () => {\n const nameSchema = ProductName.schema\n return {\n ...defaultSchema,\n properties: {\n ...defaultSchema.properties,\n nameSchema,\n },\n }\n}\n\nexport default ProductSummary\n\n```" } ]
code_store-on-localhost_68860d8b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/utils/normalize.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport { pathOr } from 'ramda'\n\nexport const DEFAULT_WIDTH = 'auto'\nexport const DEFAULT_HEIGHT = 'auto'\nexport const MAX_WIDTH = 3000\nexport const MAX_HEIGHT = 4000\n\n/**\n * Having the url below as base for the LEGACY file manager,\n * https://storecomponents.vteximg.com.br/arquivos/ids/155472/Frame-3.jpg?v=636793763985400000\n * the following regex will match https://storecomponents.vteximg.com.br/arquivos/ids/155472\n *\n * Also matches urls with defined sizes like:\n * https://storecomponents.vteximg.com.br/arquivos/ids/155473-160-auto\n * @type {RegExp}\n *\n * On the new vtex.file-manager isn't necessary replace the URL, just add the param on the querystring, like:\n * \"?width=WIDTH&height=HEIGHT&aspect=true\"\n *\n */\nconst baseUrlRegex = new RegExp(/.+ids\\/(\\d+)/)\n\nconst httpRegex = new RegExp(/http:\\/\\//)\n\nfunction toHttps(url) {\n return url.replace(httpRegex, 'https://')\n}\n\nfunction cleanImageUrl(imageUrl) {\n const result = baseUrlRegex.exec(imageUrl)\n if (result.length > 0) return result[0]\n}\n\nfunction replaceLegacyFileManagerUrl(imageUrl, width, height) {\n const legacyUrlPattern = '/arquivos/ids/'\n const isLegacyUrl = imageUrl.includes(legacyUrlPattern)\n if (!isLegacyUrl) return imageUrl\n return `${cleanImageUrl(imageUrl)}-${width}-${height}`\n}\n\nexport function changeImageUrlSize(\n imageUrl,\n width = DEFAULT_WIDTH,\n height = DEFAULT_HEIGHT\n) {\n if (!imageUrl) return\n typeof width === 'number' && (width = Math.min(width, MAX_WIDTH))\n typeof height === 'number' && (height = Math.min(height, MAX_HEIGHT))\n\n const normalizedImageUrl = replaceLegacyFileManagerUrl(\n imageUrl,\n width,\n height\n )\n const queryStringSeparator = normalizedImageUrl.includes('?') ? '&' : '?'\n\n return `${normalizedImageUrl}${queryStringSeparator}width=${width}&height=${height}&aspect=true`\n}\n\nfunction findAvailableProduct(item) {\n return item.sellers.find(\n ({ commertialOffer = {} }) => commertialOffer.AvailableQuantity > 0\n )\n}\n\nconst defaultImage = { imageUrl: '', imageLabel: '' }\nconst defaultReference = { Value: '' }\nconst defaultSeller = { commertialOffer: { Price: 0, ListPrice: 0 } }\n\nconst resizeImage = (url, imageSize) =>\n changeImageUrlSize(toHttps(url), imageSize)\n\nexport function mapCatalogProductToProductSummary(product, imageSize = 500) {\n if (!product) return null\n const normalizedProduct = { ...product }\n const items = normalizedProduct.items || []\n const sku = items.find(findAvailableProduct) || items[0]\n if (sku) {\n const [seller = defaultSeller] = pathOr([], ['sellers'], sku)\n const [referenceId = defaultReference] = pathOr([], ['referenceId'], sku)\n const catalogImages = pathOr([], ['images'], sku)\n const normalizedImages = catalogImages.map(image => ({\n ...image,\n imageUrl: resizeImage(image.imageUrl, imageSize),\n }))\n const [image = defaultImage] = normalizedImages\n normalizedProduct.sku = {\n ...sku,\n seller,\n referenceId,\n image,\n images: normalizedImages,\n }\n }\n return normalizedProduct\n}\n\n```" } ]
code_store-on-localhost_b74ce081
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/utils/attachmentHelper.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport { pathOr } from 'ramda'\n\nexport const CHOICE_TYPES = {\n SINGLE: 'SINGLE',\n MULTIPLE: 'MULTIPLE',\n TOGGLE: 'TOGGLE',\n}\n\nexport const getProductPrice = product =>\n pathOr(0, ['sku', 'seller', 'commertialOffer', 'Price'], product)\n\n```" } ]
code_store-on-localhost_3eb5f210
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/utils/displayButtonTypes.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport { values, map } from 'ramda'\n\nconst displayButtonTypes = {\n DISPLAY_ALWAYS: {\n name: 'admin/editor.productSummary.displayBuyButton.option.always',\n value: 'displayButtonAlways',\n },\n DISPLAY_ON_HOVER: {\n name: 'admin/editor.productSummary.displayBuyButton.option.hover',\n value: 'displayButtonHover',\n },\n DISPLAY_NONE: {\n name: 'admin/editor.productSummary.displayBuyButton.option.none',\n value: 'displayButtonNone',\n },\n}\n\nexport function getDisplayButtonNames() {\n return map(opt => opt.name, values(displayButtonTypes))\n}\n\nexport function getDisplayButtonValues() {\n return map(opt => opt.value, values(displayButtonTypes))\n}\n\nexport default displayButtonTypes\n\n```" } ]
code_store-on-localhost_4e868abf
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/utils/propTypes.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\nimport { CHOICE_TYPES } from './attachmentHelper'\n\nexport const addedOptionShape = PropTypes.shape({\n item: PropTypes.shape({\n name: PropTypes.string.isRequired,\n sellingPrice: PropTypes.number.isRequired,\n quantity: PropTypes.number.isRequired,\n }),\n normalizedQuantity: PropTypes.number,\n extraQuantity: PropTypes.number,\n choiceType: PropTypes.oneOf([\n CHOICE_TYPES.SINGLE,\n CHOICE_TYPES.MULTIPLE,\n CHOICE_TYPES.TOGGLE,\n ]).isRequired,\n})\n\nexport const removedOptionShape = PropTypes.shape({\n removedQuantity: PropTypes.number.isRequired,\n initialQuantity: PropTypes.number.isRequired,\n name: PropTypes.string.isRequired,\n})\n\nexport const productShape = PropTypes.shape({\n /** Product's id */\n productId: PropTypes.string.isRequired,\n /** Product's link text */\n linkText: PropTypes.string.isRequired,\n /** Product's name */\n productName: PropTypes.string.isRequired,\n /** Product's brand */\n brand: PropTypes.string,\n /** Product's brand id */\n brandId: PropTypes.number,\n /** Product's SKU */\n sku: PropTypes.shape({\n /** SKU name */\n name: PropTypes.string.isRequired,\n /** SKU id */\n itemId: PropTypes.string.isRequired,\n /** SKU Image to be shown */\n image: PropTypes.shape({\n /** Image URL */\n imageUrl: PropTypes.string.isRequired,\n /** Image tag as string */\n imageTag: PropTypes.string,\n }).isRequired,\n /** SKU seller */\n seller: PropTypes.shape({\n /** Seller id */\n sellerId: PropTypes.string,\n /** Seller comertial offer */\n commertialOffer: PropTypes.shape({\n /** SKU installments */\n Installments: PropTypes.arrayOf(\n PropTypes.shape({\n /** Installment value */\n Value: PropTypes.number.isRequired,\n /** Interest rate (zero if interest-free) */\n InterestRate: PropTypes.number.isRequired,\n /** Calculated total value */\n TotalValuePlusInterestRate: PropTypes.number,\n /** Number of installments */\n NumberOfInstallments: PropTypes.number.isRequired,\n /** Installments offer name */\n Name: PropTypes.string,\n })\n ),\n /** Selling Price */\n Price: PropTypes.number.isRequired,\n /** List Price */\n ListPrice: PropTypes.number.isRequired,\n }).isRequired,\n }).isRequired,\n }).isRequired,\n /** Product's collections */\n productClusters: PropTypes.arrayOf(\n PropTypes.shape({\n name: PropTypes.string.isRequired,\n })\n ),\n /** Contains relevant assembly options information */\n assemblyOptions: PropTypes.shape({\n added: PropTypes.arrayOf(addedOptionShape),\n removed: PropTypes.arrayOf(removedOptionShape),\n parentPrice: PropTypes.number,\n }),\n /** Quantity of item in Minicart */\n quantity: PropTypes.number,\n})\n\n```" } ]
code_store-on-localhost_2763a6cc
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductSummaryContext.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { createContext } from 'react'\n\nconst ProductSummaryContext = createContext(0)\n\nconst OriginalConsumer = ProductSummaryContext.Consumer\nProductSummaryContext.Consumer = function WrappedConsumer(props) {\n console.error(\n \"If you are seeing this, a component it's using ProductSummaryContext from vtex.product-summary, which is deprecated. Please see the issue https://github.com/vtex-apps/store-issues#28 on how to migrate to the new component.\"\n )\n\n return <OriginalConsumer {...props} />\n}\n\nexport default ProductSummaryContext\n\n```" } ]
code_store-on-localhost_eefb8c17
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductSummary.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { useCallback, useMemo, useEffect } from 'react'\nimport PropTypes from 'prop-types'\nimport classNames from 'classnames'\nimport { pathOr, path } from 'ramda'\nimport { useInView } from 'react-intersection-observer'\nimport { Link } from '../../../../../vtex.render-runtime'\nimport ProductListContext from '../../ProductListContext/ProductListContext'\nimport ProductSummaryContext from './ProductSummaryContext'\nimport ProductSummaryContextApp from '../../ProductSummaryContext/ProductSummaryContext'\nimport ProductContextProvider from '../../ProductContext/ProductContextProvider'\nimport { productShape } from '../utils/propTypes'\nimport { mapCatalogProductToProductSummary } from '../utils/normalize'\nimport useCssHandles from '../../CssHandles/useCssHandles'\n\nconst {\n ProductSummaryProvider,\n useProductSummaryDispatch,\n useProductSummary } = ProductSummaryContextApp\nconst PRODUCT_SUMMARY_MAX_WIDTH = 300\nconst CSS_HANDLES = ['container', 'containerNormal', 'element', 'clearLink']\n\nconst ProductSummaryCustom = ({\n product,\n actionOnClick,\n children,\n containerRef,\n}) => {\n const { isLoading, isHovering, selectedItem, query } = useProductSummary()\n const dispatch = useProductSummaryDispatch()\n const handles = useCssHandles(CSS_HANDLES)\n\n /*\n Use ProductListContext to send pixel events.\n Beware that productListDispatch could be undefined if\n this component is not wrapped by a <ProductListContextProvider/>.\n In that case we don't need to send events.\n */\n const { useProductListDispatch } = ProductListContext\n const productListDispatch = useProductListDispatch()\n const [inViewRef, inView] = useInView({\n // Triggers the event when the element is 75% visible\n threshold: 0.75,\n triggerOnce: true,\n })\n useEffect(() => {\n if (inView) {\n productListDispatch &&\n productListDispatch({\n type: 'SEND_IMPRESSION',\n args: { product: product },\n })\n }\n }, [productListDispatch, inView, product])\n\n useEffect(() => {\n if (product) {\n dispatch({\n type: 'SET_PRODUCT',\n args: { product },\n })\n }\n }, [product, dispatch])\n\n const handleMouseLeave = useCallback(() => {\n dispatch({\n type: 'SET_HOVER',\n args: { isHovering: false },\n })\n }, [dispatch])\n\n const handleMouseEnter = useCallback(() => {\n dispatch({\n type: 'SET_HOVER',\n args: { isHovering: true },\n })\n }, [dispatch])\n\n const handleItemsStateUpdate = useCallback(\n isLoading => {\n dispatch({\n type: 'SET_LOADING',\n args: { isLoading },\n })\n },\n [dispatch]\n )\n\n const oldContextProps = useMemo(\n () => ({\n product,\n isLoading,\n isHovering,\n handleItemsStateUpdate: handleItemsStateUpdate,\n }),\n [product, isLoading, isHovering, handleItemsStateUpdate]\n )\n\n const containerClasses = classNames(\n handles.container,\n handles.containerNormal,\n 'overflow-hidden br3 h-100 w-100 flex flex-column justify-between center tc'\n )\n\n const summaryClasses = classNames(\n handles.element,\n 'pointer pt3 pb4 flex flex-column h-100'\n )\n\n const linkClasses = classNames(handles.clearLink, 'h-100 flex flex-column')\n\n const skuId = pathOr(\n path(['sku', 'itemId'], product),\n ['itemId'],\n selectedItem\n )\n\n return (\n <ProductSummaryContext.Provider value={oldContextProps}>\n <ProductContextProvider product={product} query={{ skuId }}>\n <section\n className={containerClasses}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n style={{ maxWidth: PRODUCT_SUMMARY_MAX_WIDTH }}\n // If containerRef is passed, it should be used\n ref={containerRef || inViewRef}\n >\n <Link\n className={linkClasses}\n page=\"store.product\"\n params={{\n slug: product && product.linkText,\n id: product && product.productId,\n }}\n query={query}\n onClick={actionOnClick}\n >\n <article className={summaryClasses}>{children}</article>\n </Link>\n </section>\n </ProductContextProvider>\n </ProductSummaryContext.Provider>\n )\n}\n\nProductSummaryCustom.propTypes = {\n /** Product that owns the informations */\n product: productShape,\n /** Function that is executed when a product is clicked */\n actionOnClick: PropTypes.func,\n children: PropTypes.node,\n containerRef: PropTypes.oneOfType([\n // Either a function\n PropTypes.func,\n // Or the instance of a DOM native element\n PropTypes.shape({ current: PropTypes.instanceOf(PropTypes.Element) }),\n ]),\n}\n\nfunction ProductSummaryWrapper(props) {\n return (\n <ProductSummaryProvider {...props}>\n <ProductSummaryCustom {...props} />\n </ProductSummaryProvider>\n )\n}\n\nProductSummaryWrapper.getSchema = () => {\n return {\n title: 'admin/editor.productSummary.title',\n description: 'admin/editor.productSummary.description',\n }\n}\n\n// This function is public available to be used only by vtex.shelf and vtex.search-result.\n// We do not garantee this API will not change and might happen breaking change anytime.\nProductSummaryWrapper.mapCatalogProductToProductSummary = mapCatalogProductToProductSummary\n\nexport default ProductSummaryWrapper\n\n```" } ]
code_store-on-localhost_a5107587
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductListEventCaller.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport useProductImpression from '../../ProductListContext/useProductImpression'\n\nconst ProductListEventCaller = () => {\n useProductImpression()\n return null\n}\n\nexport default ProductListEventCaller\n\n```" } ]
code_store-on-localhost_fa0be934
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/__tests__/ProductSummary.test.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport ProductSummary from '../ProductSummaryCustom'\n\ndescribe('<ProductSummary /> component', () => {\n it(`should parse a product succesfully and get sku as the first with available quantity`, () => {\n const product = {\n productId: '123456789',\n linkText: 'linkText',\n productName: 'productName',\n items: [\n {\n itemId: '1',\n name: 'item 1',\n sellers: [\n {\n sellerId: '1',\n commertialOffer: {\n AvailableQuantity: 0,\n Price: 10,\n },\n },\n ],\n images: [\n {\n imageUrl: 'image1',\n imageLabel: null,\n },\n {\n imageUrl: 'image2',\n imageLabel: null,\n },\n ],\n },\n {\n itemId: '2',\n name: 'item 2',\n sellers: [\n {\n sellerId: '1',\n commertialOffer: {\n AvailableQuantity: 3,\n Price: 15,\n },\n },\n ],\n images: [\n {\n imageUrl: 'image1',\n imageLabel: null,\n },\n {\n imageUrl: 'image2',\n imageLabel: null,\n },\n ],\n },\n ],\n productClusters: [\n {\n name: 'name',\n },\n ],\n quantity: 1,\n }\n const result = ProductSummary.mapCatalogProductToProductSummary(product)\n expect(result).toBeDefined()\n expect(result.sku.seller.sellerId).toBe('1')\n expect(result.sku.image).toBeDefined()\n expect(result.sku.itemId).toBe('2')\n })\n it(`should not break ProductSummary getSchema`, () => {\n expect(ProductSummary.getSchema).toEqual(expect.any(Function))\n })\n})\n\n```" } ]
code_store-on-localhost_888198bb
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/__tests__/ProductSummaryLegacy.test.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport { render } from '@vtex/test-tools/react'\nimport fs from 'fs'\n\nimport ProductSummary from '../legacy/index'\n\ndescribe('<ProductSummary /> component', () => {\n // TODO: Remove this later when we have a better way to resolve contentSchemas.json at test-tools\n const rawData = fs.readFileSync('../store/contentSchemas.json')\n const contentSchema = JSON.parse(rawData)\n const buyButtonText =\n contentSchema.definitions.ProductSummary.properties.buyButtonText.default\n\n const props = {\n runtime: { hints: {} },\n buyButtonText,\n product: {\n productId: '123456789',\n linkText: 'linkText',\n productName: 'productName',\n sku: {\n name: 'name',\n itemId: 'itemId',\n image: {\n imageUrl: '',\n },\n seller: {\n sellerId: 'sellerId',\n commertialOffer: {\n Installments: [\n {\n Value: 1,\n InterestRate: 1,\n NumberOfInstallments: 1,\n },\n ],\n Price: 1,\n ListPrice: 1,\n },\n },\n },\n productClusters: [\n {\n name: 'name',\n },\n ],\n quantity: 1,\n },\n }\n\n function renderComponent(customProps) {\n return render(<ProductSummary {...props} {...customProps} />)\n }\n\n it('should match the snapshot for normal mode', () => {\n const { asFragment } = renderComponent({ displayMode: 'normal' })\n expect(asFragment()).toMatchSnapshot()\n })\n\n it('should match the snapshot for small mode', () => {\n const { asFragment } = renderComponent({ displayMode: 'small' })\n expect(asFragment()).toMatchSnapshot()\n })\n\n it('should match the snapshot for inline normal mode', () => {\n const { asFragment } = renderComponent({ displayMode: 'inline' })\n expect(asFragment()).toMatchSnapshot()\n })\n\n it('should match the snapshot for inline price mode', () => {\n const { asFragment } = renderComponent({ displayMode: 'inlinePrice' })\n expect(asFragment()).toMatchSnapshot()\n })\n\n it('should render buy button in inline, small and normal mode', () => {\n const { getByText, rerender, container } = renderComponent({\n displayMode: 'normal',\n })\n expect(getByText('Buy')).toBeTruthy()\n\n rerender(<ProductSummary {...props} displayMode=\"small\" />)\n expect(getByText('Buy')).toBeTruthy()\n\n rerender(<ProductSummary {...props} displayMode=\"inline\" />)\n expect(getByText('Buy')).toBeTruthy()\n\n rerender(<ProductSummary {...props} displayMode=\"inlinePrice\" />)\n expect(container.querySelector('.buyButtonContainer')).toBeFalsy()\n })\n\n it('should render quantity stepper only in inline price mode', () => {\n const { container, rerender } = renderComponent({ displayMode: 'normal' })\n expect(container.querySelector('.quantityStepperContainer')).toBeFalsy()\n\n rerender(<ProductSummary {...props} displayMode=\"inlinePrice\" />)\n expect(container.querySelector('.quantityStepperContainer')).toBeTruthy()\n\n rerender(<ProductSummary {...props} displayMode=\"small\" />)\n expect(container.querySelector('.quantityStepperContainer')).toBeFalsy()\n\n rerender(<ProductSummary {...props} displayMode=\"inline\" />)\n expect(container.querySelector('.quantityStepperContainer')).toBeFalsy()\n })\n\n it(`should not break Shelf getSchema`, () => {\n expect(ProductSummary.getSchema).toEqual(expect.any(Function))\n })\n\n describe('Site editor editable', () => {\n it('should export getSchema and return object with title', () => {\n const schema = ProductSummary.schema || ProductSummary.getSchema({})\n expect(schema).toEqual(\n expect.objectContaining({ title: expect.any(String) })\n )\n })\n })\n})\n\n```" } ]
code_store-on-localhost_d31bc102
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/legacy/components/ProductSummaryNormal.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport { path } from 'ramda'\nimport classNames from 'classnames'\nimport { ExtensionPoint, Link } from '../../../../../../vtex.render-runtime'\n\nimport AttachmentList from './AttachmentList'\nimport ProductImage from './ProductImage'\nimport ProductSummaryBuyButton from './ProductSummaryBuyButton'\nimport ProductSummaryPrice from './ProductSummaryPrice'\nimport ProductSummaryName from './ProductSummaryName'\nimport ProductSummaryDescription from './ProductSummaryDescription'\n\nimport productSummary from '../../productSummary.css'\n\nclass ProductSummaryNormal extends Component {\n render() {\n const {\n product,\n showBorders,\n showDescription,\n handleMouseEnter,\n handleMouseLeave,\n actionOnClick,\n imageProps,\n nameProps,\n priceProps,\n buyButtonProps,\n } = this.props\n\n const containerClasses = classNames(\n productSummary.container,\n productSummary.containerNormal,\n 'overflow-hidden br3 h-100 w-100 flex flex-column justify-between center tc'\n )\n\n const summaryClasses = classNames(\n `${productSummary.element} pointer pt3 pb4 flex flex-column h-100`,\n {\n 'bb b--muted-4 mh2 mt2': showBorders,\n }\n )\n\n const nameClasses = {\n containerClass: `flex items-start ${productSummary.nameContainer} justify-center pv6`,\n brandNameClass: 't-body',\n }\n\n const priceClasses = {\n containerClass: classNames(\n 'flex flex-column justify-end items-center relative',\n {\n [`${productSummary.priceContainer} pv5`]: !showBorders,\n }\n ),\n sellingPriceClass: 'dib ph2 t-body t-heading-5-ns',\n }\n\n const buyButtonClasses = {\n containerClass: `${productSummary.buyButtonContainer} pv3 w-100 db`,\n }\n\n const descriptionClasses = `${productSummary.description} c-muted-2 t-small`\n\n return (\n <section\n className={containerClasses}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n <div className={`${productSummary.addToListBtn} absolute z-1 mt3`}>\n <ExtensionPoint\n id=\"addon-summary-btn\"\n product={{\n skuId: path(['sku', 'itemId'], product),\n productId: path(['productId'], product),\n quantity: 1,\n }}\n />\n </div>\n <Link\n className={`${productSummary.clearLink} h-100 flex flex-column`}\n page={'store.product'}\n params={{\n slug: product && product.linkText,\n id: product && product.productId,\n }}\n onClick={actionOnClick}\n >\n <article className={summaryClasses}>\n <div className={`${productSummary.imageContainer} db w-100 center`}>\n <ProductImage {...imageProps} />\n </div>\n <div\n className={`${productSummary.information} h-100 flex flex-column justify-between`}\n >\n <ProductSummaryName {...nameProps} {...nameClasses} />\n <AttachmentList product={product} />\n {showDescription && (\n <ProductSummaryDescription\n description={product.description}\n descriptionClasses={descriptionClasses}\n />\n )}\n <div>\n <ProductSummaryPrice {...priceProps} {...priceClasses} />\n </div>\n </div>\n </article>\n <ProductSummaryBuyButton {...buyButtonProps} {...buyButtonClasses} />\n </Link>\n </section>\n )\n }\n}\n\nexport default ProductSummaryNormal\n\n```" } ]
code_store-on-localhost_b91f088d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/legacy/components/ProductSummarySmall.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport { path } from 'ramda'\nimport classNames from 'classnames'\nimport { Link } from '../../../../../../vtex.render-runtime'\n\nimport AttachmentList from './AttachmentList'\nimport ProductImage from './ProductImage'\nimport ProductSummaryBuyButton from './ProductSummaryBuyButton'\nimport ProductSummaryPrice from './ProductSummaryPrice'\nimport ProductSummaryName from './ProductSummaryName'\n\nimport styles from '../../productSummary.css'\n\nclass ProductSummarySmall extends Component {\n render() {\n const {\n product,\n showBorders,\n handleMouseEnter,\n handleMouseLeave,\n actionOnClick,\n imageProps,\n nameProps,\n priceProps,\n buyButtonProps,\n } = this.props\n\n const containerClasses = classNames(\n styles.container,\n styles.containerSmall,\n 'overflow-hidden br3 h-100 flex flex-column justify-between center tc'\n )\n\n const summaryClasses = classNames(\n styles.element,\n 'pointer pt3 pb4 flex flex-column',\n {\n 'bb b--muted-4 mh2 mt2': showBorders,\n }\n )\n\n const nameClasses = {\n containerClass: `flex items-start ${styles.nameContainer} justify-center pv5 t-mini pb2`,\n brandNameClass: 't-body t-mini',\n }\n\n const priceClasses = {\n containerClass: classNames('flex flex-column justify-end items-center', {\n [`${styles.priceContainer} pv5`]: !showBorders,\n }),\n sellingPriceClass: 'dib ph2 t-body t-heading-5-ns',\n }\n\n const buyButtonClasses = {\n containerClass: `${styles.buyButtonContainer} pv3 w-100 dn`,\n }\n\n return (\n <section\n className={containerClasses}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n <Link\n className={`${styles.clearLink} flex flex-column`}\n page={'store.product'}\n params={{ slug: path(['linkText'], product) }}\n onClick={actionOnClick}\n >\n <article className={summaryClasses}>\n <div className={`${styles.imageContainer} db w-100 center`}>\n <ProductImage {...imageProps} />\n </div>\n <div className={styles.information}>\n <ProductSummaryName {...nameProps} {...nameClasses} />\n <AttachmentList product={product} />\n <div>\n <ProductSummaryPrice {...priceProps} {...priceClasses} />\n </div>\n </div>\n </article>\n <ProductSummaryBuyButton {...buyButtonProps} {...buyButtonClasses} />\n </Link>\n </section>\n )\n }\n}\n\nexport default ProductSummarySmall\n\n```" } ]
code_store-on-localhost_d155c2ce
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/legacy/components/ProductSummaryInlinePrice.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport classNames from 'classnames'\nimport { Link } from '../../../../../../vtex.render-runtime'\n\nimport AttachmentList from './AttachmentList'\nimport ProductImage from './ProductImage'\nimport ProductQuantityStepper from './ProductQuantityStepper'\nimport ProductSummaryPrice from './ProductSummaryPrice'\nimport ProductSummaryName from './ProductSummaryName'\n\nimport styles from '../../productSummary.css'\n\nconst ProductSummaryInlinePrice = ({\n product,\n showBorders,\n handleMouseEnter,\n handleMouseLeave,\n handleItemsStateUpdate,\n actionOnClick,\n imageProps,\n nameProps,\n priceProps,\n showQuantitySelector,\n priceAlignLeft,\n muted,\n index,\n}) => {\n const containerClasses = classNames(\n styles.container,\n styles.containerInline,\n 'br3 h-100 w-100'\n )\n\n const summaryClasses = classNames(\n `${styles.element} pointer ph2 pt3 pb4 flex flex-column h-100`,\n {\n 'bb b--muted-4 mh2 mh3-ns mt2': showBorders,\n }\n )\n\n const nameClasses = {\n containerClass: classNames(\n 'flex items-start justify-left tl w-90 t-mini pb2',\n { 'c-muted-1': muted }\n ),\n brandNameClass: classNames('t-body', {\n 'c-muted-1': muted,\n 'c-on-base': !muted,\n }),\n skuNameClass: classNames('t-small', {\n 'c-muted-2': muted,\n }),\n }\n\n const priceClasses = {\n containerClass: classNames('flex flex-column nr1 h1', {\n 'items-start': priceAlignLeft,\n 'items-end': !priceAlignLeft,\n [`${styles.priceContainer} pv5`]: !showBorders,\n }),\n sellingPriceClass: classNames('dib ph2 t-body t-heading-5-ns', {\n 'c-muted-1': muted,\n }),\n }\n\n return (\n <section\n className={containerClasses}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n <article className={summaryClasses}>\n <Link\n className={`${styles.clearLink} flex h-100`}\n page=\"store.product\"\n params={{\n slug: product && product.linkText,\n id: product && product.productId,\n }}\n onClick={actionOnClick}\n >\n <div className={`${styles.imageContainer} db h-100`}>\n <ProductImage {...imageProps} />\n </div>\n <div className={`${styles.information} w-70 pb2 ph3`}>\n <ProductSummaryName {...nameProps} {...nameClasses} />\n <AttachmentList product={product} />\n <div className=\"mv3 nr2\">\n <div\n onClick={e => {\n e.preventDefault()\n // Stop propagation so it doesn't trigger the Link component above\n e.stopPropagation()\n }}\n className={`flex justify-end nr4 mb2 ${styles.quantityStepperContainer}`}\n >\n {showQuantitySelector && (\n <ProductQuantityStepper\n product={product}\n onUpdateItemsState={handleItemsStateUpdate}\n index={index}\n />\n )}\n </div>\n <ProductSummaryPrice {...priceProps} {...priceClasses} />\n </div>\n </div>\n </Link>\n </article>\n </section>\n )\n}\n\nexport default ProductSummaryInlinePrice\n\n```" } ]
code_store-on-localhost_97ec5967
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/legacy/components/ProductSummaryName.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { path } from 'ramda'\nimport ProductName from '../../../StoreComponents/ProductName'\n\nimport { productShape } from '../../utils/propTypes'\n\nconst ProductSummaryName = ({\n product,\n showFieldsProps,\n containerClass,\n brandNameClass,\n skuNameClass,\n}) => {\n const productName = path(['productName'], product)\n const skuName = path(['sku', 'name'], product)\n const brandName = path(['brand'], product)\n\n return (\n <div className={containerClass}>\n <ProductName\n className=\"overflow-hidden c-on-base\"\n brandNameClass={brandNameClass}\n skuNameClass={skuNameClass}\n loaderClass=\"pt5 overflow-hidden\"\n name={productName}\n skuName={skuName}\n brandName={brandName}\n {...showFieldsProps}\n />\n </div>\n )\n}\n\nProductSummaryName.propTypes = {\n /** Product that owns the informations */\n product: productShape,\n /** Name schema props */\n showFieldsProps: PropTypes.object,\n /** Styles used in the container div */\n containerClass: PropTypes.string,\n /** Styles used in the brand name */\n brandNameClass: PropTypes.string,\n}\n\nexport default ProductSummaryName\n\n```" } ]
code_store-on-localhost_b7c2dad6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/legacy/components/ProductSummaryPrice.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { path, prop } from 'ramda'\n\nimport Spinner from '../../../Styleguide/Spinner'\nimport ProductPrice from '../../../StoreComponents/ProductPrice'\n\nimport { productShape } from '../../utils/propTypes'\n\nconst ProductSummaryPrice = ({\n product,\n showListPrice,\n showLabels,\n showInstallments,\n labelSellingPrice,\n labelListPrice,\n isLoading,\n containerClass,\n sellingPriceClass,\n}) => {\n const commertialOffer = path(['sku', 'seller', 'commertialOffer'], product)\n\n if (isLoading) {\n return (\n <div className=\"flex items-end justify-end w-100 h1 pr6\">\n <Spinner size={20} />\n </div>\n )\n }\n\n const sellingPrice = prop('Price', commertialOffer)\n\n return (\n <div className={containerClass}>\n {sellingPrice !== 0 && (\n <ProductPrice\n className=\"flex flex-column justify-start\"\n listPriceContainerClass=\"pv1 normal c-muted-2\"\n listPriceLabelClass=\"dib strike t-small t-mini\"\n listPriceClass=\"dib ph2 strike t-small-ns t-mini\"\n sellingPriceContainerClass=\"pt1 pb3 c-on-base\"\n sellingPriceLabelClass=\"dib\"\n sellingPriceClass={sellingPriceClass}\n savingsContainerClass=\"t-small-ns c-muted-2\"\n savingsClass=\"dib\"\n interestRateClass=\"dib pl2\"\n installmentContainerClass=\"t-small-ns c-muted-2\"\n listPrice={prop('ListPrice', commertialOffer)}\n sellingPrice={prop('Price', commertialOffer)}\n installments={prop('Installments', commertialOffer)}\n showListPrice={showListPrice}\n showLabels={showLabels}\n showInstallments={showInstallments}\n labelSellingPrice={labelSellingPrice}\n labelListPrice={labelListPrice}\n />\n )}\n </div>\n )\n}\n\nProductSummaryPrice.propTypes = {\n /** Product that owns the informations */\n product: productShape,\n /** Set the product list price's visibility */\n showListPrice: PropTypes.bool,\n /** Set pricing labels' visibility */\n showLabels: PropTypes.bool,\n /** Set installments' visibility */\n showInstallments: PropTypes.bool,\n /** Text of selling Price's label */\n labelSellingPrice: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),\n /** Text of selling Price's label */\n labelListPrice: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),\n /** Defines if the loading spinner is shown */\n isLoading: PropTypes.bool,\n /** Styles used in the container div */\n containerClass: PropTypes.string,\n /** Styles used in the selling price */\n sellingPriceClass: PropTypes.string,\n}\n\nexport default ProductSummaryPrice\n\n```" } ]
code_store-on-localhost_79d86fd6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/legacy/components/ProductSummaryDescription.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Fragment } from 'react'\nimport PropTypes from 'prop-types'\n\nconst MAX_SIZE_DESCRIPTION = 120\n\nconst ProductSummaryDescription = ({ descriptionClasses, description }) => {\n if (!description) return <Fragment />\n\n const descriptionTruncated =\n description.length > MAX_SIZE_DESCRIPTION\n ? `${description.substring(0, MAX_SIZE_DESCRIPTION)}...`\n : description\n\n return <span className={descriptionClasses}>{descriptionTruncated}</span>\n}\n\nProductSummaryDescription.propTypes = {\n /** Styles used in the description */\n\n descriptionClasses: PropTypes.string.isRequired,\n /** Description of the product */\n\n description: PropTypes.string,\n}\n\nexport default ProductSummaryDescription\n\n```" } ]
code_store-on-localhost_095ff364
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/legacy/components/ProductSummaryBuyButton.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport BuyButton from '../../../StoreComponents/BuyButton'\nimport { equals, path } from 'ramda'\nimport classNames from 'classnames'\nimport IOMessage from '../../../NativeTypes/IOMessage'\nimport { useRuntime } from '../../../../../../vtex.render-runtime'\n\nimport displayButtonTypes from '../../utils/displayButtonTypes'\nimport productSummary from '../../productSummary.css'\n\nconst ProductSummaryBuyButton = ({\n product,\n displayBuyButton,\n isOneClickBuy,\n buyButtonText,\n isHovering,\n containerClass,\n}) => {\n const {\n hints: { mobile },\n } = useRuntime()\n\n const hoverBuyButton =\n equals(displayBuyButton, displayButtonTypes.DISPLAY_ALWAYS.value) ||\n !equals(displayBuyButton, displayButtonTypes.DISPLAY_ON_HOVER.value) ||\n (isHovering && !mobile)\n\n const showBuyButton =\n !equals(displayBuyButton, displayButtonTypes.DISPLAY_NONE.value) &&\n !(\n equals(displayBuyButton, displayButtonTypes.DISPLAY_ON_HOVER.value) &&\n mobile\n )\n\n const buyButtonClasses = classNames(\n `${productSummary.buyButton} center mw-100`,\n {\n [productSummary.isHidden]: !hoverBuyButton,\n }\n )\n\n // TODO: change ProductSummaryContext to have `selectedSku` field instead of `sku`\n const selectedItem = product.sku\n const selectedSeller = path(['seller'], selectedItem)\n const isAvailable =\n selectedSeller &&\n selectedSeller.commertialOffer &&\n selectedSeller.commertialOffer.AvailableQuantity > 0\n const skuItems = BuyButton.mapCatalogItemToCart({\n product,\n selectedItem,\n selectedSeller,\n selectedQuantity: 1,\n })\n\n return (\n showBuyButton && (\n <div className={containerClass}>\n <div className={buyButtonClasses}>\n <BuyButton\n available={isAvailable}\n skuItems={skuItems}\n isOneClickBuy={isOneClickBuy}\n >\n <IOMessage id={buyButtonText} />\n </BuyButton>\n </div>\n </div>\n )\n )\n}\n\nexport default ProductSummaryBuyButton\n\n```" } ]
code_store-on-localhost_2a8a7fe0
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/legacy/components/ProductQuantityStepper.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport { compose, path } from 'ramda'\nimport PropTypes from 'prop-types'\nimport NumericStepper from '../../../Styleguide/NumericStepper'\nimport withToast from '../../../Styleguide/withToast'\nimport PixelContext from '../../../PixelContext/PixelContext'\nimport { debounce } from 'debounce'\nimport { injectIntl } from 'react-intl'\nimport { graphql } from 'react-apollo'\nimport gql from 'graphql-tag'\n\nimport { productShape } from '../../utils/propTypes'\n\nconst { Pixel } = PixelContext\nconst UPDATE_ITEMS_MUTATION = gql`\n mutation updateItemsStepper($items: [MinicartItem]) {\n updateItems(items: $items) @client\n }\n`\n\nconst UPDATE_LOCAL_ITEMS_MUTATION = gql`\n mutation updateLocalItems($items: [MinicartItem]) {\n updateLocalItems(items: $items) @client\n }\n`\n\nclass ProductQuantityStepper extends Component {\n static propTypes = {\n product: productShape.isRequired,\n onUpdateItemsState: PropTypes.func.isRequired,\n showToast: PropTypes.func,\n minicartItems: PropTypes.array,\n updateItems: PropTypes.func.isRequired,\n updateLocalItems: PropTypes.func.isRequired,\n push: PropTypes.func.isRequired,\n index: PropTypes.number,\n }\n\n state = {\n quantity: this.props.product.quantity,\n canIncrease: true,\n }\n\n pushPixelCartEvents = ({ isAdditionOfProd, product }) => {\n const updatedProduct = {\n skuId: path(['sku', 'itemId'], product),\n variant: path(['sku', 'name'], product),\n price: path(['assemblyOptions', 'parentPrice'], product),\n name: path(['productName'], product),\n quantity: path(['quantity'], product),\n productRefId: product.productRefId,\n brand: product.brand,\n category: product.category,\n }\n if (isAdditionOfProd) {\n this.props.push({\n event: 'addToCart',\n items: [updatedProduct],\n })\n } else {\n // removal of product\n this.props.push({\n event: 'removeFromCart',\n items: [updatedProduct],\n })\n }\n }\n\n componentDidUpdate = prevProps => {\n const {\n product: { quantity: prevQuantity },\n } = prevProps\n const {\n product: { quantity },\n showToast,\n intl,\n } = this.props\n if (prevQuantity !== quantity) {\n this.pushPixelCartEvents({\n isAdditionOfProd: prevQuantity < quantity,\n product: this.props.product,\n })\n const canIncrease = quantity === this.state.quantity\n this.setState({ quantity, canIncrease })\n if (!canIncrease) {\n showToast({\n message: intl.formatMessage({\n id: 'store/productSummary.quantity-error',\n }),\n })\n }\n }\n }\n\n handleOnChange = e => {\n e.stopPropagation()\n e.preventDefault()\n this.props.onUpdateItemsState(true)\n this.setState({ quantity: e.value }, () =>\n this.debouncedUpdate(this.state.quantity)\n )\n }\n\n updateItemQuantity = async quantity => {\n const { product, updateItems, updateLocalItems, index } = this.props\n this.setState({ canIncrease: true })\n const {\n sku: { itemId: id, seller = {} },\n cartIndex,\n } = product\n try {\n if (cartIndex != null) {\n await updateItems([\n {\n id,\n quantity,\n seller: seller.sellerId,\n index: cartIndex,\n },\n ])\n } else {\n await updateLocalItems([\n {\n id,\n quantity,\n seller: seller.sellerId,\n index,\n },\n ])\n }\n } catch (err) {\n // gone wrong, rollback to old quantity value\n console.error(err)\n }\n this.props.onUpdateItemsState(false)\n }\n\n debouncedUpdate = debounce(this.updateItemQuantity, 1000)\n\n render() {\n return (\n <NumericStepper\n lean\n size=\"small\"\n value={this.state.quantity}\n minValue={1}\n maxValue={this.state.canIncrease ? undefined : this.state.quantity}\n onChange={this.handleOnChange}\n />\n )\n }\n}\n\nconst withUpdateItemsMutation = graphql(UPDATE_ITEMS_MUTATION, {\n props: ({ mutate }) => ({\n updateItems: items => mutate({ variables: { items } }),\n }),\n})\n\nconst withUpdateLocalItemsMutation = graphql(UPDATE_LOCAL_ITEMS_MUTATION, {\n props: ({ mutate }) => ({\n updateLocalItems: items => mutate({ variables: { items } }),\n }),\n})\n\nexport default compose(\n Pixel,\n injectIntl,\n withToast,\n withUpdateItemsMutation,\n withUpdateLocalItemsMutation\n)(ProductQuantityStepper)\n\n```" } ]
code_store-on-localhost_8bbf7550
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/legacy/components/ProductSummaryInline.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport classNames from 'classnames'\nimport { Link } from '../../../../../../vtex.render-runtime'\n\nimport AttachmentList from './AttachmentList'\nimport ProductImage from './ProductImage'\nimport ProductSummaryBuyButton from './ProductSummaryBuyButton'\nimport ProductSummaryPrice from './ProductSummaryPrice'\nimport ProductSummaryName from './ProductSummaryName'\n\nimport productSummary from '../../productSummary.css'\n\nclass ProductSummaryInline extends Component {\n render() {\n const {\n product,\n showBorders,\n handleMouseEnter,\n handleMouseLeave,\n actionOnClick,\n imageProps,\n nameProps,\n priceProps,\n buyButtonProps,\n } = this.props\n\n const containerClasses = classNames(\n productSummary.container,\n productSummary.containerInlinePrice,\n 'overflow-hidden br3 h-100 w-100'\n )\n\n const summaryClasses = classNames(\n `${productSummary.element} ${productSummary.clearLink} pointer pt3 pb4 flex flex-column`,\n {\n 'bb b--muted-4 mh2 mh3-ns mt2': showBorders,\n }\n )\n\n const nameClasses = {\n containerClass: 'flex items-start justify-left tl w-90 t-mini pb2',\n brandNameClass: 't-body c-on-base',\n }\n\n const priceClasses = {\n containerClass: classNames('flex flex-column nr1', {\n [`${productSummary.priceContainer}`]: !showBorders,\n }),\n sellingPriceClass: 'dib ph2 t-body t-heading-5-ns',\n }\n\n const buyButtonClasses = {\n containerClass: `${productSummary.buyButtonContainer} pt3 w-100`,\n }\n\n return (\n <section\n className={containerClasses}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n <Link\n className={summaryClasses}\n page={'store.product'}\n params={{\n slug: product && product.linkText,\n id: product && product.productId,\n }}\n onClick={actionOnClick}\n >\n <article className=\"flex\">\n <div className={`${productSummary.imageContainer} db w-70`}>\n <ProductImage {...imageProps} />\n </div>\n <div\n className={`${productSummary.information} w-80 pb2 pl3 flex flex-wrap flex-column justify-between`}\n >\n <div className=\"flex flex-column\">\n <ProductSummaryName {...nameProps} {...nameClasses} />\n <AttachmentList product={product} />\n <div className=\"nr2\">\n <ProductSummaryPrice {...priceProps} {...priceClasses} />\n </div>\n </div>\n <div className=\"flex flex-column-reverse\">\n <ProductSummaryBuyButton\n {...buyButtonProps}\n {...buyButtonClasses}\n />\n </div>\n </div>\n </article>\n </Link>\n </section>\n )\n }\n}\n\nexport default ProductSummaryInline\n\n```" } ]
code_store-on-localhost_e9893bdc
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/legacy/components/AttachmentList.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport { productShape } from '../../utils/propTypes'\nimport { pathOr, reject } from 'ramda'\n\nimport RemovedAttachmentsList from '../../components/ProductSummaryAttachmentList/RemovedAttachmentsList'\nimport AddedAttachmentsList from '../../components/ProductSummaryAttachmentList/AddedAttachmentsList'\n\nimport styles from '../../productSummary.css'\n\nconst itemShouldHide = ({ item, extraQuantity }) =>\n extraQuantity === 0 && item.sellingPriceWithAssemblies === 0\n\nconst AttachmentList = ({ product }) => {\n const addedOptions = pathOr([], ['assemblyOptions', 'added'], product)\n const removedOptions = pathOr([], ['assemblyOptions', 'removed'], product)\n\n const filteredOption = reject(itemShouldHide, addedOptions)\n\n if (filteredOption.length === 0 && removedOptions.length === 0) {\n return null\n }\n\n return (\n <div className={`${styles.attachmentListContainer} pv2`}>\n <AddedAttachmentsList\n addedOptions={filteredOption}\n />\n <RemovedAttachmentsList removedOptions={removedOptions} />\n </div>\n )\n}\n\nAttachmentList.propTypes = {\n product: productShape,\n}\n\nexport default AttachmentList\n\n```" } ]
code_store-on-localhost_500ff9f6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/legacy/components/ProductImage.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { useState } from 'react'\nimport { path, pathOr, compose } from 'ramda'\nimport PropTypes from 'prop-types'\nimport CollectionBadges from '../../../StoreComponents/CollectionBadges'\nimport DiscountBadge from '../../../StoreComponents/DiscountBadge'\nimport classNames from 'classnames'\n\nimport ImagePlaceholder from '../../components/ProductSummaryImage/ImagePlaceholder'\n\nimport { productShape } from '../../utils/propTypes'\n\nimport productSummary from '../../productSummary.css'\n\nconst maybeBadge = ({ listPrice, price, label }) => shouldShow => component => {\n if (shouldShow) {\n return (\n <DiscountBadge listPrice={listPrice} sellingPrice={price} label={label}>\n {component}\n </DiscountBadge>\n )\n }\n return component\n}\n\nconst maybeCollection = ({ productClusters }) => shouldShow => component => {\n if (shouldShow && productClusters && productClusters.length > 0) {\n const collections = productClusters.map(cl => cl.name)\n return (\n <CollectionBadges collectionBadgesText={collections}>\n {component}\n </CollectionBadges>\n )\n }\n return component\n}\n\nconst ProductImage = ({\n product,\n showBadge,\n badgeText,\n showCollections,\n displayMode,\n}) => {\n const [error, setError] = useState(false)\n if (!path(['sku', 'image', 'imageUrl'], product) || error) {\n return <ImagePlaceholder cssHandle={productSummary.imagePlaceholder} />\n }\n\n const {\n productClusters,\n productName: name,\n sku: {\n image: { imageUrl },\n },\n } = product\n\n const imageClassName = classNames({\n [productSummary.imageNormal]: displayMode !== 'inline',\n [productSummary.imageInline]: displayMode === 'inline',\n })\n\n const commertialOffer = pathOr(\n {},\n ['sku', 'seller', 'commertialOffer'],\n product\n )\n\n const withBadge = maybeBadge({\n listPrice: commertialOffer.ListPrice,\n price: commertialOffer.Price,\n label: badgeText,\n })\n const withCollection = maybeCollection({ productClusters })\n const img = (\n <img\n className={imageClassName}\n src={imageUrl}\n alt={name}\n onError={() => setError(true)}\n />\n )\n\n return compose(\n withBadge(showBadge),\n withCollection(showCollections)\n )(img)\n}\n\nProductImage.propTypes = {\n /** Product that owns the informations */\n product: productShape,\n /** Set the discount badge's visibility */\n showBadge: PropTypes.bool,\n /** Text shown on badge */\n badgeText: PropTypes.string,\n /** Defines if the collection badges are shown */\n showCollections: PropTypes.bool,\n /** Display mode of the summary */\n displayMode: PropTypes.string,\n}\n\nexport default ProductImage\n\n```" } ]
code_store-on-localhost_67607126
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductSummaryBuyButton/ProductSummaryBuyButton.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport BuyButton from '../../../StoreComponents/BuyButton'\nimport { withRuntimeContext } from '../../../../../../vtex.render-runtime'\nimport { equals, path } from 'ramda'\nimport classnames from 'classnames'\nimport IOMessage from '../../../NativeTypes/IOMessage'\n\nimport ProductSummaryContextApp from '../../../ProductSummaryContext/ProductSummaryContext'\nconst { useProductSummary } = ProductSummaryContextApp\nimport displayButtonTypes, {\n getDisplayButtonNames,\n getDisplayButtonValues,\n} from '../../utils/displayButtonTypes'\n\nimport productSummary from '../../productSummary.css'\nimport useCssHandles from '../../../CssHandles/useCssHandles'\n\nconst ALWAYS_GO_TO_PRODUCT = 'alwaysGoToProduct'\nconst DEFAULT_BUTTON_BEHAVIOR = 'default'\nconst BUY_BUTTON_BEHAVIOR_OPTIONS = [\n ALWAYS_GO_TO_PRODUCT,\n DEFAULT_BUTTON_BEHAVIOR,\n]\nconst CSS_HANDLES = ['buyButton', 'buyButtonContainer']\n\nconst ProductSummaryBuyButton = ({\n displayBuyButton,\n isOneClickBuy,\n buyButtonText,\n customToastURL,\n runtime: {\n hints: { mobile },\n },\n buyButtonBehavior,\n isHovering,\n}) => {\n const { product, selectedItem, selectedQuantity } = useProductSummary()\n const handles = useCssHandles(CSS_HANDLES)\n\n const hoverBuyButton =\n equals(displayBuyButton, displayButtonTypes.DISPLAY_ALWAYS.value) ||\n !equals(displayBuyButton, displayButtonTypes.DISPLAY_ON_HOVER.value) ||\n (isHovering && !mobile)\n\n const showBuyButton =\n !equals(displayBuyButton, displayButtonTypes.DISPLAY_NONE.value) &&\n !(\n equals(displayBuyButton, displayButtonTypes.DISPLAY_ON_HOVER.value) &&\n mobile\n )\n\n const buyButtonClasses = classnames(\n handles.buyButton,\n 'center mw-100',\n {\n [productSummary.isHidden]: !hoverBuyButton,\n }\n )\n\n const containerClass = classnames(\n handles.buyButtonContainer,\n 'pv3 w-100 db'\n )\n\n const selectedSeller = path(['seller'], selectedItem)\n const isAvailable =\n selectedSeller &&\n selectedSeller.commertialOffer &&\n selectedSeller.commertialOffer.AvailableQuantity > 0\n const skuItems = BuyButton.mapCatalogItemToCart({\n product,\n selectedItem,\n selectedSeller,\n selectedQuantity,\n })\n\n const { items = [] } = product\n // if the item is not available the behavior is just show the disabled BuyButton,\n // but you still can go to the product page clicking in the summary\n const shouldBeALink =\n (items.length !== 1 || buyButtonBehavior !== DEFAULT_BUTTON_BEHAVIOR) &&\n isAvailable\n\n return (\n showBuyButton && (\n <div\n className={containerClass}\n data-testid=\"product-summary__buy-button-container\"\n >\n <div className={buyButtonClasses}>\n <BuyButton\n skuItems={skuItems}\n available={isAvailable}\n isOneClickBuy={isOneClickBuy}\n customToastURL={customToastURL}\n shouldAddToCart={!shouldBeALink}\n >\n <IOMessage id={buyButtonText} />\n </BuyButton>\n </div>\n </div>\n )\n )\n}\n\nProductSummaryBuyButton.propTypes = {\n /** Runtime context */\n runtime: PropTypes.shape({\n hints: PropTypes.shape({\n /** Indicates if is on a mobile device */\n mobile: PropTypes.bool,\n }),\n }),\n /** What the buy button should do when you click it, if you pass default it will add to cart only if there is only one SKU of that product */\n buyButtonBehavior: PropTypes.oneOf(BUY_BUTTON_BEHAVIOR_OPTIONS),\n /** Should redirect to checkout after clicking on buy */\n isOneClickBuy: PropTypes.bool,\n /** Custom buy button text */\n buyButtonText: PropTypes.string,\n /** Defines the display mode of buy button */\n displayBuyButton: PropTypes.oneOf(getDisplayButtonValues()),\n /** A custom URL for the `VIEW CART` button inside the toast created by BuyButton */\n customToastURL: PropTypes.string,\n}\n\nProductSummaryBuyButton.defaultProps = {\n displayBuyButton: displayButtonTypes.DISPLAY_ALWAYS.value,\n isOneClickBuy: false,\n buyButtonBehavior: DEFAULT_BUTTON_BEHAVIOR,\n}\n\nProductSummaryBuyButton.getSchema = () => {\n return {\n title: 'admin/editor.productSummaryBuyButton.title',\n type: 'object',\n properties: {\n isOneClickBuy: {\n type: 'boolean',\n title: 'admin/editor.productSummary.isOneClickBuy.title',\n default: false,\n isLayout: true,\n },\n displayBuyButton: {\n title: 'admin/editor.productSummary.displayBuyButton.title',\n type: 'string',\n enum: getDisplayButtonValues(),\n enumNames: getDisplayButtonNames(),\n default: displayButtonTypes.DISPLAY_ALWAYS.value,\n isLayout: true,\n },\n },\n }\n}\n\nexport default withRuntimeContext(ProductSummaryBuyButton)\n\n```" } ]
code_store-on-localhost_85ba2eb1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductSummaryBrand/ProductSummaryBrand.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport ProductBrand from '../../../StoreComponents/ProductBrand'\n\nimport ProductSummaryContextApp from '../../../ProductSummaryContext/ProductSummaryContext'\nconst { useProductSummary } = ProductSummaryContextApp\n\nconst DISPLAY_MODE = {\n LOGO: 'logo',\n TEXT: 'text',\n}\n\nconst ProductSummaryBrand = ({\n displayMode,\n fallbackToText,\n height,\n excludeBrands,\n logoWithLink,\n}) => {\n const { product } = useProductSummary()\n return (\n <ProductBrand\n displayMode={displayMode}\n fallbackToText={fallbackToText}\n height={height}\n excludeBrands={excludeBrands}\n logoWithLink={logoWithLink}\n brandName={product.brand}\n brandId={product.brandId}\n />\n )\n}\n\nProductSummaryBrand.propTypes = {\n /** Whether it should be displayed as a logo or as a text */\n displayMode: PropTypes.oneOf(Object.values(DISPLAY_MODE)),\n /** Whether it should display the name of the brand if there is no logo */\n fallbackToText: PropTypes.bool,\n /** List of brands that should be hidden, if any */\n excludeBrands: PropTypes.arrayOf(\n PropTypes.oneOfType([PropTypes.number, PropTypes.string])\n ),\n /** Height of the logo */\n height: PropTypes.number,\n /** If the logo should have a link*/\n logoWithLink: PropTypes.bool,\n}\n\nexport default ProductSummaryBrand\n```" } ]
code_store-on-localhost_0b43323a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductSummaryImage/ImagePlaceholder.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\n\nconst ImagePlaceholder = ({ cssHandle }) => (\n <div className=\"relative\">\n <div className={`${cssHandle} absolute w-100 h-100 contain bg-center`} />\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox=\"0 0 512 512\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n data-testid=\"image-placeholder\"\n >\n <rect width=\"512\" height=\"512\" fill=\"#F2F2F2\" />\n <rect\n x=\"183.857\"\n y=\"180.2\"\n width=\"144.286\"\n height=\"150.474\"\n stroke=\"#CACBCC\"\n strokeWidth=\"2\"\n />\n <path d=\"M183.78 303.688H328.214\" stroke=\"#CACBCC\" strokeWidth=\"2\" />\n <path\n d=\"M205.082 279.563L223.599 240.507L242.116 260.035L269.892 220.979L306.926 279.563H205.082Z\"\n stroke=\"#CACBCC\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n d=\"M252.225 213.939C252.225 219.822 247.66 224.52 242.114 224.52C236.569 224.52 232.004 219.822 232.004 213.939C232.004 208.057 236.569 203.359 242.114 203.359C247.66 203.359 252.225 208.057 252.225 213.939Z\"\n stroke=\"#CACBCC\"\n strokeWidth=\"2\"\n />\n </svg>\n </div>\n)\n\nexport default ImagePlaceholder\n\n```" } ]
code_store-on-localhost_6f2b46bb
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductSummaryImage/ProductImage.test.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport { render, fireEvent } from '@vtex/test-tools/react'\nimport ProductImage from './ProductImage'\nimport { ProductSummaryProvider } from 'vtex.product-summary-context/ProductSummaryContext'\n\ntest('should show placeholder on error', () => {\n const productName = 'Ball'\n const mock = {\n product: {\n productName,\n sku: { image: { imageUrl: 'foo' } },\n },\n }\n\n const { getByAltText, getByTestId } = render(\n <ProductSummaryProvider value={mock}>\n <ProductImage />\n </ProductSummaryProvider>\n )\n\n const image = getByAltText(productName)\n\n fireEvent.error(image)\n expect(getByTestId('image-placeholder')).toBeDefined()\n})\n\n```" } ]
code_store-on-localhost_b6691d33
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductSummaryImage/ProductImage.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { useState } from 'react'\nimport PropTypes from 'prop-types'\nimport { pathOr, compose } from 'ramda'\nimport CollectionBadges from '../../../StoreComponents/CollectionBadges'\nimport DiscountBadge from '../../../StoreComponents/DiscountBadge'\nimport classNames from 'classnames'\nimport useDevice from '../../../DeviceDetector/useDevice'\nimport useResponsiveValues from '../../../ResponsiveValues/useResponsiveValues'\nimport useCssHandles from '../../../CssHandles/useCssHandles'\nimport applyModifiers from '../../../CssHandles/applyModifiers'\n\nimport ImagePlaceholder from './ImagePlaceholder'\n\nimport ProductSummaryContextApp from '../../../ProductSummaryContext/ProductSummaryContext'\n\nimport productSummary from '../../productSummary.css'\n\nimport { changeImageUrlSize } from '../../utils/normalize'\n\nconst { useProductSummary } = ProductSummaryContextApp\nconst CSS_HANDLES = ['image', 'imageContainer', 'product', 'imagePlaceholder']\n\nconst maybeBadge = ({ listPrice, price, label }) => shouldShow => component => {\n if (shouldShow) {\n return (\n <DiscountBadge listPrice={listPrice} sellingPrice={price} label={label}>\n {component}\n </DiscountBadge>\n )\n }\n return component\n}\n\nconst maybeCollection = ({ productClusters }) => shouldShow => component => {\n if (shouldShow && productClusters && productClusters.length > 0) {\n const collections = productClusters.map(cl => cl.name)\n return (\n <CollectionBadges collectionBadgesText={collections}>\n {component}\n </CollectionBadges>\n )\n }\n return component\n}\n\nconst findImageByLabel = (images, selectedLabel) => {\n if (!selectedLabel) {\n return null\n }\n return images.find(({ imageLabel }) => imageLabel === selectedLabel)\n}\n\nconst Image = ({ src, width, height, onError, alt, className }) => {\n const { isMobile } = useDevice()\n\n const dpi = window.devicePixelRatio || (isMobile ? 2 : 1)\n\n const shouldResize = !!(width || height)\n\n return (\n <img\n src={\n shouldResize ? changeImageUrlSize(src, width * dpi, height * dpi) : src\n }\n style={\n shouldResize\n ? {\n width: '100%',\n height,\n objectFit: 'contain',\n maxHeight: 'unset',\n maxWidth: width,\n }\n : null\n }\n loading={shouldResize ? 'lazy' : 'auto'}\n alt={alt}\n className={className}\n onError={onError}\n />\n )\n}\n\nconst ProductImageContent = ({\n product,\n onError,\n hasError,\n showBadge,\n badgeText,\n displayMode,\n mainImageLabel,\n hoverImageLabel,\n showCollections,\n width: widthProp,\n height: heightProp,\n}) => {\n const { productClusters, productName: name } = product || {}\n\n const sku = product && product.sku\n\n const { isMobile } = useDevice()\n const handles = useCssHandles(CSS_HANDLES)\n\n const [width, height] = [\n // fallsback to the other remaining value, if not defined\n parseFloat(widthProp || heightProp || 0),\n parseFloat(heightProp || widthProp || 0),\n ]\n\n const legacyContainerClasses = classNames(\n productSummary.imageStackContainer,\n productSummary.hoverEffect\n )\n\n const containerClassname = classNames(\n 'dib relative',\n handles.imageContainer,\n legacyContainerClasses\n )\n\n if (!sku || hasError) {\n return (\n <div className={containerClassname}>\n <ImagePlaceholder cssHandle={handles.productImage} />\n </div>\n )\n }\n\n const images = pathOr([], ['images'], sku)\n const hoverImage = findImageByLabel(images, hoverImageLabel)\n\n let imageUrl = pathOr({}, ['image', 'imageUrl'], sku)\n if (mainImageLabel) {\n const mainImage = findImageByLabel(images, mainImageLabel)\n if (mainImage) {\n imageUrl = mainImage.imageUrl\n }\n }\n\n const legacyImageClasses = classNames({\n [productSummary.imageNormal]: displayMode !== 'inline',\n [productSummary.imageInline]: displayMode === 'inline',\n })\n\n // TODO: change ProductSummaryContext to have `selectedSku` field instead of `sku`\n const commertialOffer = pathOr(\n {},\n ['sku', 'seller', 'commertialOffer'],\n product\n )\n\n const withBadge = maybeBadge({\n listPrice: commertialOffer.ListPrice,\n price: commertialOffer.Price,\n label: badgeText,\n })\n\n const withCollection = maybeCollection({ productClusters })\n\n const imageClassname = classNames(legacyImageClasses, handles.image)\n\n const hoverImageClassname = classNames(\n 'w-100 h-100 dn absolute top-0 left-0 z-999',\n applyModifiers(handles.image, 'hover'),\n legacyImageClasses,\n productSummary.hoverImage\n )\n\n const img = (\n <div className={containerClassname}>\n <Image\n src={imageUrl}\n width={width}\n height={height}\n alt={name}\n className={imageClassname}\n onError={onError}\n />\n {hoverImage && !isMobile && (\n <Image\n src={hoverImage.imageUrl}\n width={width}\n height={height}\n alt={name}\n className={hoverImageClassname}\n onError={onError}\n />\n )}\n </div>\n )\n\n return compose(\n withBadge(showBadge),\n withCollection(showCollections)\n )(img)\n}\n\nconst ProductImage = ({\n showBadge,\n badgeText,\n displayMode,\n mainImageLabel,\n hoverImageLabel,\n showCollections,\n width: widthProp,\n height: heightProp,\n}) => {\n const { product } = useProductSummary()\n\n const { widthProp: width, heightProp: height } = useResponsiveValues({\n widthProp,\n heightProp,\n })\n\n const [error, setError] = useState(false)\n\n const imageClassName = classNames(productSummary.imageContainer, {\n 'db w-100 center': displayMode !== 'inline',\n })\n\n return (\n <div className={imageClassName}>\n <ProductImageContent\n width={width}\n height={height}\n hasError={error}\n product={product}\n badgeText={badgeText}\n showBadge={showBadge}\n displayMode={displayMode}\n onError={() => setError(true)}\n mainImageLabel={mainImageLabel}\n hoverImageLabel={hoverImageLabel}\n showCollections={showCollections}\n />\n </div>\n )\n}\n\nProductImage.propTypes = {\n /** Set the discount badge's visibility */\n showBadge: PropTypes.bool,\n /** Text shown on badge */\n badgeText: PropTypes.string,\n /** Defines if the collection badges are shown */\n showCollections: PropTypes.bool,\n /** Display mode of the summary */\n displayMode: PropTypes.oneOf(['normal', 'inline']),\n hoverImageLabel: PropTypes.string,\n mainImageLabel: PropTypes.string,\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.object]),\n height: PropTypes.oneOfType([PropTypes.number, PropTypes.object]),\n}\n\nProductImage.defaultProps = {\n showBadge: true,\n showCollections: false,\n displayMode: 'normal',\n hoverImageLabel: '',\n mainImageLabel: '',\n}\n\nProductImage.getSchema = () => {\n return {\n title: 'admin/editor.productSummaryImage.title',\n description: 'admin/editor.productSummaryImage.description',\n type: 'object',\n properties: {\n showBadge: {\n type: 'boolean',\n title: 'admin/editor.productSummary.showBadge.title',\n default: ProductImage.defaultProps.showBadge,\n isLayout: true,\n },\n showCollections: {\n type: 'boolean',\n title: 'admin/editor.productSummary.showCollections.title',\n default: ProductImage.defaultProps.showCollections,\n isLayout: true,\n },\n displayMode: {\n title: 'admin/editor.productSummary.displayMode.title',\n type: 'string',\n enum: ['normal', 'inline'],\n default: ProductImage.defaultProps.displayMode,\n isLayout: true,\n },\n hoverImageLabel: {\n title: 'admin/editor.productSummaryImage.hoverImageLabel.title',\n type: 'string',\n default: '',\n isLayout: false,\n },\n },\n }\n}\n\nexport default ProductImage\n\n```" } ]
code_store-on-localhost_c2ea77e7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductSummaryName/ProductSummaryName.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { path } from 'ramda'\nimport ProductName from '../../../StoreComponents/ProductName'\nimport useCssHandles from '../../../CssHandles/useCssHandles'\n\nimport ProductSummaryContextApp from '../../../ProductSummaryContext/ProductSummaryContext'\nconst { useProductSummary } = ProductSummaryContextApp\n\nconst CSS_HANDLES = [\n 'nameContainer',\n 'nameWrapper',\n 'brandName',\n 'skuName',\n 'productReference',\n 'productNameLoader',\n]\n\nconst ProductSummaryName = ({ showFieldsProps }) => {\n const { product } = useProductSummary()\n const handles = useCssHandles(CSS_HANDLES)\n const productName = path(['productName'], product)\n // TODO: change ProductSummaryContext to have `selectedSku` field instead of `sku`\n const skuName = path(['sku', 'name'], product)\n const brandName = path(['brand'], product)\n\n const containerClasses = `${handles.nameContainer} flex items-start justify-center pv6`\n const wrapperClasses = `${handles.nameWrapper} overflow-hidden c-on-base f5`\n const brandNameClasses = `${handles.brandName} t-body`\n const skuNameClasses = `${handles.skuName} t-small`\n const loaderClasses = `${handles.productNameLoader} pt5 overflow-hidden`\n\n return (\n <div className={containerClasses}>\n <ProductName\n className={wrapperClasses}\n brandNameClass={brandNameClasses}\n skuNameClass={skuNameClasses}\n loaderClass={loaderClasses}\n productReferenceClass={handles.productReference}\n name={productName}\n skuName={skuName}\n brandName={brandName}\n {...showFieldsProps}\n />\n </div>\n )\n}\n\nProductSummaryName.defaultProps = {\n showFieldsProps: {\n showProductReference: false,\n showBrandName: false,\n showSku: false,\n },\n}\n\nProductSummaryName.propTypes = {\n /** Name schema props */\n showFieldsProps: PropTypes.object,\n}\n\nProductSummaryName.getSchema = () => {\n return {\n title: 'admin/editor.productSummaryName.title',\n type: 'object',\n properties: {\n showFieldsProps: ProductName.schema,\n },\n }\n}\n\nexport default ProductSummaryName\n\n```" } ]
code_store-on-localhost_cf57f0ad
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductSummaryPrice/ProductSummaryPrice.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { path, prop, flatten, pluck } from 'ramda'\nimport classNames from 'classnames'\nimport Spinner from '../../../Styleguide/Spinner'\nimport ProductPrice from '../../../StoreComponents/ProductPrice'\nimport ProductSummaryContextApp from '../../../ProductSummaryContext/ProductSummaryContext'\n\nimport useCssHandles from '../../../CssHandles/useCssHandles'\n\nconst { useProductSummary } = ProductSummaryContextApp\nconst CSS_HANDLES = [\n 'priceContainer',\n 'productPriceClass',\n 'listPriceContainer',\n 'listPriceLabel',\n 'listPrice',\n 'sellingPriceContainer',\n 'sellingPriceLabel',\n 'sellingPrice',\n 'savingsContainer',\n 'savings',\n 'interestRate',\n 'installmentContainer',\n 'listPriceRange',\n 'sellingPriceRange',\n 'priceLoading',\n]\n\nconst isAvailableProduct = price => price !== 0\n\nconst getPrices = (product, attribute) => {\n if (!product || (!product.items && !product.priceRange)) {\n return []\n }\n if (product.priceRange) {\n const values = product.priceRange[attribute]\n return values ? [values.lowPrice, values.highPrice] : []\n }\n\n // No priceRange resolver provided, use sku information\n const sellers = flatten(pluck('sellers', product.items))\n const offerAttribute = attribute === 'sellingPrice' ? 'Price' : 'ListPrice'\n const prices = sellers.map(path(['commertialOffer', offerAttribute]))\n const availableProductsPrices = prices.filter(isAvailableProduct)\n return availableProductsPrices\n}\n\nconst ProductSummaryPrice = ({\n showListPrice,\n showSellingPriceRange,\n showLabels,\n showInstallments,\n showDiscountValue,\n labelSellingPrice,\n labelListPrice,\n showBorders,\n showListPriceRange,\n}) => {\n const { product, isLoading } = useProductSummary()\n const handles = useCssHandles(CSS_HANDLES)\n // TODO: change ProductSummaryContext to have `selectedSku` field instead of `sku`\n const commertialOffer = path(['sku', 'seller', 'commertialOffer'], product)\n\n if (isLoading) {\n return (\n <div\n className={`${handles.priceLoading} flex items-end justify-end w-100 h1 pr6`}\n >\n <Spinner size={20} />\n </div>\n )\n }\n\n const priceClasses = {\n containerClass: classNames('flex flex-column justify-end items-center', {\n [`${handles.priceContainer} pv5`]: !showBorders,\n }),\n sellingPriceClass: `${handles.sellingPrice} dib ph2 t-body t-heading-5-ns`,\n }\n\n const sellingPriceList = showSellingPriceRange\n ? getPrices(product, 'sellingPrice')\n : []\n const listPriceList = showListPriceRange\n ? getPrices(product, 'listPrice')\n : []\n const sellingPrice = prop('Price', commertialOffer)\n\n return (\n <div className={priceClasses.containerClass}>\n {sellingPrice !== 0 && (\n <ProductPrice\n className={`${handles.productPriceClass} flex flex-column justify-start`}\n listPriceContainerClass={`${handles.listPriceContainer} pv1 normal c-muted-2`}\n listPriceLabelClass={`${handles.listPriceLabel} dib strike t-small t-mini`}\n listPriceClass={`${handles.listPrice} dib ph2 strike t-small-ns t-mini`}\n sellingPriceContainerClass={`${handles.sellingPriceContainer} pt1 pb3 c-on-base`}\n sellingPriceLabelClass={`${handles.sellingPriceLabel} dib`}\n sellingPriceClass={priceClasses.sellingPriceClass}\n savingsContainerClass={`${handles.savingsContainer} t-small-ns c-muted-2`}\n savingsClass={`${handles.savings} dib`}\n interestRateClass={`${handles.interestRate} dib pl2`}\n installmentContainerClass={`${handles.installmentContainer} t-small-ns c-muted-2`}\n listPrice={prop('ListPrice', commertialOffer)}\n sellingPriceList={sellingPriceList}\n listPriceRangeClass={`${handles.listPriceRange} dib ph2 t-small-ns strike`}\n sellingPriceRangeClass={`${handles.sellingPriceRange} dib ph2 t-small-ns`}\n sellingPrice={prop('Price', commertialOffer)}\n installments={prop('Installments', commertialOffer)}\n showListPrice={showListPrice}\n showSellingPriceRange={showSellingPriceRange}\n showLabels={showLabels}\n showInstallments={showInstallments}\n labelSellingPrice={labelSellingPrice}\n labelListPrice={labelListPrice}\n listPriceList={listPriceList}\n showListPriceRange={showListPriceRange}\n showSavings={showDiscountValue}\n />\n )}\n </div>\n )\n}\n\nProductSummaryPrice.propTypes = {\n /** Set the product selling price range visibility */\n showSellingPriceRange: PropTypes.bool,\n /** Set the product list price's visibility */\n showListPrice: PropTypes.bool,\n /** Set the product list price range visibility */\n showListPriceRange: PropTypes.bool,\n /** Set pricing labels' visibility */\n showLabels: PropTypes.bool,\n /** Set installments' visibility */\n showInstallments: PropTypes.bool,\n /** Set savings' visibility*/\n showDiscountValue: PropTypes.bool,\n /** Text of selling Price's label */\n labelSellingPrice: PropTypes.string,\n /** Text of list Price's label */\n labelListPrice: PropTypes.string,\n /** Set installments' visibility */\n showBorders: PropTypes.bool,\n}\n\nProductSummaryPrice.defaultProps = {\n showSellingPriceRange: false,\n showDiscountValue: false,\n showListPriceRange: false,\n showListPrice: true,\n showInstallments: true,\n showLabels: true,\n labelSellingPrice: '',\n labelListPrice: '',\n showBorders: false,\n}\n\nProductSummaryPrice.schema = {\n title: 'admin/editor.productSummaryPrice.title',\n description: 'admin/editor.productSummaryPrice.description',\n type: 'object',\n properties: {\n showListPrice: {\n type: 'boolean',\n title: 'admin/editor.productSummaryPrice.showListPrice.title',\n default: ProductSummaryPrice.defaultProps.showListPrice,\n isLayout: true,\n },\n showSellingPriceRange: {\n type: 'boolean',\n title: 'admin/editor.productSummaryPrice.showSellingPriceRange.title',\n default: ProductSummaryPrice.defaultProps.showSellingPriceRange,\n isLayout: true,\n },\n showListPriceRange: {\n type: 'boolean',\n title: 'admin/editor.productSummaryPrice.showListPriceRange.title',\n default: ProductSummaryPrice.defaultProps.showListPrice,\n isLayout: true,\n },\n showInstallments: {\n type: 'boolean',\n title: 'admin/editor.productSummaryPrice.showInstallments.title',\n default: ProductSummaryPrice.defaultProps.showInstallments,\n isLayout: true,\n },\n showDiscountValue: {\n type: 'boolean',\n title: 'admin/editor.productSummaryPrice.showDiscountValue.title',\n default: ProductSummaryPrice.defaultProps.showDiscountValue,\n },\n showLabels: {\n type: 'boolean',\n title: 'admin/editor.productSummaryPrice.showLabels.title',\n default: ProductSummaryPrice.defaultProps.showLabels,\n isLayout: true,\n },\n showBorders: {\n type: 'boolean',\n title: 'admin/editor.productSummaryPrice.showBorders.title',\n default: ProductSummaryPrice.defaultProps.showBorders,\n isLayout: true,\n },\n },\n}\n\nexport default ProductSummaryPrice\n\n```" } ]
code_store-on-localhost_889e8780
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductSummaryAddToListButton/ProductSummaryAddToListButton.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { useMemo } from 'react'\nimport { ExtensionPoint } from '../../../../../../vtex.render-runtime'\nimport { path } from 'ramda'\nimport ProductSummaryContextApp from '../../../ProductSummaryContext/ProductSummaryContext'\nconst { useProductSummary } = ProductSummaryContextApp\nimport useCssHandles from '../../../CssHandles/useCssHandles'\n\n// TODO: change ProductSummaryContext to have `selectedSku` field instead of `sku`\nconst getSkuId = path(['sku', 'itemId'])\nconst getProductId = path(['productId'])\nconst CSS_HANDLES = ['addToListBtn']\n\n// This avoids triggering the link to the product page\nconst captureClick = e => {\n e.preventDefault()\n e.stopPropagation()\n}\n\nfunction ProductSummaryAddToListButton() {\n const handles = useCssHandles(CSS_HANDLES)\n const productContext = useProductSummary()\n\n const skuId = getSkuId(productContext.product)\n const productId = getProductId(productContext.product)\n\n const productProp = useMemo(\n () => ({\n skuId,\n productId,\n quantity: 1,\n }),\n [skuId, productId]\n )\n\n return (\n <div\n role=\"button\"\n tabIndex=\"-1\"\n onKeyDown={() => {}}\n className={`${handles.addToListBtn} absolute z-1`}\n onClick={captureClick}\n >\n <ExtensionPoint id=\"addon-summary-btn\" product={productProp} />\n </div>\n )\n}\n\nexport default ProductSummaryAddToListButton\n\n```" } ]
code_store-on-localhost_d717f39c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductSummaryDescription/ProductSummaryDescription.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Fragment } from 'react'\n\nimport ProductSummaryContextApp from '../../../ProductSummaryContext/ProductSummaryContext'\nconst { useProductSummary } = ProductSummaryContextApp\nimport useCssHandles from '../../../CssHandles/useCssHandles'\n\nconst MAX_SIZE_DESCRIPTION = 120\nconst CSS_HANDLES = ['description']\n\nconst ProductSummaryDescription = () => {\n const {\n product: { description },\n } = useProductSummary()\n const handles = useCssHandles(CSS_HANDLES)\n\n if (!description) return <Fragment />\n\n const descriptionClasses = `${handles.description} c-muted-2 t-small`\n\n const descriptionTruncated =\n description.length > MAX_SIZE_DESCRIPTION\n ? `${description.substring(0, MAX_SIZE_DESCRIPTION)}...`\n : description\n\n return <span className={descriptionClasses}>{descriptionTruncated}</span>\n}\n\nexport default ProductSummaryDescription\n\n```" } ]
code_store-on-localhost_89b334e4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductSummarySpecificationBadges/index.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\n\nimport BaseSpecificationBadges from '../../../ProductSpecificationBadges/BaseSpecificationBadges'\nimport ProductSummaryContextApp from '../../../ProductSummaryContext/ProductSummaryContext'\nconst { useProductSummary } = ProductSummaryContextApp\n\nconst ProductSummarySpecificationBadges = ({\n specificationGroupName,\n visibleWhen,\n specificationsOptions,\n specificationName,\n displayValue,\n orientation,\n}) => {\n const { product } = useProductSummary()\n return (\n <BaseSpecificationBadges\n product={product}\n visibleWhen={visibleWhen}\n specificationsOptions={specificationsOptions}\n specificationName={specificationName}\n displayValue={displayValue}\n orientation={orientation}\n specificationGroupName={specificationGroupName}\n />\n )\n}\n\nProductSummarySpecificationBadges.schema = {\n ...BaseSpecificationBadges.schema,\n title: 'admin/editor.product-summary-specification-badges.title',\n}\n\nexport default ProductSummarySpecificationBadges\n\n```" } ]
code_store-on-localhost_384c4282
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductSummaryAttachmentList/AttachmentChildren.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport AddedAttachmentsList from './AddedAttachmentsList'\nimport RemovedAttachmentsList from './RemovedAttachmentsList'\n\nimport useCssHandles from '../../../CssHandles/useCssHandles'\n\nconst CSS_HANDLES = ['attachmentChildrenContainer']\n\nconst AttachmentChildren = ({ addedOptions, removedOptions }) => {\n const handles = useCssHandles(CSS_HANDLES)\n if (addedOptions.length === 0 && removedOptions.length === 0) {\n return null\n }\n\n return (\n <div className={`${handles.attachmentChildrenContainer} ml3`}>\n <AddedAttachmentsList addedOptions={addedOptions} showItemPrice={false} />\n <RemovedAttachmentsList removedOptions={removedOptions} />\n </div>\n )\n}\n\nexport default AttachmentChildren\n\n```" } ]
code_store-on-localhost_f6674891
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductSummaryAttachmentList/AttachmentItem.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { memo } from 'react'\nimport { string, number, object, bool } from 'prop-types'\nimport ProductPrice from '../../../StoreComponents/ProductPrice'\nimport { reject } from 'ramda'\n\nimport useCssHandles from '../../../CssHandles/useCssHandles'\nimport AttachmentChildren from './AttachmentChildren'\n\nconst CSS_HANDLES = ['attachmentItemContainer', 'attachmentItem', 'attachmentItemProductText']\n\nconst itemShouldHide = ({ item, extraQuantity }) =>\n extraQuantity === 0 && item.sellingPriceWithAssemblies === 0\n\nconst AttachmentItem = ({\n productText,\n price,\n assemblyOptions,\n showItemPrice,\n}) => {\n const handles = useCssHandles(CSS_HANDLES)\n const childrenAdded = (assemblyOptions && assemblyOptions.added) || []\n const childrenRemoved = (assemblyOptions && assemblyOptions.removed) || []\n const filteredChildrenAdded = reject(itemShouldHide, childrenAdded)\n const parentColor =\n filteredChildrenAdded.length > 0 || childrenRemoved.length > 0\n ? 'c-on-base'\n : 'c-muted-2'\n\n return (\n <div className={`${handles.attachmentItemContainer} flex flex-column pv1`}>\n <div className={`${handles.attachmentItem} flex items-center justify-between`}>\n <span className={`${handles.attachmentItemProductText} t-small ${parentColor} tl pr3`}>{productText}</span>\n {price != null && showItemPrice && price > 0 && (\n <ProductPrice\n sellingPrice={price}\n sellingPriceContainerClass=\"c-on-base\"\n sellingPriceLabelClass=\"dib\"\n sellingPriceClass=\"dib t-small c-muted-2\"\n showListPrice={false}\n showLabels={false}\n showInstallments={false}\n />\n )}\n </div>\n <AttachmentChildren\n addedOptions={filteredChildrenAdded}\n removedOptions={childrenRemoved}\n />\n </div>\n )\n}\n\nAttachmentItem.propTypes = {\n productText: string.isRequired,\n price: number,\n assemblyOptions: object,\n showItemPrice: bool,\n}\n\nexport default memo(AttachmentItem)\n\n```" } ]
code_store-on-localhost_47abfb2f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductSummaryAttachmentList/RemovedAttachmentsList.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Fragment } from 'react'\nimport { injectIntl } from 'react-intl'\nimport { arrayOf } from 'prop-types'\n\nimport AttachmentItem from './AttachmentItem'\n\nimport { removedOptionShape } from '../../utils/propTypes'\n\nconst wasCompletelyRemoved = ({ removedQuantity, initialQuantity }) =>\n removedQuantity === 1 && removedQuantity === initialQuantity\n\nconst formatAttachmentName = (missingOption, intl) => {\n const { name, removedQuantity } = missingOption\n if (wasCompletelyRemoved(missingOption)) {\n return intl.formatMessage(\n { id: 'store/productSummary.missingOptionName' },\n { name }\n )\n }\n\n const extraParams = {\n sign: '-',\n name,\n quantity: removedQuantity,\n }\n return intl.formatMessage(\n { id: 'store/productSummary.attachmentName' },\n extraParams\n )\n}\n\nconst RemovedAttachmentsList = ({ removedOptions, intl }) => {\n if (removedOptions.length === 0) {\n return null\n }\n\n return (\n <Fragment>\n {removedOptions.map(removedOption => {\n const productText = formatAttachmentName(removedOption, intl)\n return <AttachmentItem productText={productText} key={productText} />\n })}\n </Fragment>\n )\n}\n\nRemovedAttachmentsList.propTypes = {\n removedOptions: arrayOf(removedOptionShape).isRequired\n}\n\nexport default injectIntl(RemovedAttachmentsList)\n\n```" } ]
code_store-on-localhost_d7c1e44f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductSummaryAttachmentList/AttachmentList.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport { pathOr, reject } from 'ramda'\n\nimport ProductSummaryContextApp from '../../../ProductSummaryContext/ProductSummaryContext'\nconst { useProductSummary } = ProductSummaryContextApp\n\nimport RemovedAttachmentsList from './RemovedAttachmentsList'\nimport AddedAttachmentsList from './AddedAttachmentsList'\n\nimport useCssHandles from '../../../CssHandles/useCssHandles'\n\nconst CSS_HANDLES = ['attachmentListContainer']\n\nconst itemShouldHide = ({ item, extraQuantity }) =>\n extraQuantity === 0 && item.sellingPriceWithAssemblies === 0\n\nconst AttachmentList = () => {\n const { product } = useProductSummary()\n const handles = useCssHandles(CSS_HANDLES)\n const addedOptions = pathOr([], ['assemblyOptions', 'added'], product)\n const removedOptions = pathOr([], ['assemblyOptions', 'removed'], product)\n\n const filteredOption = reject(itemShouldHide, addedOptions)\n\n if (filteredOption.length === 0 && removedOptions.length === 0) {\n return null\n }\n\n return (\n <div className={`${handles.attachmentListContainer} pv2`}>\n <AddedAttachmentsList addedOptions={filteredOption} />\n <RemovedAttachmentsList removedOptions={removedOptions} />\n </div>\n )\n}\n\nexport default AttachmentList\n\n```" } ]
code_store-on-localhost_c24a1360
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSummary/components/ProductSummaryAttachmentList/AddedAttachmentsList.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Fragment } from 'react'\nimport { arrayOf, bool } from 'prop-types'\nimport { FormattedMessage } from 'react-intl'\n\nimport AttachmentItem from './AttachmentItem'\n\nimport { CHOICE_TYPES } from '../../utils/attachmentHelper'\n\nimport { addedOptionShape } from '../../utils/propTypes'\n\nconst formatAttachmentName = option => (\n <FormattedMessage\n id=\"store/productSummary.attachmentName\"\n values={{\n sign: '+',\n name: option.item.name,\n quantity: option.normalizedQuantity,\n }}\n />\n)\n\nconst AddedAttachmentsList = ({ addedOptions, showItemPrice }) => {\n if (addedOptions.length === 0) {\n return null\n }\n return (\n <Fragment>\n {addedOptions.map(option => {\n const isMultiple = option.choiceType === CHOICE_TYPES.MULTIPLE\n const productText = isMultiple\n ? formatAttachmentName(option)\n : option.item.name\n return (\n <AttachmentItem\n productText={productText}\n price={\n option.item.sellingPriceWithAssemblies * option.normalizedQuantity\n }\n key={`${option.item.name}-${option.choiceType}`}\n assemblyOptions={option.item.assemblyOptions}\n showItemPrice={showItemPrice}\n />\n )\n })}\n </Fragment>\n )\n}\n\nAddedAttachmentsList.defaultProps = {\n showItemPrice: true,\n}\n\nAddedAttachmentsList.propTypes = {\n addedOptions: arrayOf(addedOptionShape).isRequired,\n showItemPrice: bool,\n}\n\nexport default AddedAttachmentsList\n\n```" } ]